Overview

A token is the unit of text a language model reads and generates: a word, word piece, punctuation mark, or byte sequence. Context limits, rate limits, and prices are all counted in tokens, not characters or words.

Claude averages roughly 3.5 English characters per token. Code, numbers, and non-English text use more. Tokenizers differ by model: Claude 4.7 and later models use a newer tokenizer that produces about 30 percent more tokens for the same text than earlier Claude models, so recount against the model you will call. Count with the provider’s tool: Claude’s /v1/messages/count_tokens endpoint is free and returns an estimate, and OpenAI’s tiktoken does not match Claude.

Input and output tokens are priced separately, and output costs more: Sonnet 5.5 is 10 per million output. Thinking tokens bill as output tokens and count toward max_tokens. Budget prompts and responses in tokens, and trim large tool results and images, which consume many.