Why output tokens in Claude Code cost about 5x what input does

On August 14, Anthropic published a breakdown of what a Claude Code session actually spends tokens on. It covers which requests get billed at which multiple of the input price, and which ordinary commands quietly force the whole conversation to be processed again. The post on the Claude blog starts at the GPU, where every request runs in two phases priced differently.
The first phase is prefill. The model reads everything it is given: the system prompt, CLAUDE.md, your message, and everything added to the conversation since, including the files Claude has read and the output of the commands it ran. That is input. The second phase is decode, where the model writes output one token at a time, so a 200-token response means 200 runs of the model, one after another. Per token, decode keeps the GPU busy much longer, and that is why output costs roughly 5x what input does.
Thinking tokens make up a large share of that output, and the effort level controls how much thinking happens per turn. Whatever you pick with /effort carries over as the default into your next session, and the same goes for /model. Anthropic suggests running both once in a fresh session to check what you are actually using. For a session you already know will be grunt work, MAX_THINKING_TOKENS=0 claude turns thinking off entirely for that session, one step below /effort low. It does not apply on Fable 5.
Five requests for one failing test
The pricing that matters most in a session is the cache’s. If a request starts with exactly the same tokens as one the server just processed, the server can reuse the stored state for that shared prefix and only prefill what comes after it. Reading from the cache costs 0.1x the input price, since the state is loaded instead of computed. Writing into the cache costs more than plain input, up to 2x, because the server also has to keep the state around. Each token is written once, and the 0.1x reads happen on every turn after that. Claude Code manages caching on every request, and there is nothing to switch on.
Anthropic walks through the prompt “fix the failing test in utils.test.ts”. The first request carries the system prompt with tool definitions, CLAUDE.md and the message. The cache is empty, so all of it is prefilled and written. The model answers with a Read call for the test file. Claude Code appends the file and sends everything again: request one comes back from the cache at a tenth of the price, and only the Read call and the file are prefilled at full price. Then comes a second Read for the file under test, an Edit, and an npm test run. Each one adds its result to the end of the conversation and resends the whole thing. When the tests pass, the model writes a short summary with no tool call, so there is no sixth request.
That makes five requests for one small fix, and each carried the entire conversation up to that point. Anthropic describes a typical turn as lopsided, with tens of thousands of tokens going in and a few hundred coming out. The per-turn bill has three parts: cache reads on the history, full input price on whatever is new, and output price on the response. This holds on a subscription too. Subscribers never see the prices, but the same requests are what use up their limits.
With the history this cheap to re-read, shrinking it does less than it looks like it should. In a July test, context compression cut 39% of input tokens and saved almost nothing, because roughly 98% of the baseline’s input tokens were already being served from cache.
What throws the cache away
The cache matches from the very start of the request, and requests always go out in the same order: tool definitions, then the system prompt, then the conversation, with CLAUDE.md at its front. A tool result added at the end is the ideal case, since nothing comes after it. A change further forward means everything behind it is prefilled again, and so does a change to what the cache is keyed on. The post lists the triggers:
/model: each model has its own cache, so on the next turn the entire conversation is prefilled again at full price. That includes opusplan, which switches models every time you enter or leave plan mode./effort: the effort level is part of the cache key, so the result is the same. That is why both commands ask for confirmation when you switch mid-conversation.- Fast mode: also part of the key, and the re-prefill is billed at fast mode prices. Turning it off again costs nothing in cache terms.
/compact: the conversation is replaced with a shorter one, so none of it matches anymore. The system prompt in front of it survives.- Time: every turn resets the clock, but the cache expires after an hour on a subscription and after five minutes on an API key.
Anthropic’s prompt caching documentation now makes an exception on effort. On Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1, used with an API key or a Claude subscription, the cache stays intact by default when effort changes. On most other models each effort level still has its own cache.
On an API key, ENABLE_PROMPT_CACHING_1H=1 raises the cache lifetime to an hour. The variable shipped in Claude Code v2.1.108 together with FORCE_PROMPT_CACHING_5M, which pins the five-minute lifetime, and the defaults stayed as they were. Without it, a coffee break longer than five minutes on an API key means the next turn prefills the whole conversation. Resuming an old session nearly always misses as well: the cache is usually gone by then, and the system prompt is rebuilt at launch either way.
The cheap moments to switch model or effort are the start of a session and right after /clear. The expensive moment is the middle of a long conversation. With /compact, timing matters too: writing the summary is cheap while the old conversation is still cached, so compacting costs far less before a long break than after one. When the last few turns went somewhere you do not want to keep, Anthropic recommends /rewind to just before them. Rewinding only trims the end, so everything earlier stays cached and the operation costs nothing. Compacting rewrites the whole conversation, so it always costs something.
Nothing gets sent once
Everything that enters the conversation, whether a file Claude read or the output of a command it ran, is resent on every turn for the rest of the session. Each resend is a cheap cache read. It still costs something, and it takes up context the model has to work around on every turn. Anthropic sums up the cost model of a session in three variables: how many tokens end up in the context, how many turns they stay there, and how many contexts you run at once.
Part of the context is loaded before you type anything: tool definitions, the system prompt, CLAUDE.md and whatever else loads at startup. /context in a fresh session shows that baseline. Anthropic’s advice is to keep CLAUDE.md to specific instructions and move workflow-specific ones into skills, which load only when used. MCP servers a session does not need can be turned off with /mcp. The CLAUDE.md file in particular tends to grow over time: a preprint in August found such files gain a net 4.9 instructions per commit.
Most of what gets added during a session is tool results, and how much Claude reads depends on how much it has to work out for itself. “The tests are failing” sends it searching: a grep or two, then a few files opened to find the relevant one. All of those results stay in context long after they stop being useful. Naming utils.test.ts skips the search and costs one Read call. Writing @utils.test.ts saves that call as well, because Claude Code attaches the file to the message before anything is sent. The file takes up the same room in context either way, so one mention per conversation is enough. Mentioning it again on a later turn generally attaches a second copy.
Command output builds up the same way. Large output is handled for you: past 30,000 characters, Claude Code writes the output to a file and puts only a short preview and the path into the conversation. The threshold can be changed with BASH_MAX_OUTPUT_LENGTH. The trouble is everything below that limit. A test runner that prints 400 passing tests one line at a time stays under the threshold, and those 400 lines become part of every remaining turn. Claude often trims output itself with flags and tail, and the docs include a small hook that rewrites noisy commands before they run so only the relevant lines come back.
Anthropic also recommends putting the two or three commands you run all day into CLAUDE.md, quiet flags included, the way you would type them yourself. Its example is “run a single test file with npx vitest run <file> --reporter=dot”, which saves a turn and a few hundred lines of output in every later session.
How long context stays
One long session costs more than the same work split into several short ones, and the post says the gap is bigger than you would expect, because turn 40 also re-reads the 39 turns before it. The rule that follows is to keep one task’s context out of the next: /clear when you start something new, and /compact once the earlier part of the same task is done. Run /rename before /clear if you might want the session back. When compacting, tell it what to keep, or add a “Compact instructions” section to CLAUDE.md if the answer is always the same. On a 1M model, /autocompact 200k moves the auto-compact safety net back to where it used to be. That requires Claude Code v2.1.221 or later.
Some turns happen while you are not typing. A /loop fires as a full turn in the session where it was set up and carries that whole conversation with it every time. If more than an hour has passed since the last turn, each firing is also a cache miss. Anthropic’s fix is to start a fresh session in another terminal and run the loop from there.
Subagents keep work out of your context by running it in a separate one. A subagent gets its own context window with its own system prompt, the tools and your CLAUDE.md, but not your conversation. It runs its own turns, only its answer returns to the main session, and everything else is discarded when it finishes. The cost is that it sometimes re-reads material the main session already had, and it pays for its own turns while doing so. For a small job that is pure overhead, according to Anthropic. A subagent pays off on jobs that produce a lot of output you do not need to keep, such as going through a log. Claude often picks one on its own for that, and you can also ask directly (“go through this log in a subagent”). The main session gets back only what the subagent chose to report.
If you hand off the same noisy job again and again, give it its own subagent definition with model: haiku (or sonnet). Otherwise it runs on whatever model your main session is using.
Up next
Anthropic publishes its second Risk Report
Anthropic published its second Risk Report, laying out the risks its systems pose and how ready the company is to address them. The reports are a recurring part of its Responsible Scaling Policy, and the new one is live on Anthropic’s site.
Related stories
- The same tokens cost up to 40x more on the API than on a subscription
- Claude Code Ultra week measured at 17B Opus cache reads
- “Verify twice” wastes tokens on Opus 5, Anthropic says
- By the end of a long session, strict solutions drop to 0.5%
- Spotify’s shunt blocks Claude Code reads over 350 lines
- Claude hands paid users a spare limit reset until Oct 22
Comments
No comments yet. Be the first.
Join the conversation
Sign in to leave a comment. It appears after moderation.

