Skip to content
RU

Count tokens (Anthropic-compatible)

POST
/messages/count_tokens
curl --request POST \
--url https://api.mixen.ai/v1/messages/count_tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "example", "max_tokens": 1, "messages": [ {} ], "system": [ {} ], "tools": [ {} ], "tool_choice": {}, "temperature": 1, "top_p": 1, "top_k": 1, "stream": false, "stop_sequences": [ "example" ], "thinking": {}, "provider": {}, "service_tier": "example", "metadata": {} }'

Cheap ~chars/4 estimate without an upstream call. Used by Claude Code for context/compact decisions.

Media typeapplication/json
CountTokensRequest
object
model
required
Model
string
max_tokens
Any of:
integer
>= 1
messages
required
Messages
Array<object>
object
key
additional properties
any
system
Any of:
string
tools
Any of:
Array<object>
object
key
additional properties
any
tool_choice
Any of:
object
key
additional properties
any
temperature
Any of:
number
top_p
Any of:
number
<= 1
top_k
Any of:
integer
stream
Stream
boolean
stop_sequences
Any of:
Array<string>
thinking
Any of:
object
key
additional properties
any
provider
Any of:
object
key
additional properties
any
service_tier
Any of:
string
metadata
Any of:
object
key
additional properties
any

Successful Response

Media typeapplication/json
Examplegenerated
example

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}