Skip to main content
Measure the token cost of a request before sending it. Available on the Anthropic surface.

Endpoint

Accepts the same body as /v1/messages (minus max_tokens). Returns:

Example

curl

Notes

  • The count reflects your payload only — internal system instructions we add for tool routing are excluded. What you see is what you’d be billed for.
  • Tools, system prompts, and image blocks are all included in the count.
  • If the upstream count path is unavailable, the API falls back to a local estimator. Counts should still be within a few tokens of the real figure.
Last modified on May 3, 2026