Count Message tokens
Anthropic
Count Tokens
Anthropic Messages token-counting compatible endpoint. Returns the number of input tokens a Messages request would consume, without creating a message. Mirrors Anthropic’s POST /v1/messages/count_tokens (same request body as the Messages endpoint, minus the required max_tokens). Supported for Claude models; other models return 400.
POST
Count Message tokens
Authorizations
API key authentication. Pass your API key as a Bearer token.
Headers
Function name for tracing and project-level guardrail function-scope filtering.
Parent span ID for distributed tracing context.
Body
application/json
Response
Successful response
The number of input tokens the request would consume.