Skip to main content
Version: 1.13.0-dev

Count a chat request's input tokens

POST 

/v1/tokens/count

Counts a Chat Completions request's input tokens without calling a model. Since 1.10.0. The body is a /v1/chat/completions body, so you count exactly what you are about to send. Add a models list (up to 10) to compare the same request across models.

For each model the answer gives the input tokens; who counted them (the provider routing picks, when it can count, else DVARA); the vocabulary and where the tokens go; the context window DVARA holds the request to and how much of it the input and max_tokens would use; and the cost at DVARA's prices. Where DVARA has no price it answers pricing_known: false, never a cost of zero. Prices need the Enterprise platform.

The request is routed as a call would be. Workspace status, policy, prompt templates, PII and guardrails run on it, because its text can go to a provider to be counted. No model is called. No usage or cost is recorded, and the count does not count against a call cap or the unlicensed call band. A key with scopes needs completions:write.

A model that is refused gets an error entry while the others are counted. When every model is refused (always so for a single model), the first refusal is the answer, with the status a call would get.

Request​

Responses​

One count per model