QUICK ANSWER
Claude Token Counter
The reliable way to count Claude input tokens is Anthropic’s official Message Token Count API. Send the same model, system prompt, messages, tools, images, or document content that you plan to use in the real request. The endpoint returns the estimated input-token total without generating a Claude response.
Why the model and full message matter
Claude tokenization can differ between model generations. Counting only the visible user text can also miss the system prompt, earlier conversation turns, tool definitions, images, and documents included in the request. For a useful result, count the complete message structure against the Claude model you will actually call.
What the official counter returns
Anthropic’s token-counting endpoint returns an input_tokens value. Anthropic describes this count as an estimate: the input-token usage reported by the eventual message request can differ slightly. The endpoint does not create a response, so it cannot tell you the final number of output tokens.
What content it can count
The endpoint accepts structured message input and supports system prompts, client tools, images, and PDFs. Anthropic’s current documentation notes exceptions for some server tools and remote file sources; for supported PDF counting, the document is supplied as base64 content.
Where to count and plan cost
Use Anthropic’s official token-counting documentation when you need the request estimate for Claude. After you have a token total, use the Token Cost Kit calculator to plan token-based API cost. For OpenAI text, use the separate OpenAI Token Counter.