anthropic

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

Claude News

anthropic

Anthropic has published a breakdown of what a Claude Code session costs on the GPU, and the ratio at the center of it is decode: output tokens are priced at roughly 5x input. The post on the Claude blog traces a single request through prefill, decode and the prompt cache that sits between them.

At a glance

  • A request splits into prefill, where the model reads the system prompt, CLAUDE.md and the accumulated conversation, and decode, which writes one token per pass and keeps the GPU busy far longer.
  • Cache reads cost 0.1x the input price and cache writes up to 2x, with the cached prefix expiring after an hour on a subscription or five minutes on an API key.
  • Switching model, effort level or fast mode mid-conversation invalidates the cache key, so the entire thread gets prefilled again at full price, which is why both switches ask for confirmation.

Why it matters None of this is billed visibly on a subscription, but the same requests draw down the limits, which likely makes session hygiene a bigger lever than model choice for most users. The economics reward short, focused sessions: turn 40 is paying to re-read the 39 before it, and a long-lived conversation appears to cost more than the same work split across several /clear boundaries.

One small fix takes five requests, each carrying the whole conversation

Anthropic walks the pricing through a single instruction: fix the failing test in utils.test.ts. The first request bundles the tool definitions, the system prompt, CLAUDE.md and the message, and nothing is cached yet, so all of it gets prefilled and written into the cache.

From there the model issues a Read for the test file, a second Read for the file under test, an Edit, and a run of npm test. Each tool result is appended and the whole conversation goes out again, with everything earlier read back from the cache at a tenth of the input price.

The summary at the end carries no tool call, so there is nothing to append and the exchange stops at five requests. The per-turn bill is the same each time: cache reads on the history, full input price on whatever is new, and the output price on the response.

Rewinding a few turns costs nothing, while /compact always costs something

Every model keeps its own cache, so a /model switch mid-conversation re-prefills the whole thread at full price. That includes opusplan, which changes models on every entry into and exit from plan mode. Fast mode is part of the key as well, and the re-prefill it triggers is billed at fast mode prices.

/compact replaces the conversation with a shorter one, so nothing in it matches anymore, though the system prompt in front of it survives. Writing the summary is cheap while the old conversation is still cached. /rewind cuts turns off the end instead, leaving everything before them cached, and costs nothing.

Each turn resets the expiry clock, and coming back after the window has passed prefills the whole conversation again. On an API key, ENABLE_PROMPT_CACHING_1H=1 stretches the five-minute window to an hour. Resuming an old session almost always re-prefills too, since the cache is usually gone and the system prompt is rebuilt at launch.

Command output under 30,000 characters stays in the conversation for the rest of the session

Everything added to a conversation gets re-sent on every later turn, cached but not free, and it occupies context the model has to think around. Above 30,000 characters Claude Code writes command output to a file and leaves a short preview and the path in the conversation, a threshold set by BASH_MAX_OUTPUT_LENGTH.

Under that limit, a test runner printing 400 passing lines becomes part of every remaining turn. An @-mention attaches a file to the message before the request goes out, so there is no Read call for it, and one mention per conversation is enough since the file stays in context.

A subagent runs in its own context window with its own system prompt, the tools and CLAUDE.md, but not the conversation, and only its answer comes back. /context shows what is loaded before anything is typed, and /mcp turns off servers that are not needed in a given session.

What's next The autocompact threshold is adjustable: /autocompact 200k restores the old safety net on a 1M-context model and requires Claude Code v2.1.221 or later. MAX_THINKING_TOKENS=0 disables thinking for a single session, a step below /effort low, except on Fable 5. The post recommends running scheduled work from a fresh session in another terminal, since a /loop fires as a full turn in the session it was created in.

Comments

No comments yet. Be the first.

Join the conversation

Sign in with Google to leave a comment. Your name and avatar come from your Google profile, and the comment appears after moderation.

We only use your name and avatar from Google. We never store your email address.