Count tokens

Return an approximate token count for a Gemini request without running the model. This is a fast estimate for pre-flight sizing, not an exact tokenization; the billed token counts on the actual response are authoritative.

Authentication

AuthorizationBearer

Pass your EmpirioLabs API key as a bearer token. The Anthropic-style x-api-key header is also accepted on every endpoint.

Path parameters

modelstringRequired

An EmpirioLabs chat model id, for example qwen3-7-max.

Request

This endpoint expects an object.
contentslist of objectsRequired

Conversation turns. Roles are user and model.

systemInstructionobjectOptional
generationConfigobjectOptional
toolslist of objectsOptional
toolConfigobjectOptional
safetySettingslist of objectsOptional
Accepted for compatibility.

Response

Token count.
totalTokensintegerOptional

Approximate total token count (estimate

Errors

401
Unauthorized Error