BaseModelCountTokensAsync Method

Counts the number of tokens in a given input using the provided model and request.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
protected virtual Task<CountTokensResponse> CountTokensAsync(
	string model,
	CountTokensRequest request
)

Parameters

model  String
The name of the Generative AI Model to use for counting tokens. Format: `models/{model}`.
request  CountTokensRequest
The CountTokensRequest containing the input data for token counting.

Return Value

TaskCountTokensResponse
The CountTokensResponse containing details about the token count.

See Also