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