Count tokens
Anthropic's token count route for a Messages request. Every Messages answer carries the exact counts in its usage, so this route answers 404 not_found_error with the code route_not_available, in the Messages route's error shape, and Claude Code estimates its context itself.
POST
/v1/messages/count_tokensservedAnswers 404 route_not_available in Anthropic's shape: each answer's usage carries the exact counts.
Answer
{ "type": "error", "error": { "type": "not_found_error", "message": "<a sentence naming the route; each answer's usage carries the exact counts>", "code": "route_not_available" }, "request_id": "req_..."}Any other method on the path is 404 method_not_allowed with Allow: POST.
Related sheets
- Sheet
- 19 of 21
- Detail
- E
- Updated
- 2026-11-18