Skip to main content
POST
Count Gemini input tokens
POST /v1/token-counts requires an active GENGEN API key and does not require wallet balance. It creates no generation, wallet hold, or charge.
The example count is illustrative; use the count returned for your request. cachedContentTokenCount is included when supplied by the provider. Supply either Chat Completions messages or Responses input, with the same system instructions, content parts, function declarations and providerOptions.google that you plan to generate with. Multimodal content and tool-history validation match the generation endpoints. Maximum request body: 16 MiB. Raw gs:// media references, streaming, background execution and stored response continuation are not supported. Counts cover the supplied input. They do not predict generated output, the number of Google searches, or content retrieved by Search and URL Context, so they are not a final price quote. Generation is settled using its returned usage. Try Count tokens · Free in the Hydrogen text Explorer.

Authorizations

Authorization
string
header
required

A workspace API key beginning with gengen_live_.

Body

application/json

Uses the same validation and native conversation replay as generation. Only synchronous, full-history requests are accepted. Maximum request body is 16 MiB.

model
enum<string>
required
Available options:
gemini-4-neon,
gemini-4-hydrogen
messages
any
required
input
any
instructions
string
tools
object[]
providerOptions
object
stream
boolean

Response

The provider-reported input token count. No wallet hold or charge is created.

model
enum<string>
required
Available options:
gemini-4-neon,
gemini-4-hydrogen
totalTokens
integer
required
Required range: x >= 0
cachedContentTokenCount
integer
Required range: x >= 0