Google Generative AI SDK
C#
Show/Hide TOC
Generative
Model
Count
Tokens
Async(IEnumerable
Content
) Method
Asynchronously counts the tokens in the given contents.
Definition
Namespace:
GenerativeAI
Assembly:
GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
Copy
public
Task
<
CountTokensResponse
>
CountTokensAsync
(
IEnumerable
<
Content
>
contents
)
Parameters
contents
IEnumerable
Content
A collection of
Content
objects representing the input for which tokens need to be counted.
Return Value
Task
CountTokensResponse
A task representing the asynchronous operation, containing the
CountTokensResponse
with the resulting token count.
Implements
IGenerativeModel
CountTokensAsync(IEnumerable
Content
)
See Also
Reference
GenerativeModel Class
CountTokensAsync Overload
GenerativeAI Namespace
In This Article
Definition
Parameters
Return Value
Implements
See Also