Google Generative AI SDK
C#
Show/Hide TOC
Generative
Model
Count
Tokens
Async(Count
Tokens
Request) Method
Counts tokens asynchronously based on the provided request.
Definition
Namespace:
GenerativeAI
Assembly:
GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
Copy
public
Task
<
CountTokensResponse
>
CountTokensAsync
(
CountTokensRequest
request
)
Parameters
request
CountTokensRequest
An instance of
CountTokensRequest
containing the details of contents or generation parameters for counting tokens.
Return Value
Task
CountTokensResponse
A task that represents the asynchronous operation, containing a
CountTokensResponse
with the token count details.
Implements
IGenerativeModel
CountTokensAsync(CountTokensRequest)
See Also
Reference
GenerativeModel Class
CountTokensAsync Overload
GenerativeAI Namespace
In This Article
Definition
Parameters
Return Value
Implements
See Also