You type nine words, press enter, and a paragraph comes back. Between those two events, the system assembles a document you did not write: your conversation history, a system prompt, tool definitions, memory, attachments, and the residue of everything the model has already said in this session. Then it bills you for reading all of it.
This is not a metaphor. It is the documented behaviour of the major APIs, and understanding it explains three complaints that otherwise look like bugs: why long chats get worse, why the same question costs different amounts on different days, and why the model “forgot” a rule you gave it an hour ago.
Stage one: your text is not your text
Models do not read characters. They read tokens, and the tokeniser is the first place meaning gets approximated. Google’s developer documentation puts the ratio at about four characters per token, with 100 tokens equal to roughly 60 to 80 English words. FACT (Google, Understand and count tokens)
That ratio is the reason every cost estimate you do in your head is wrong in a specific direction. A page of dense technical prose, full of identifiers and symbols, tokenises worse than a page of plain English, because unusual strings get broken into fragments. INFERENCE Non-English text and code are the two categories where the four-characters rule of thumb misleads most.
The practical consequence: counting words is a proxy, and a loose one. If a number matters, count tokens with the provider’s own counter before you send, which is what the token-counting endpoints exist for. FACT
Stage two: the system prompt you never see
Every request carries instructions that were not in your message. Anthropic’s documentation is explicit that everything in the request counts toward the context window: the system prompt, every message in the conversation, tool results, images and documents, and the tool definitions themselves. FACT (Anthropic, Context windows)
So the window is not a container for your question. It is a container for the vendor’s scaffolding plus your question plus the model’s own output, and your question is usually the smallest of the three.
This is also why two products built on the same model behave differently at the same price. The one with more tools, longer instructions and an agent loop spends more of the window before the user says anything. INFERENCE
Stage three: tools are paid for before they are used
A tool definition is a schema: a name, a description, and a parameter list that the model must be able to read. It sits in the prompt whether or not the model calls it.
Anthropic notes in the same document that tool definitions count toward the window, and points to tool-context management and deferred tool loading as mitigations. FACT Google’s documentation says the same for its side: tools such as functions, code execution and search are counted, and the usage object reports tool-use tokens separately. FACT
The practical version: an agent wired to twenty tools pays for twenty schemas on every turn, and the cost is invisible because nothing in the interface says “tools loaded”. INFERENCE A team debugging “why is this expensive” should count tool definitions before counting messages.
Stage four: an image is 258 tokens, and a video is not
Attachments have prices that feel arbitrary until you see the mechanics.
Google publishes the conversions: an image up to 384 pixels on both sides counts as 258 tokens; a larger image is tiled into 768-pixel squares, each costing 258 tokens; audio runs at 32 tokens per second; static video at roughly 100 tokens per second. FACT
Do the arithmetic on a ten-minute video at 100 tokens per second: 60,000 tokens before the model has answered. A one-hour recording is 360,000 tokens, which is a third of a million-token window spent on a single attachment. INFERENCE
There is a second ceiling that arrives before the token ceiling. Anthropic’s documentation states that a single request can include up to 600 images or PDF pages, and 100 on models with a 200,000-token window, and that request-size limits can be reached before the token limit. FACT
So “my 300-page PDF got truncated” is usually not a context-window failure. It is a request-size or page-count limit, hit before the token budget was exhausted. INFERENCE
Stage five: the answer is part of the input for the next turn
The output phase is where the loop closes: the response becomes part of the input for the next turn. Anthropic describes the pattern directly — each turn’s input contains all previous conversation history plus the new message, and the output joins that history. FACT
That is why cost grows faster than usage. Eight short exchanges do not cost eight times one exchange, because exchange eight re-reads exchanges one through seven. INFERENCE
Two mitigations exist and they are not equivalent. Caching changes what you pay for re-reading the prefix, not whether the prefix occupies the window: Anthropic states that cached prompt prefixes still occupy the context window. FACT Compaction actually reduces what is in the window by summarising earlier turns on the server, and it is documented as available in beta on Claude 4.6 and later models. FACT
The distinction matters for budgeting. Caching is a discount. Compaction is a capacity change. INFERENCE
Stage six: why long inputs get worse, not just pricier
Here is the finding that reframes the whole pipeline. Anthropic’s documentation states that as token count grows, accuracy and recall degrade, a phenomenon it calls context rot, and that “more context isn’t automatically better”. FACT
That single sentence explains the most common complaint about assistants. People assume a larger window is a bigger desk. In practice it is a bigger desk with more paper on it, and the paper you need is not always on top.
The mechanism matters for how you fix it. If the problem were memory, adding capacity would help. If the problem is retrieval within a long context, the fix is editing what goes in: fewer documents, better structure, and removing the irrelevant. INFERENCE
Where the request actually fails
Two failure modes are worth knowing because they look identical to a user and are handled differently by the API.
If the input alone exceeds the window, the request is rejected outright with an invalid_request_error on every model. FACT That is a hard wall and it happens before generation.
If input plus the requested maximum output exceeds the window, current Claude models accept the request and, if generation reaches the limit, stop with stop_reason: "model_context_window_exceeded". FACT That is a truncated answer, not a rejection, and it is the one people misread as the model “giving up”.
Gemini’s behaviour is documented similarly but with a shared budget: Gemini 4 models share a single 1,048,576-token window across input, thinking and output, and the API caps the output limit to whatever remains after input. FACT
The lesson is the same in both: the output you asked for competes with the input you sent. A long prompt does not just cost more; it can shorten the answer. INFERENCE
A worked example: one contract, three ways
Take a 20-page contract, about 10,000 words, and a reader who needs five answers from it. Using the published ratio of 60 to 80 English words per 100 tokens, the document is roughly 12,500 to 17,000 tokens before any instructions are added. INFERENCE (arithmetic from the Google ratio; the tokeniser output for a specific file is UNKNOWN until counted)
Way one: attach the file and ask five questions in one thread. The first request carries the document. Each following turn re-reads the document plus everything said so far, because history accumulates. The fifth request alone is the document plus four exchanges. A rough total for the thread is five document-reads plus the conversation, so somewhere between 65,000 and 90,000 input tokens. INFERENCE
Way two: extract once, then ask about the extract. One pass converts the contract into a 1,500-word summary with clause references. The five questions now cost 1,500 words each, roughly 2,000 to 2,500 tokens per turn. The total lands near 15,000 to 25,000 tokens. INFERENCE The trade is obvious and usually worth taking: you have replaced re-reading with a summary you can check once.
Way three: retrieve per question. If the tool can search the document rather than load it, each question pulls the relevant clauses only. That is cheapest per question and most expensive to build, and it is the only one of the three that scales to a folder of contracts rather than a single file. INFERENCE
None of these numbers is a vendor quote, and that is the point of showing the arithmetic: the ordering is stable even if the exact counts are not, and the ordering is what the decision depends on.
The budget you should actually keep
Most teams track one number, spend, and discover the composition only when something breaks. A more useful ledger has five lines, because these are the things that consume the window:
| Line | What moves it | What to do about it |
|---|---|---|
| System instructions | Product design, not user behaviour | Nothing as a user; know it exists |
| Tool schemas | Number of connected tools | Disconnect tools you are not using |
| Attachments | Pages, seconds, tiles | Send the section, not the document |
| History | Turn count, not word count | Start a new thread per task |
| Output and reasoning | Max tokens, thinking budget | Ask for shorter answers when scanning |
Two habits follow. The first is to start a new conversation for a new task, because the cheapest token is the one you never send. The second is to measure before optimising: every major provider reports usage per request, and Google’s usage object breaks it down into input, output, thinking, cached and tool-use tokens. FACT A team that reads those fields once will stop guessing about where the money goes.
None of this makes the model worse. It makes the model legible. The window is working memory, the prompt is a document you did not write, and the bill is for reading it — which is a fair description of what is happening and a much better basis for decisions than the interface’s one-line chat box suggests.
If you want the commercial side of the same mechanism, why the $20 plan stops being cheap follows the caps rather than the prices, and the productivity tool review turns the same arithmetic into a renewal decision. For a worked example of context management inside a coding agent, the Claude Code review shows what compaction keeps and what it discards.
Sources
All URLs fetched 26 October 2026.
- https://platform.claude.com/docs/en/build-with-claude/context-windows — everything counts toward the window (system prompt, messages, tool results, images, documents, tool definitions, output and thinking), up to 1M tokens with 128k max output, “context rot” and degrading recall, 600 images/PDF pages per request (100 on 200k models), request-size limits arriving first, cached prefixes still occupying the window, compaction in beta on 4.6+, overflow behaviour (
invalid_request_errorversusmodel_context_window_exceeded), token-counting API. - https://ai.google.dev/gemini-api/docs/tokens — token ratio of ~4 characters and 60–80 words per 100 tokens, image tokenisation (258 tokens at 384 px, 258 per 768 px tile), audio at 32 tokens/s, static video at ~100 tokens/s, system instructions and tools counted as input, usage fields for input/output/thinking/cached/tool-use tokens, Gemini 4’s shared 1,048,576-token window with output capped to the remainder.
- https://ai.google.dev/gemini-api/docs/pricing — free-tier Flash pricing at zero cost with content used for product improvement, paid-tier exclusion from that use, Gemini 4 Argon unavailable on the free tier, and the 50% Batch discount that applies to the same token accounting.
Independent technology writer focused on artificial intelligence, emerging technologies, and digital innovation. Covers AI applications in sports, productivity, and online business.

















































