Prompt caching explained: cost and latency
Prompt caching reuses the processed start of a repeated prompt, so it bills at a tenth or less of the input price. How Claude, OpenAI and Gemini differ.
Prompt caching reuses the processed start of a repeated prompt, so it bills at a tenth or less of the input price. How Claude, OpenAI and Gemini differ.
State the task and success criteria, give context and reasons, show examples, enforce the format with a schema and test every change. Prompting for 2026 models.
Make the model a setting, not a dependency: a thin interface, evals per task and a tested fallback. Route across models only where cost or residency pays.
A recurring report. A slow review. A prototype that needs to work in the real world.
Prompt caching lets a model provider reuse the work it already did on the opening of a prompt you send repeatedly (the instructions, tool definitions and reference documents at the start of a request), so those tokens bill at a tenth or less of the normal input price and the first word arrives sooner. It isn't response caching: the model still writes a fresh answer every time.
For any application with a long system prompt, a fixed set of tools, a reference document or a growing conversation, it's usually the biggest cost cut you can make without changing a single output. The catch is that it's fussy: put the static content first, put anything that changes last, and on Claude switch it on explicitly.
Key takeaways
When a model reads a prompt, it computes intermediate values for every token (the "key-value cache") before it writes anything. That reading step accounts for a big chunk of both the bill and the wait before the first word appears. Prompt caching holds onto those values for the opening prefix of your prompt, so the next request starting with the same tokens loads them instead of recomputing them from scratch.
The match is exact and runs from the very first token. Change a single character near the start and everything after it is a miss.
It depends on how much of each request is a repeated prefix and how often that prefix gets reused before it expires. Take a support assistant running on Claude Sonnet 5.5 at November 2026 list prices ($2 per million input tokens, $2.50 per million for a 5-minute cache write and $0.10 per million for a cache read; see Anthropic's pricing):
| Tokens | Rate per 1M | Cost per day | |
|---|---|---|---|
| Without caching: every token at full price | 10,200 × 5,000 = 51.0M | $2.00 | $102.00 |
| With caching: cache writes (5% of requests) | 10,000 × 250 = 2.5M | $2.50 | $6.25 |
| With caching: cache reads (95% of requests) | 10,000 × 4,750 = 47.5M | $0.10 | $4.75 |
| With caching: questions, never cached | 200 × 5,000 = 1.0M | $2.00 | $2.00 |
| With caching: total | $13.00, about 87% less |
Input tokens only; output costs the same with or without caching. Prices are list prices checked on 11 November 2026.
Two things make the arithmetic work: the prefix is almost the whole request (10,000 of 10,200 tokens), and it's read many times for every write. If your prefix is a small slice of the request, or traffic is sparse enough that most requests arrive after the cache has expired, the saving shrinks, and the write premium can actually make caching cost slightly more.
The break-even is low. On Claude, a 5-minute cache write costs 1.25 times the normal input price and a read costs a tenth or less, so a prefix used twice already beats sending it twice uncached (1.25 + 0.1 = 1.35 against 2). The 1-hour option writes at twice the input price, so it needs at least three uses to pay off.
Caching also cuts latency because the provider skips reading the cached tokens. How much depends on the model and prefix length, so measure time to first token before and after rather than trusting a quoted figure.
The principle is the same everywhere. The switches, minimums, lifetimes and prices differ by provider and by model, and they shift between model generations.
| Anthropic Claude | OpenAI | Google Gemini | |
|---|---|---|---|
| How it's turned on | Opt-in. A top-level cache_control places the breakpoint for you, or mark up to four blocks yourself | On by default for supported models; GPT-5.6 and later also accept explicit breakpoints | Implicit caching on by default for Gemini 2.5 and newer; explicit caches on supported 2.5 and 3 models |
| Minimum prefix | 512 tokens on current models; 1,024 to 4,096 on some older ones | 1,024 tokens on GPT-5.6 and later; varies with request settings on earlier models | 2,048 tokens on Gemini 2.5; 4,096 on Gemini 3.x and 4 |
| Lifetime | 5 minutes, refreshed on each hit; or 1 hour with ttl: "1h" | GPT-5.6 and later: 30 minutes, or 12 hours on request. Earlier models: in-memory or 24-hour retention | Managed by Google for implicit caching; you set it for explicit caches |
| Writing to the cache | 1.25× input price (5 minutes) or 2× (1 hour) | GPT-5.6 and later: 1.25× (30 minutes) or 2.5× (12 hours) | See Google's pricing page |
| Reading from the cache | 0.1× input price on most models; 0.05× on Opus 5.5 and Sonnet 5.5; 0.025× on Fable 5.1 and 5.2 | 0.1× on GPT-5.6 and later (0.05× on some newer models) | Discounted automatically on a hit; see Google's pricing page |
| Where to see hits | cache_read_input_tokens and cache_creation_input_tokens in usage | usage.input_tokens_details.cached_tokens | usage.total_cached_tokens in the SDKs |
Checked against each provider's documentation on 11 November 2026. Providers change these, so check the linked docs before you rely on a figure.
Two consequences follow. On Claude, nothing is cached until you ask, so an app ported from another provider can quietly pay full price for months. On OpenAI and Gemini, caching is free to try, but anything under the minimum length never hits, and because the minimum differs by model, a routine model upgrade can change your hit rate without a single line of code changing.
Arrange every request from most stable to least stable. The cache covers everything up to the last breakpoint, so a static block sitting after a changing one is never reused.
On Claude, the simplest version is a single top-level setting:
const response = await client.messages.create({ model: "claude-sonnet-5-5", max_tokens: 2000, // Caches everything up to the last cacheable block. Opt-in on Claude. cache_control: { type: "ephemeral" }, system: POLICY_PROMPT, // stable: the same bytes on every request messages: [ { role: "user", content: question }, // changes every time: goes last ],}); // Prove it: on warm requests, reads should dominate.console.log(response.usage.cache_read_input_tokens);console.log(response.usage.cache_creation_input_tokens);Use explicit breakpoints on individual blocks when parts of the prefix change at different rates, say tools and instructions that change monthly, and a document that changes daily. Each segment is then cached separately.
Agent loops are where caching matters most. Every step re-sends the whole conversation so far: instructions, tool definitions, every earlier tool call and its result. Without caching, a ten-step task pays for the opening instructions ten times over. With the conversation cached and new content appended only at the end, each step pays full price only for what it added. Our guide to agentic retrieval shows how quickly loop costs climb.
Batch processing stacks with caching. Anthropic and OpenAI both charge about half the normal price for requests sent through their batch APIs, which return results within 24 hours. Because batch requests run concurrently and in no fixed order, cache hits are best effort: Anthropic's documentation reports hit rates from 30% to 98% depending on traffic, and recommends the 1-hour lifetime for batches that share context.
The two are complementary, and plenty of production systems use both.
| Prompt caching | Response caching | |
|---|---|---|
| Where it runs | The provider's infrastructure | Your application |
| What's stored | The processed prompt prefix | The finished answer |
| When it helps | Same prefix, different questions | The same question asked again, expecting the same answer |
| Saving | Most of the cost of the cached input tokens | The whole call |
| Risk | Little: the answer is generated fresh | Stale or wrong answers if the underlying data changes |
Production checklist
Start by logging the usage fields on every request so you have a real hit rate before you touch anything. Then reorder prompts so the stable parts come first, push dates and IDs to the end, sort anything serialised, and turn on caching where it's opt-in. On a typical assistant or agent that's a day's work, and the usage fields will tell you within hours whether it took.
After that, pick lifetimes from real traffic gaps, keep each conversation on one model, and add a cache-hit alert to your monitoring so a later prompt edit can't quietly break it. If you're weighing caching against other levers such as model choice, effort settings and batch processing, read how LLM cost, context and latency work and multi-model AI without provider lock-in.
Cost and latency checks are part of every system we build; we leave behind the usage logging and cache monitoring that show where the token bill actually goes. How we engineer AI costs →