API ReferenceAnthropic
Count Tokens
Count tokens for Anthropic-compatible requests when supported by the group.
Use POST /v1/messages/count_tokens for Anthropic-compatible token counting.
OpenAI groups do not support this endpoint. Use it with Anthropic-compatible groups, and verify support for Gemini-compatible groups before relying on it in production.
curl https://anyroute.io/v1/messages/count_tokens \
-H "Authorization: Bearer YOUR_ANYROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-haiku-20241022",
"messages": [{"role": "user", "content": "Hello"}]
}'
AnyRoute Docs