anthropic
Output tokens cost roughly 5x input in Claude Code
Promtime
anthropicOutput tokens in Claude Code are priced at roughly five times input, because decode writes one token at a time while prefill reads the entire request in a single pass, according to a post on Anthropic's Claude blog. The post walks through what a single session bills for, request by request.
At a glance
- A request runs in two phases: prefill reads the system prompt, CLAUDE.md and everything added since, then decode writes the thinking, tool calls and text one token at a time.
- Cache reads cost 0.1x the input price and writes run up to 2x, but a write happens once per token while the discounted reads repeat on every turn that follows.
- In the post's worked example, one small test fix takes five requests, each carrying the whole conversation, with only the newly added tokens prefilled at the full input price.
Why it matters The pricing mechanics turn ordinary habits into cost decisions: a mid-conversation model switch or an over-eager test runner reads as a line item rather than a preference. On a subscription the effect shows up indirectly, as limits draining faster than the work would suggest. The guidance also moves the tuning target from prompt wording to context volume, likely the more durable lever as sessions get longer.
Cache reads cost 0.1x the input price and writes up to 2x
Prompt caching works when a request starts with exactly the same tokens as one the server has just seen: the state for that shared beginning is reused, and only what comes after it gets prefilled. Reading from the cache costs 0.1x the input price, writing into it costs up to 2x. Claude Code manages the cache on every request.
The post's example is a request to fix a failing test in utils.test.ts. It produces five requests: the initial send, a Read of the test file, a Read of the file under test, an Edit, and a run of npm test, each resending the full conversation with only the new part at full input price.
A large share of output tokens are thinking tokens, and /effort controls how much thinking happens per turn. Both /model and /effort carry over as defaults into the next session, and MAX_THINKING_TOKENS=0 turns thinking off for a single session, a step below /effort low.
Switching /model, /effort or fast mode mid-conversation re-prefills everything at full price
The cache has to match from the start of the request forward, and requests always go out in the same order: tool definitions, then the system prompt, then the conversation with CLAUDE.md at its front. Every model has its own cache, and the effort level and fast mode are part of what the cache is keyed on.
Switching any of them mid-conversation re-prefills the whole conversation, which is why /model and /effort ask for confirmation; opusplan counts too, since it changes model on every entry to and exit from plan mode. Re-prefilling after a fast mode switch happens at fast mode prices. Turning fast mode off is free.
The cache also expires: an hour on a subscription, five minutes on an API key, with ENABLE_PROMPT_CACHING_1H=1 extending that to an hour. /compact replaces the conversation and invalidates it, while /rewind trims turns off the end and leaves everything before them cached.
Command output under 30,000 characters stays in the conversation for the rest of the session
Everything added to the conversation, files read and command output alike, is resent on every later turn. Output above 30,000 characters is written to a file, leaving a short preview and the path in the conversation, adjustable through BASH_MAX_OUTPUT_LENGTH. A runner printing 400 passing tests one line each falls under that limit.
@-mentioning a file attaches it to the message before anything is sent, so it lands in the first request and costs no Read call. It occupies the same context either way and only needs mentioning once, since a later mention generally attaches a second copy. /context lists what a fresh session already holds, and /mcp turns off servers not needed in that session.
Subagents run in a separate context window with their own system prompt, the tools and CLAUDE.md, but without the main conversation, and only their answer comes back. A subagent definition can pin the model, with haiku or sonnet named in the post.
What's next The same requests draw down subscription limits even though the prices are not visible there. On 1M-context models, /autocompact 200k restores the earlier auto-compact threshold and requires Claude Code v2.1.221 or later, and the documentation includes a hook that rewrites noisy commands before they run. The post closes with four items ranked by how much they cost.
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.
