countTokens

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


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