Count message tokens
POST/v1/messages/count_tokens
Counts a Messages request's input tokens without calling a model. Since 1.8.5. On a route to Anthropic the count is Anthropic's own; otherwise it is DVARA's estimate.
Workspace status, policy, prompt templates, PII, and guardrails run on
the request. No model is called, no usage or cost is booked, and the
count does not count against a call cap or the unlicensed call band.
The rate limit counts it as a request. Same key and scope as
/v1/messages.
Request
Responses
- 200
- 400
- 401
- 403
- 429
The input token count
Invalid request, unsupported field or capability, unknown model, or a missing or other anthropic-version.
A key is required. Missing, invalid, revoked, or expired keys are refused.
Policy, PII, guardrail, scope, or IP access refused the call.
Per-key rate limit reached.