Every request to a chat or agent API resends the instructions, tool definitions and reference documents that came before it, and you pay to process them again. Prompt caching lets the provider reuse the work it already did on an unchanged beginning of the prompt and bill that part at a lower rate. For an application with a long, stable prefix it is usually the largest single cost lever on the input side. It is also easy to get silently wrong, because the API does not error when a cache misses; it just charges full price.
The three major APIs implement it differently. This guide compares what each vendor's own documentation says as of 27 November 2026, works out when caching saves money, and lists the reasons a cache hit fails to appear. It builds on our explainer on tokens, context windows and AI cost.
What a prompt cache actually stores
All three vendors describe the same idea: a cache entry is tied to a prefix of the prompt, and a later request can use it only if its own prefix is identical. Anthropic says cache keys are generated from a cryptographic hash of the prompt up to the cache control point, so "only requests with identical prompts can access a specific cache".[1] OpenAI says "cache reuse requires the entire rendered prefix to match".[2]
Two consequences follow. First, order matters: put stable content (tools, system instructions, reference documents) first and variable content (the user's message, a timestamp) last. Second, caching saves input processing only. Output tokens are billed as usual, and the vendors do not claim that caching changes the answer.
How the three APIs compare
The table summarises each documentation page as read on 27 November 2026. Limits and multipliers change, so check the linked pages before you budget.
| Spec | Claude API | OpenAI API | Gemini API |
|---|---|---|---|
| How you turn it on | Add cache_control, either once at the top level or on individual blocks[1] | On by default for supported models[2] | Implicit caching on by default for Gemini 2.5 and newer; explicit caches are created by you on supported models[3][4] |
| Minimum prompt length | 512 tokens for the Fable 5.2, Opus 5.5, Sonnet 5.5 and Haiku 5.5 families, up to 4,096 for some older models[1] | 1,024 tokens for GPT-5.6 and later; varies by settings for earlier models[2] | 4,096 for Gemini 4 and 3.x tiers listed; 2,048 for Gemini 2.5 Flash and Pro (implicit)[3] |
| Lifetime | 5 minutes by default, refreshed on each use; 1 hour optional[1] | GPT-5.6 and later: 30 minutes (default) or 12 hours minimum; earlier models: in-memory, about 5 to 10 minutes of inactivity, or extended up to 24 hours[2] | Explicit cache: 1 hour if no TTL is set; the page gives no implicit lifetime[4] |
| Write price | 1.25x base input (5 minutes), 2x (1 hour)[1] | GPT-5.6 and later: 1.25x (30 minutes), 2.5x (12 hours)[2] | Explicit: cached tokens billed at a reduced rate plus storage by TTL duration; rates are on the pricing page[4] |
| Read price | 0.1x for most models; 0.05x for Opus 5.5 and Sonnet 5.5; 0.025x for Fable 5.2, Mythos 5.2, Fable 5.1 and Mythos 5.1[1] | Up to 95% discount per the page; on GPT-5.6 and later 0.1x, or 0.05x on some models[2] | The page says savings are passed on automatically and gives no percentage[3] |
| Where you see hits | cache_read_input_tokens, cache_creation_input_tokens[1] | usage.input_tokens_details.cached_tokens, cache_write_tokens[2] | usage.total_cached_tokens, and usage_metadata on cache operations[3][4] |
Three details in that table are easy to miss.
- Claude's cache is the most explicit. Up to four breakpoints, each writing one entry that is a hash of the prefix ending at that block, and a lookback of at most 20 positions per breakpoint.[1] A growing conversation can push a breakpoint more than 20 blocks past the last write, which is the documented reason to add a second one.[1]
- OpenAI's write premium is documented only for GPT-5.6 and later. The page lists the 1.25x and 2.5x write prices for those models. We did not find a write price for earlier models on that page, so do not assume writes are free or charged there without checking your invoice.[2]
- Gemini 4 cannot use explicit caches. Google's page says explicit caching "is not supported" for Gemini 4 models, which rely on implicit caching.[4] On Gemini 4 the multi-turn threshold is also higher: the full previous request is cached only if the new request adds at least 2,050 tokens.[3]
When caching pays off: the break-even arithmetic
The following is our arithmetic from the published multipliers, not a vendor benchmark. Let the cacheable prefix be P tokens, priced at the base input rate, and let n be the number of requests that send that prefix within the cache lifetime. Without caching you pay n times P. With caching you pay one write and n minus 1 reads.
| Setup | Cost of the prefix over n requests | Break-even |
|---|---|---|
| Claude, 5-minute write, 0.1x read | 1.25P + 0.1P x (n-1) | n = 2 |
| Claude, 1-hour write, 0.1x read | 2P + 0.1P x (n-1) | n = 3 |
| Claude, 5-minute write, 0.05x read | 1.25P + 0.05P x (n-1) | n = 2 |
| OpenAI GPT-5.6+, 12-hour write, 0.1x read | 2.5P + 0.1P x (n-1) | n = 3 |
Worked example: a 20,000-token prefix reused ten times inside the 5-minute window on a 0.1x model. Uncached, that is 10 x 20,000 = 200,000 input-token equivalents. Cached it is 1.25 x 20,000 + 9 x 0.1 x 20,000 = 25,000 + 18,000 = 43,000, about 21.5% of the uncached cost, so a saving of roughly 78%. That applies only to the prefix; the new tokens in each request, and all output tokens, are billed normally.
The practical reading: the premium on a write is small relative to the discount on a read, so the question is rarely "is the multiplier worth it" but "will the same prefix actually be sent again before the entry expires". A support bot with a 3,000-token system prompt and steady traffic will usually hit. A batch of unrelated documents each with its own prefix will not.
Why you do not get a cache hit
Most disappointing cache results come from one of a small number of causes. The vendor pages document these.
- The prompt is below the minimum. Anthropic states that shorter prompts cannot be cached even if marked, and are processed without caching and without an error.[1]
- Something early in the prefix changed. On Claude the order is tools, then system, then messages, and "changes at each level invalidate that level and all subsequent levels". Modifying tool definitions invalidates the entire cache.[1] Changes to the model, tools or settings such as
reasoning.effortcan break an OpenAI match.[2] - Volatile content sits before stable content. A timestamp, request ID or per-user greeting near the top makes every prefix unique. Anthropic's advice is to place the breakpoint on the last block that is identical across the requests that should share a cache, and keep varying blocks after it.[1]
- The entry expired. With a 5-minute default, a quiet period ends the entry. Lifetime on Claude is measured from the start of the request that writes or reads the entry, not from the end of its response.[1]
- Routing. OpenAI notes that cache reuse depends on routing to the right machine, that
prompt_cache_keyinfluences routing without guaranteeing a hit, and that traffic above 15 requests per minute can lead to overflow routing.[2] - Batch processing. Anthropic says cache hits in the Message Batches API are best-effort because requests can be processed concurrently and in any order. Its suggested pattern is to write the shared prefix to the 1-hour cache with one request first, then submit the rest.[1]
A related point for cost modelling: OpenAI states that cached input tokens still count toward tokens-per-minute limits, so caching reduces your bill but not necessarily your rate-limit pressure.[2]
A minimal Claude example
The Claude docs describe a top-level cache_control field that moves the breakpoint forward automatically as a conversation grows.[1] The sketch below shows the shape of a request body for a long reference document; the model name is a placeholder you must replace with one from the current models page.
{
"model": "<model-id>",
"max_tokens": 1024,
"cache_control": { "type": "ephemeral" },
"system": "You answer questions about the attached policy document.",
"messages": [
{ "role": "user", "content": "<long policy text> ... Question: what is the refund window?" }
]
}Run it twice inside five minutes with the same long text and inspect the usage object. On the second call cache_read_input_tokens should be non-zero. The docs give the identity total_input_tokens = cache_read_input_tokens + cache_creation_input_tokens + input_tokens, which is the figure to reconcile against your bill.[1] We have not run this request ourselves; it follows the documented field names only.
Privacy and isolation
Anthropic states that prompt caching is eligible for zero data retention, that cached entries are held in memory rather than at rest, and that entries are isolated between organisations and, on some platforms, between workspaces.[1] OpenAI notes that organisations without Zero Data Retention default to the 24h retention setting, while those with it default to in_memory.[2] If you handle regulated data, read the vendor's retention page rather than rely on this summary.
Which to choose
There is rarely a choice between vendors on caching alone; the model you need decides the API. Within an API, the decision guide is short.
- Stable long prefix, steady traffic: use the default lifetime and one breakpoint at the end of the stable content.
- Bursty traffic with gaps of more than five minutes: a longer lifetime costs more to write (2x on Claude, 2.5x for the 12-hour OpenAI option) but needs three or more reuses to break even on our arithmetic.
- Gemini 4: rely on implicit caching and structure prompts so stable content comes first; there is no explicit cache to manage.
- Anywhere: log the cached-token counts, alert when they fall to zero, and re-check after you change a tool definition or move to a new model. Model changes alter minimum lengths and multipliers, as the Claude Fable 5.2 migration notes and our guide to model routing and cascades show.
What we could not verify
We read the OpenAI and Gemini pages through a fetch tool that summarises them rather than as raw text, and the Anthropic page's first 100,000 characters plus its FAQ and privacy sections through the same tool. We did not run any API call, did not open the vendors' separate pricing pages, and did not confirm what Gemini implicit caching bills in absolute terms because the caching page gives no rate. All prices and thresholds above are the vendors' own statements on the retrieval date and may have changed.




