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.
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
Opt in to top-level automatic prompt caching: {"type":"ephemeral"} (optionally "ttl":"1h"). Places one moving breakpoint on the largest cacheable prefix. Explicit per-block cache_control on system/message/tool content takes precedence. Caching is off unless set. Cache writes cost 1.25x input and reads 0.1x
Any value
Any value
Any value
Response
Successful response
The number of input tokens the request would consume.