GenerativeModelCountTokensAsync(GenerateContentRequest) Method

Counts the number of tokens in the content based on the provided GenerateContentRequest.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public Task<CountTokensResponse> CountTokensAsync(
	GenerateContentRequest generateContentRequest
)

Parameters

generateContentRequest  GenerateContentRequest
An instance of GenerateContentRequest containing the input data for which the token count is calculated.

Return Value

TaskCountTokensResponse
A task that represents the asynchronous operation, containing a CountTokensResponse with token count details.

Implements

IGenerativeModelCountTokensAsync(GenerateContentRequest)

See Also