Count tokens
POST /messages/count_tokens
Count the input tokens a Messages request would consume, without running it. Same request shape as POST /messages (minus max_tokens); free.
AuthorizationBearer <token>
Your Munito API key.
In: header
Header Parameters
munito-service-tier?string
priority, standard or flex. The response names the tier that is billed; see x-ratelimit-over-limit.
Default
"standard"Value in
- "priority"
- "standard"
- "flex"
munito-affinity?string
An opaque token. Send it back with the next request of the conversation, so that the prompt cache can serve it.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
model*string
Model id from GET /models.
messages*array<>
The messages to count, Anthropic-style.
Response Body
application/json
curl -X POST "https://example.com/messages/count_tokens" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen/qwen3.8-27b",
"messages": [
{
"role": "user",
"content": "Explain intelligence sovereignty in one sentence."
}
]
}'{
"input_tokens": 18
}