If you run a coding agent or a chatbot on an API, most of what you pay for is input you've already sent. Every turn resends the same system prompt, tool definitions and project docs. Prompt caching is how you stop paying full price for that.
The idea in one paragraph
The provider keeps the processed version of the start of your prompt for a few minutes. If the next request begins with exactly the same content, it reuses that work and bills you a fraction of the normal input price. Only the new part at the end is billed in full.
What it costs on Claude
From Anthropic's pricing and caching docs:
| Multiplier on base input price | |
|---|---|
| Cache write, 5-minute lifetime | 1.25× |
| Cache write, 1-hour lifetime | 2× |
| Cache read (hit) | 0.1× |
| Cache read on Opus 5.5 and Sonnet 5.5 | 0.05× |
In dollars per million input tokens:
| Model | Base input | Cache hit |
|---|---|---|
| Opus 5.5 | $4 | $0.20 |
| Sonnet 5.5 | $2 | $0.10 |
So on Sonnet 5.5, a 50,000-token system prompt plus project context costs $0.10 to send uncached and $0.005 on a cache hit. Over a 40-turn agent session, that difference adds up fast. Batch processing stacks a further 50% discount on top.
Other providers
Every major API now discounts cached input, but the details differ:
| Provider / model | Cached input |
|---|---|
| Gemini 4 Argon | 95% off input during the intro period (to Nov 30, 2026) |
| MiniMax M3.1 Flash | $0.015 per M (vs $0.15 input) |
| GPT-6 Astra | Cache reads and writes are priced separately from input |
| Mercury 3 | Cached input 90% off |
See our full API pricing comparison for base prices, and the Gemini 4 Argon pricing breakdown for what changes after Nov 30.
The one rule: stable stuff first
Caches match an exact prefix. On Claude, the prefix is built in this order:
- Tools (tool definitions)
- System (system prompt)
- Messages (the conversation)
If anything changes early in that order, everything after it is a miss. The classic mistake:
System: You are a helpful assistant. Today is 2026-10-22 14:03:11. User: Sam.
That timestamp changes every request, so nothing after it is ever cached. Move changing details to the end, in the latest user message.
A cache-friendly layout:
[tools: same every call]
[system: instructions + style guide + project docs] ← cache breakpoint here
[conversation history] ← optional second breakpoint
[new user message: includes today's date, user name]
How to turn it on (Claude)
Add a cache_control marker to the last block of the part you want cached. A Python sketch:
from anthropic import Anthropic
client = Anthropic()
response = client.messages.create(
model="YOUR_MODEL_ID",
max_tokens=1024,
system=[
{
"type": "text",
"text": LONG_PROJECT_INSTRUCTIONS, # thousands of tokens that don't change
"cache_control": {"type": "ephemeral"}, # 5-minute cache
}
],
messages=[{"role": "user", "content": "Add a test for formatPrice()."}],
)
print(response.usage)
Things to know:
- You can set up to 4 breakpoints.
- On the Claude 5.x models, the cached prefix must be at least 512 tokens. Shorter prefixes simply aren't cached.
- For a 1-hour cache, use
{"type": "ephemeral", "ttl": "1h"}. It's worth it only if you return to the same prefix often over a longer window, because the write costs 2× instead of 1.25×.
Check that it's working
Look at the usage object in the response:
cache_creation_input_tokens> 0 → you wrote to the cache (paid the write premium).cache_read_input_tokens> 0 → you hit the cache (paid the discount).
If you only ever see creation and never reads, something in your prefix changes between calls. Diff two consecutive requests.
One more cost trap: tokenizers
Anthropic notes that the tokenizer on Claude 4.7 and later models produces roughly 30% more tokens for the same text than earlier models. If your bill jumped after a model upgrade, that's part of it, and caching is the cleanest way to win it back. Our context windows explainer covers how tokens add up in agent sessions.
Where you're already using it
Coding agents like Claude Code and Codex use caching behind the scenes, which is why long sessions cost less than you'd expect. Writing a good CLAUDE.md or AGENTS.md that stays the same between sessions helps the cache too.



