Guide · Claude Code cost
How does prompt caching change what Claude Code costs?
Claude Code sends the whole conversation with every request, and the prompt cache bills the part it has seen before as a cheap read. A five-minute cache write costs 1.25 times fresh input, and a one-hour write costs twice. A read costs a tenth to a fortieth of fresh input, depending on the model. So one write costs as much as 12.5 to 50 reads.
What does a cache write cost against a cache read?
Anthropic's list prices, in US dollars per million tokens:
| Model | Fresh input | 5-minute write | 1-hour write | Read | 5-minute write ÷ read |
|---|---|---|---|---|---|
| Claude Fable 5.1 | $10 | $12.50 | $20 | $0.25 | 50× |
| Claude Opus 5.5 | $4 | $5 | $8 | $0.20 | 25× |
| Claude Sonnet 5.5 | $2 | $2.50 | $4 | $0.10 | 25× |
| Claude Haiku 5.5 | $0.10 | $0.125 | $0.20 | $0.01 | 12.5× |
The Haiku 5.5 row is for prompts up to 100,000 tokens. Above that every Haiku rate is five times higher, and the ratios stay the same.
A one-hour write costs 20 to 80 reads. Anthropic says caching pays for itself after one read on the five-minute lifetime, and after two reads on the hour.
A cache miss is the expensive turn: on Opus 5.5 one write costs as much as 25 reads.
What does Claude Code put in the prompt cache?
The API caches by matching the start of each request, the prefix, against what it processed recently. The match is exact, so a change anywhere in the prefix reprocesses everything after it. Claude Code orders each request so the parts that change least come first:
| Layer | What it holds | Changes when |
|---|---|---|
| System prompt | Core instructions and tool definitions | The set of loaded tools changes |
| Project context | CLAUDE.md, auto memory, unscoped rules | A session starts, or after /clear or /compact |
| Conversation | Messages, answers and tool results | Every turn |
Each model has its own cache. Caches are never shared between organizations. On the Claude API they are also kept apart per workspace.
What makes Claude Code miss the cache?
Claude Code's documentation lists these:
- Switching models, including each plan-mode toggle on the
opusplansetting. - Changing effort on most models. Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 keep the cache on an API key or a Claude subscription.
- Turning on fast mode, once per conversation.
- Changing the tool set mid-session, such as connecting an MCP server or denying a whole tool, when tool search is off. With tool search on, the default on supported models, the tool list stays fixed and the cache survives.
- Compacting, which replaces the conversation layer by design.
- Many images, when Claude Code drops a batch of the oldest.
- Upgrading Claude Code, on the first conversation after the upgrade.
- A break longer than the cache lifetime. The first message back reprocesses the whole context.
Editing files, editing CLAUDE.md mid-session, changing permission mode or output style,
running a skill and /rewind all keep the cache.
Which cache lifetime does Claude Code ask for?
It depends on how you pay:
| Requests | Claude subscription, within plan usage | API key, usage credits or a cloud provider |
|---|---|---|
| Main conversation | One hour | Five minutes |
| Subagents, workflows, compaction and other side requests | Five minutes, except a few helpers Anthropic sets to an hour | Five minutes |
To choose yourself, set promptCacheTtl to 1h or 5m,
or the CLAUDE_CODE_PROMPT_CACHE_TTL variable. Subagents have
subagentPromptCacheTtl. Both need Claude Code 2.1.242 or later.
The hour costs more per write and saves the rewrite after a pause. It pays when a session idles past five minutes and comes back within the hour.
ANTHROPIC_BASE_URL,
the cache works as at Anthropic only if the gateway forwards Claude Code's
cache_control markers unchanged. The hour also needs its
anthropic-beta header. A gateway that removes the markers and still answers
bills the whole history as fresh input on every turn. Claude Code also turns tool search off
behind a custom base URL, so an MCP change rewrites the cache unless
ENABLE_TOOL_SEARCH=true is set. Selan's launcher sets it by default.
How do you check your cache hit rate?
Run /usage. From Claude Code 2.1.251 its Session block has a
Prompt cache (main) line: the share of input served from cache, the misses,
and whether the cache is warm now. It covers the main conversation only.
A statusline script can read cache_creation_input_tokens and
cache_read_input_tokens on every turn. A high read-to-creation ratio means the
cache is working. Creation that stays high turn after turn means something keeps changing
the prefix.
How does Selan keep a team's cache warm?
Selan connects the Claude seats and API keys your company already pays for, and decides the cache lifetime per request:
- A person's conversation in Claude Code or Claude Desktop gets the hour from its first request, on a seat or a key.
- Subagents, workflows and side calls get five minutes.
- Automation, such as the Agent SDK, gets five minutes, and the hour only after a pause of five to sixty minutes.
Selan sets that lifetime only on markers that name none. A lifetime Claude Code chose
itself is left as it is. Selan's default Claude Code settings also set
promptCacheTtl to 1h, and a developer's own setting wins.
A cache is shared only inside one organization, so Selan sends a conversation back to the seat or key that holds its cache: within ten minutes, or within the hour once it holds a one-hour entry. It never keeps a conversation on a pay-per-use key to save a cache while a seat could serve it.
Insights, which an owner turns on, shows context reuse per repository: cache reads against reads plus rewrites. Healthy is 75% or better, Watch is 50 to 74%, and Poor is below that. It is described on the insights page. What a session costs and what to cut is in the practices docs, and each developer's own spend is on the statusline.
Free for up to three seats, and the Free plan needs no card.
The short version
- A five-minute cache write costs 1.25 times fresh input and an hour costs twice; a read costs a tenth to a fortieth.
- One write costs 12.5 reads on Haiku 5.5, 25 on Opus 5.5 and Sonnet 5.5, and 50 on Fable 5.1.
- Switching models, changing tools, compacting and a pause past the lifetime make Claude Code rewrite the cache.
- Claude Code asks for the hour only on a subscription within plan usage, unless you set
promptCacheTtl. - Selan gives a person's conversation the hour, keeps it on the seat that holds its cache, and shows reuse per repository.
Prices and cache rules are as Anthropic's pricing and prompt-caching documentation (platform.claude.com) and Claude Code's prompt-caching documentation (code.claude.com/docs/en/prompt-caching) stated them on 22 October 2026. They change: check the date before quoting a figure. What Selan does is as its control and proxy code did on that date.