Count tokens
Anthropic's token count for a Messages request is not served yet. The route exists so that a client gets a clear answer: 404 not_found_error with the code route_not_available, in the Messages route's error shape. Every Messages answer carries the exact counts in its usage, and Claude Code estimates its context itself when the count is not served.
POST
/v1/messages/count_tokensnot servedAnswers 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": "POST /v1/messages/count_tokens is not served yet; 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
- 17 of 19
- Detail
- E
- Updated
- 2026-11-11