GET
/v1/schemas/gemini/chat/v1beta/models/{modelsId}:countTokens?kind=output
Accept:
| field | recorded source |
|---|---|
| schema | Source linked above.Source tracef697c69526f2d0f93e6e022d34a6a98146776f0f982cc56727132c048329221c{
"fetchedAt": 1783328683,
"extractorVersion": "1",
"verifiedAt": null
} |
Response body
4 properties · 0 required · 1 $defs| property | type | description | constraints |
|---|---|---|---|
| cachedContentTokenCount | integer | Number of tokens in the cached part of the prompt (the cached content). | format: int32 |
| totalTokens | integer | The number of tokens that the `Model` tokenizes the `prompt` into. Always non-negative. | format: int32 |
| promptTokensDetails | ModalityTokenCount[] | Output only. List of modalities that were processed in the request input. | |
| cacheTokensDetails | ModalityTokenCount[] | Output only. List of modalities that were processed in the cached content. |
Types
1 $defsModalityTokenCountobject
Represents token counting info for a single modality.
| tokenCount | integer | Number of tokens. | format: int32 |
| modality | enum | The modality associated with this token count. | MODALITY_UNSPECIFIED | TEXT | IMAGE | VIDEO | AUDIO | DOCUMENT |
Validate a payload
before you spend tokensshell
$ curl -X POST https://modelschemas.com/v1/validate \
-d '{"provider":"gemini","endpointId":"v1beta/models/{modelsId}:countTokens","payload":{…}}'
→ {"valid": false, "errors": [{"path": "#", "keyword": "required", …}]}