An LLM API bills you for two quantities on every request: input tokens, which is everything you send to the model, and output tokens, which is everything the model writes back. Output tokens are priced far higher per unit, about five times the input rate at the major providers as of September 2026, but input usually dominates the count because you resend the whole conversation on every turn. Knowing which side of the meter your workload sits on is the difference between a predictable bill and a surprising one.

What is a token?

Tokens are the units a model reads and writes: whole words, fragments of words, punctuation, or single characters. Anthropic's pricing FAQ gives the usual rule of thumb, "1 token is approximately 4 characters or 0.75 words in English", and its glossary puts Claude specifically at about 3.5 English characters per token.

The count depends on the tokenizer, not only on the text. Anthropic notes that Claude 4.7 and later models use a newer tokenizer that "produces approximately 30% more tokens for the same text" than Sonnet 4.6 and earlier. Same document, newer model, higher token count, and the per-token price on top of that. Never estimate from word count when money is on the line; Anthropic offers a token counting endpoint that returns the exact figure before you send the request.

What counts as an input token?

Everything in the request. Anthropic's context window documentation lists it plainly: the system prompt, every message including tool results, images and documents, and your tool definitions all count. Passing tools also injects a hidden tool use system prompt, 286 tokens on Claude Opus 5 with the default tool choice. Fetched web content counts too; Anthropic's own estimate is about 2,500 tokens for an average 10 kB web page.

The part most people miss is history. Each turn's input phase contains all previous conversation history plus the current user message. Turn twenty of a chat resends turns one through nineteen. Total input over a conversation therefore grows roughly with the square of its length, which is why a chat product's bill is mostly input even though each individual answer is longer than each question.

What counts as an output token?

Everything the model generates: the visible answer, the arguments of any tool call, and its reasoning. Anthropic states that thinking tokens are a subset of max_tokens and are billed as output tokens. On models that keep earlier thinking blocks in the conversation, those blocks then become input on later turns and are billed as input. A single request can produce up to 128k output tokens on the 1M context Claude models, so a runaway generation is a real line item, not a rounding error.

How much do input and output tokens cost in September 2026?

Prices below were checked on 7 September 2026 on the official pages linked in the last column. They change often, so treat the ratios as the durable lesson and the figures as a snapshot.

Model Input per 1M tokens Output per 1M tokens Output to input ratio Source
Claude Sonnet 5 $2 $10 5x Anthropic pricing
Claude Opus 5 $5 $25 5x Anthropic pricing
Claude Haiku 4.5 $1 $5 5x Anthropic pricing
GPT-5.6 Sol $4 $20 5x OpenAI pricing
GPT-5.5 (under 272K context) $5 $30 6x OpenAI pricing
GPT-5.4 mini $0.75 $4.50 6x OpenAI pricing
Gemini 3.1 Pro Preview (prompts up to 200k) $2 $12 6x Gemini pricing
Gemini 3.8 Flash $0.75 $3.75 5x Gemini pricing

Two footnotes matter. Google lists the Gemini 3.8 Flash rates as valid through December 31, 2026, rising to $1.50 input and $7.50 output from January 1, 2027, and charges Gemini 3.1 Pro $4 input and $18 output on prompts above 200k tokens. Anthropic goes the other way on long context: a 900k token request is billed at the same per-token rate as a 9k token request.

Which side of the meter dominates your bill?

It depends entirely on the shape of the job. Three examples at Claude Sonnet 5 rates ($2 input, $10 output per million, from the pricing page):

Document extraction. A 30,000 token contract goes in, 500 tokens of JSON come out. Input costs $0.060, output costs $0.005. Input is 92% of the bill, and the 5x output premium is irrelevant.

Content generation. A 300 token brief goes in, a 1,500 token article comes out. Input costs $0.0006, output costs $0.015. Output is 96% of the bill, and the model's verbosity is the whole story.

A 20 turn support chat. A 2,000 token system prompt, 150 token questions, 300 token answers. Because every turn resends the history, the conversation sends 128,500 input tokens in total against 6,000 output tokens: $0.257 of input versus $0.060 of output. Input is 81% of the bill, even though the model wrote twice as much as the customer.

So the first question in any cost estimate is not "which model" but "what is resent, and how often".

How do you cut the bill on each side?

On the input side, prompt caching is the big lever. Anthropic charges cache reads at 0.1 times the base input price and OpenAI lists cached input at a tenth of the standard rate on its current models. Batch processing halves both sides if you can wait: Anthropic's Batch API gives a 50% discount on input and output, and OpenAI's gives a 50% cost discount with completion within 24 hours. Trimming history also works: Anthropic's server-side compaction summarizes older turns so they stop being resent in full.

On the output side, cap max_tokens, ask for terse formats such as JSON instead of prose, and lower the reasoning effort on tasks that do not need it, since reasoning is billed as output. When we scope a system at Qubba, the cost sheet is built from these two columns before any code is written, because a workload that is 90% input needs caching, and a workload that is 90% output needs a smaller model or a shorter answer.

Frequently asked questions

Are cached tokens input or output tokens?

They are input tokens billed at a reduced rate.
Anthropic reports them separately as cache_read_input_tokens and cache_creation_input_tokens, and all three input fields still count toward the context window.
Caching changes the price of a token, not whether it occupies space in the request.

Do tool calls cost tokens?

Yes, on both sides.
Tool definitions and tool results are input, and the arguments the model writes for a tool call are output.
Anthropic also adds a tool use system prompt per request and charges $10 per 1,000 searches for its web search tool on top of the tokens the results occupy.

Is a 1M token context window billed at a higher rate?

Not at Anthropic, which bills the full 1M window at standard pricing.
Google does raise rates on Gemini 3.1 Pro above 200k tokens, and OpenAI's table marks GPT-5.5 rates as applying under 272K context.
Check the threshold before you rely on long context.

How do I count tokens before sending a request?

Use the provider's counting endpoint rather than a word count.
Anthropic documents a token counting API for estimating a request in advance, and the response usage block of every call reports the exact input and output figures you were charged for.