Prompt Caching Explained: Cut AI API Costs in 2026
The Short Answer
Prompt caching stores the expensive part of your prompt so you stop paying to reprocess it. On Anthropic’s API a cache read costs 0.1x the base input price. On DeepSeek’s V4 models it’s roughly 97% off.
The catch nobody reads: writing the cache costs more than a normal input token. Caching is a bet that you’ll reuse the prefix before it expires. Win the bet and you cut input costs by 90%. Lose it and you paid a 25-100% premium for nothing.
How It Works
Every request re-sends your entire context — system prompt, tool definitions, documents, conversation history. The model reprocesses all of it, every time. If 95% of that is identical across calls, you’re paying repeatedly for identical work.
Caching stores the processed form of a prefix and lets later requests reference it. Three things follow from that, and they explain nearly every caching mistake:
- It’s a prefix, not a set. Matching starts at the beginning of the prompt and stops at the first difference.
- It’s exact. One changed character invalidates everything after it.
- It expires. Typically 5 minutes or 1 hour, refreshed on each hit.
The Pricing Structure
Anthropic’s multipliers, relative to base input price:
| Operation | Multiplier | Lifetime |
|---|---|---|
| 5-minute cache write | 1.25x | 5 minutes |
| 1-hour cache write | 2x | 1 hour |
| Cache read (hit) | 0.1x | Refreshes the window |
In absolute terms, for Claude Sonnet 5 at $2/MTok base input: writes cost $2.50 (5m) or $4 (1h), reads cost $0.20. For Claude Opus 5 at $5: writes $6.25 or $10, reads $0.50.
Other providers, August 2026:
| Provider / model | Base input | Cache hit | Effective discount |
|---|---|---|---|
| Claude Sonnet 5 | $2 | $0.20 | 90% |
| Claude Opus 5 | $5 | $0.50 | 90% |
| DeepSeek V4-Pro (off-peak) | $0.66 | $0.022 | ~97% |
| DeepSeek V4-Flash (off-peak) | $0.22 | $0.007 | ~97% |
| GLM-5.3 | $1.40 | $0.26 | ~81% |
| Grok 4.6 | $2 | $0.50 | 75% |
| Muse Spark 1.2 | $1.25 | $0.15 | 88% |
The Break-Even Math
5-minute cache: write costs 1.25x, read costs 0.1x. Versus 2x uncached calls at 1.0x each:
- Cached: 1.25 + 0.1 = 1.35x
- Uncached: 1.0 + 1.0 = 2.0x
Profitable after one read.
1-hour cache: write costs 2x.
- Two calls cached: 2 + 0.1 = 2.1x vs 2.0x uncached — still losing
- Three calls cached: 2 + 0.2 = 2.2x vs 3.0x uncached — now winning
Profitable after two reads. The rule: use 5-minute caching by default; reach for 1-hour only when you’re confident of three or more hits, such as a long agent session or a support conversation.
At ten calls against a cached prefix, the 5-minute cache costs 1.25 + 0.9 = 2.15x versus 10x uncached — a 78% reduction on the prefix.
What This Doesn’t Cover
Output tokens are never cached. If your workload is short prompts and long generations, caching barely moves your bill. Check the split before investing engineering time: caching pays for long-prefix, short-output workloads — RAG over a fixed corpus, agents with large tool definitions, chat over a long system prompt, document Q&A.
It does not pay for one-shot classification with tiny prompts, or creative generation where output dominates.
The Five Mistakes
1. Volatile content at the top. A timestamp, request ID, randomised few-shot order, or user name near the start of the prompt invalidates the cache every single request. You pay write rates forever and never see a hit. Everything that changes goes last, after the cached block.
2. Caching things that aren’t reused. Unique per-request documents in the cached region means paying 1.25-2x for a cache that’s never read. Cache the shared prefix only.
3. Ignoring the minimum. Providers set a minimum cacheable length. Anthropic lowered the minimum to 512 tokens for Opus 5. Below the threshold, caching is silently ignored — you pay full price and see no error.
4. Not measuring hit rate. API responses report cache read and write token counts. If hits aren’t 10x your writes on a steady workload, something upstream is invalidating the prefix. This is the single most useful metric in the whole exercise.
5. Assuming the discount is stable. DeepSeek’s cache-hit price rose up to 12x on August 16, 2026 — from $0.003625 to $0.044 on V4-Pro at peak — even though the percentage discount barely changed, because the base moved. An architecture whose economics depend on one vendor’s unusually generous cache treatment is renting its advantage. See the August 2026 price divergence.
How To Implement It
- Restructure the prompt: stable → volatile. System instructions, tool definitions and reference documents first. User input, timestamps and session data last. Do this before touching any cache API.
- Cache the largest stable block you have. Usually tool definitions plus reference corpus, often 80%+ of input volume.
- Start with automatic caching if offered. Anthropic’s automatic mode takes a single top-level
cache_controlfield and manages breakpoints as conversations grow. Move to explicit breakpoints only when you need finer control. - Default to the 5-minute window. Upgrade to 1-hour only where you can show three or more hits.
- Log
cache_read_input_tokensandcache_creation_input_tokenson every call, and alert when the ratio drops. - Stack the discounts. Caching multipliers combine with batch discounts and off-peak scheduling. Together they routinely beat switching to a cheaper, weaker model — without the quality loss.
Last verified: August 17, 2026. Rates from official vendor pricing pages.