count Tokens
public CompletableFuture<CountTokensResponse> countTokens(String model, List<Content> contents, CountTokensConfig config)
Asynchronously counts tokens given a GenAI model and a list of content.
Return
a com.google.genai.types.CountTokensResponse instance that contains tokens count.
Parameters
model
the name of the GenAI model to use.
contents
a < to send to count tokens for.
config
a com.google.genai.types.CountTokensConfig instance that specifies the optional configurations
public CompletableFuture<CountTokensResponse> countTokens(String model, String text, CountTokensConfig config)
Asynchronously counts tokens given a GenAI model and a text string.
Return
a com.google.genai.types.CountTokensResponse instance that contains tokens count.
Parameters
model
the name of the GenAI model to use.
text
the text string to send to count tokens for.
config
a com.google.genai.types.CountTokensConfig instance that specifies the optional configurations