anthropic_passthrough
Count Tokens
Count tokens for Anthropic Messages API format.
This endpoint follows the Anthropic Messages API token counting specification. It accepts the same parameters as the /v1/messages endpoint but returns token counts instead of generating a response.
Example usage:
curl -X POST "http://localhost:4000/v1/messages/count_tokens?beta=true" -H "Content-Type: application/json" -H "Authorization: Bearer your-key" -d '{
"model": "claude-3-sonnet-20240229",
"messages": [{"role": "user", "content": "Hello Claude!"}]
}'
Returns: {"input_tokens": <number>}
post/v1/messages/count_tokens
Response
Successful Response
{"stackTrail":"paths:/v1/messages/count_tokens:post:responses:200:content:application/json:schema","oasType":"schema","type":"unknown"}
Changes
Changed in 1 of the 16 revisions of this API.2
- ○
api tag
anthropic_passthroughaddedapi-tag-added
- ○
api tag
[beta] Anthropic Messages Token Countingremovedapi-tag-removed
This revision also has 19 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog
- ○