Example
bash
curl https://api.anthropic.com/v1/messages/count_tokens \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" \
-d '{
"messages": [
{
"content": "Hello, world",
"role": "user"
}
],
"model": "claude-opus-5",
"system": [
{
"text": "Today'\''s date is 2024-06-01.",
"type": "text"
}
],
"thinking": {
"type": "adaptive"
},
"tools": [
{
"input_schema": {
"type": "object",
"properties": {
"location": "bar",
"unit": "bar"
},
"required": [
"location"
]
},
"name": "name"
}
]
}'Response (200)
json
{
"context_management": {
"original_input_tokens": 0
},
"input_tokens": 2095
}