GET

/v1/schemas/gemini/chat/v1beta/models/{modelsId}:countTokens?kind=output

kind outputactivity chathash 0297c146…extracted Jul 6, 2026version currentsource upstream spec ↗
fieldrecorded source
schemaSource linked above.
Source trace
f697c69526f2d0f93e6e022d34a6a98146776f0f982cc56727132c048329221c
{
  "fetchedAt": 1783328683,
  "extractorVersion": "1",
  "verifiedAt": null
}

Response body

4 properties · 0 required · 1 $defs
propertytypedescriptionconstraints
cachedContentTokenCountintegerNumber of tokens in the cached part of the prompt (the cached content).format: int32
totalTokensintegerThe number of tokens that the `Model` tokenizes the `prompt` into. Always non-negative.format: int32
promptTokensDetailsModalityTokenCount[]Output only. List of modalities that were processed in the request input.
cacheTokensDetailsModalityTokenCount[]Output only. List of modalities that were processed in the cached content.

Types

1 $defs

ModalityTokenCountobject

Represents token counting info for a single modality.

tokenCountintegerNumber of tokens.format: int32
modalityenumThe modality associated with this token count.MODALITY_UNSPECIFIED | TEXT | IMAGE | VIDEO | AUDIO | DOCUMENT

Validate a payload

before you spend tokens
shell
$ curl -X POST https://modelschemas.com/v1/validate \
    -d '{"provider":"gemini","endpointId":"v1beta/models/{modelsId}:countTokens","payload":{…}}'
→ {"valid": false, "errors": [{"path": "#", "keyword": "required", …}]}