Prompt caching explained: how it works and how much it saves
ExplainerBy Lucas Matías García TorresUpdated (first published )Data checked 6 min read
Reviewed by Lucas Matías García Torres on . How we work.

Short answer
Prompt caching reuses the processing of an identical prompt prefix, so repeated instructions, documents and tool definitions are read from cache at about 0.1 times the input price on OpenAI, Anthropic and Google (0.05 times on GPT-6.1 Sol, Claude Opus 5.5 and Claude Sonnet 5.5) instead of full price. OpenAI, Google and DeepSeek enable it by default; Anthropic needs cache_control. Only an exact prefix hits, minimum lengths run from 512 to 4,096 tokens, and a long document reread on every request can cost about 80% less.
Prices and limits change often: check the vendor's page before you pay. How we make money.
Prompt caching lets an LLM API reuse the work it already did on the start of your prompt, so repeated instructions, documents or tool definitions are processed once and then billed at a fraction of the normal input price. Every major provider now offers it: OpenAI, Google and DeepSeek turn it on by default, and Anthropic needs a cache_control setting, which can be added in one line. This guide explains how prompt caching works, compares the rules and prices of the four providers as documented on October 6, 2026 (Anthropic's re-checked on October 26, 2026), and shows how to structure a prompt to get cache hits.
What is prompt caching?
When a model reads your prompt, it builds intermediate results called key-value (KV) states, which let it refer back to earlier tokens while it reads the rest and writes the answer. OpenAI explains that prompt caching saves that state for a reusable prefix, "the unchanged tokens at the beginning of a prompt", and that the cache "stores key-value tensors, not the tokens themselves". When a later request starts with the same prefix and finds a matching entry, the model skips that work and processes only the new part.
Two consequences follow from how it works:
- Only the beginning of the prompt can be cached. The prefix must match exactly: Anthropic says cache hits require "100% identical prompt segments", and OpenAI says reuse requires the entire rendered prefix to match. Anything that changes early in the prompt, such as a timestamp or a reordered tool definition, makes everything after it miss.
- Caching changes the price and the speed, not the answer. The model sees the same prompt. What you save is the cost of re-reading it. For the unit behind these prices, see what a token is.
How do the four providers compare?
Table: prompt caching rules by provider (October 6, 2026)
| Item | OpenAI (GPT-5.6 and later) | Anthropic (Claude) | Google (Gemini) | DeepSeek |
|---|---|---|---|---|
| How to turn it on | On by default; optional explicit breakpoints | Add cache_control: automatic mode, or explicit breakpoints (up to 4) |
Implicit caching on by default for Gemini 2.5 and newer; explicit caching through the generateContent API |
On by default (disk cache) |
| Minimum cacheable prompt | 1,024 tokens | 512 tokens on Haiku 5.5, Sonnet 5.5, Opus 5.5 and Fable 5.1; 4,096 on Haiku 4.5 | 4,096 tokens on the Gemini 3 models listed; 2,048 on 2.5 | Not stated on its page |
| How long it lasts | At least 30 minutes after the last write or reuse | 5 minutes, refreshed each time it is used; 1 hour at extra cost | Not stated on its caching page | Not stated on its page |
| Price to read from cache | 0.1x the input price (0.05x on GPT-6.1 Sol) | 0.1x (0.05x on Opus 5.5 and Sonnet 5.5; 0.025x on Fable 5.1) | About 0.1x on the models in its price table | $0.006 against $0.30 per million tokens on V4.1 Flash at peak rates |
| Price to write | 1.25x the input price | 1.25x (5 minutes) or 2x (1 hour) | A storage price per million tokens per hour is listed in its price table | No separate charge listed |
Read the table with these caveats: older OpenAI models use different retention settings (in_memory or 24h) and different minimums, and the rates for each model are on each vendor's pricing page, summarized in LLM API pricing compared. Anthropic and OpenAI both say caches are isolated between organizations, and Anthropic adds that they are isolated per workspace on its API.
How much can caching save?
OpenAI's own arithmetic shows the shape of it. At a 0.1x read rate and a 1.25x write, writing a prefix once and reusing it fully once costs 1.35 times its ordinary input cost, against 2 times for processing it twice without caching. Across ten requests, one write and nine full reads cost 2.15 times, against 10 times without caching.
Our cost model gives concrete monthly figures. These are our calculations from the providers' published prices; they include cache reads but not cache writes or storage, and they apply no tokenizer adjustment.
Table: monthly cost with and without caching (our calculation)
| Workload | Share of input read from cache | GPT-6.1 Sol | Claude Sonnet 5.5 |
|---|---|---|---|
| 20,000 requests, 3,000 input and 600 output tokens each | 0% | $240.00 | $240.00 |
| The same | 40% | $194.40 | $194.40 |
| The same | 80% | $148.80 | $148.80 |
| 10,000 requests, 50,000 input and 500 output tokens each | 0% | $1,050.00 | $1,050.00 |
| The same | 90% | $195.00 | $195.00 |
The first workload saves less (38% at 80% cached) because output tokens, which caching does not touch, are half of its bill. The second, a long document reread on every request, is where caching matters most: the bill falls by about 81%. The two columns match because both models read from cache at 0.05x the input price; on a model that reads at 0.1x, such as Claude Haiku 4.5, the same share saves less. Run your own numbers in the LLM API cost calculator.
How to structure a prompt to get cache hits
Because only an identical prefix is reused, the layout of the prompt decides your hit rate:
- Put stable content first. System instructions, tool definitions, examples and reference documents go at the start. The question, the user's name, the date and anything that changes per request go last.
- Do not change the early part. Reordering tools, editing a tool description, toggling a feature or adding a timestamp at the top invalidates everything after it. Anthropic's cache follows the order tools, then system, then messages, and a change at one level invalidates that level and every later one.
- Place the breakpoint at the end of the static prefix. With Anthropic's explicit mode, put
cache_controlon the last block that is identical across the requests that should share a cache, not on the block that varies. - Keep requests close together. Caches expire: 5 minutes at Anthropic by default (refreshed on each use), at least 30 minutes at OpenAI on current models. Sending similar requests within that window keeps the entry alive.
- Mind the minimum length. A prompt shorter than the minimum is processed without caching and no error is returned. If yours falls just short, Anthropic notes that expanding the cached content to reach the threshold is often worthwhile.
- Measure it. Anthropic reports
cache_creation_input_tokensandcache_read_input_tokens, OpenAI reportscached_tokensandcache_write_tokensin its usage details, and Google reports cached tokens in its response. If the cached count is zero, the prefix did not match or was too short.
What about privacy?
Caching stores model state, so read the retention terms. OpenAI says prompt caching may store encrypted key-value tensors in GPU-local storage, that caches are not shared across organizations and that, to prevent users from probing whether a prompt was cached, you can use separate cache keys per customer. Anthropic documents isolation between organizations and workspaces and points to its data retention page for how zero data retention applies to this feature. If you handle personal data, check the provider's terms for how long cached state is kept; our guide to the Regulation (EU) 2024/1689 covers other rules that may apply when you deploy language models in the EU.
When is caching not worth it?
When your prompts are short (below the minimum), when every request is different at the start, or when requests are too far apart for the entry to survive. Caching also does nothing for output tokens, which usually cost several times more than input. For an agent that loops, the opposite holds: each step repeats the same long prefix, which is why agents benefit so much, and why their costs are worth modeling before you build, as in our agents for business example.
What we checked
- OpenAI: prompt caching is enabled by default for supported models; reused tokens are billed at the cached-input rate, discounted up to 95%; the cache stores key-value tensors, not tokens; reuse requires the entire rendered prefix to match; for GPT-5.6 and later the minimum cacheable prompt is 1,024 tokens, cache writes cost 1.25x the input rate and reads 0.1x (0.05x on GPT-6.1 Sol), the default lifetime is at least 30 minutes after the latest write or reuse, explicit breakpoints allow up to four cache writes per request; writing once and reading nine times costs 2.15x against 10x without caching; caches are not shared across organizations; separate prompt cache keys help prevent cache-hit probing; prompt caching may store encrypted key/value tensors in GPU-local storage; older models use prompt_cache_retention with in_memory (about 5 to 10 minutes of inactivity, up to one hour) or 24h. (OpenAI, )
- Anthropic: two ways to enable caching (automatic caching with one top-level cache_control field, or explicit breakpoints on content blocks, up to 4); default lifetime 5 minutes refreshed at no cost on use, 1 hour at extra cost; the cache follows the hierarchy tools, system, messages and a change at one level invalidates that level and all later ones; hits require 100% identical prompt segments; minimum cacheable length 512 tokens for Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 5.5 and 4,096 for Haiku 4.5; prompts below the minimum are processed without caching and without an error; 5-minute writes 1.25x, 1-hour writes 2x, reads 0.1x (0.05x for Opus 5.5 and Sonnet 5.5 and 0.025x for Fable 5.1) of the base input price; caches are isolated between organizations and per workspace on the Claude API; usage reports cache_creation_input_tokens and cache_read_input_tokens. (Anthropic, )
- Google: implicit caching is enabled by default for Gemini 2.5 and newer models, with savings passed on automatically; the minimum input is 4,096 tokens for the Gemini 3.x models listed and 2,048 for Gemini 2.5; putting large common content at the beginning and sending similar requests close together raises the chance of a hit; cached tokens are reported in the response usage. (Google (Gemini API docs), )
- Gemini API pricing lists a context caching price of $0.075 per million tokens against $0.75 for input on Gemini 3.8 Flash (through December 31, 2026) and $0.20 against $2.00 on Gemini 3.1 Pro (prompts up to 200K tokens), with a storage price per million tokens per hour. (Google (Gemini API docs), )
- DeepSeek: context caching on disk is enabled by default for all users; a cache hit requires a full match with a persisted cache prefix unit; cache-hit input costs $0.006 against $0.30 for cache-miss input on V4.1 Flash at peak rates. (DeepSeek, )
- DeepSeek peak-rate prices per million tokens: V4.1 Flash $0.30 input, $0.006 cache hit, $1.20 output. (DeepSeek, )
- OpenAI standard prices per million tokens: GPT-6.1 Sol $2 input, $0.10 cached input, $10 output; our monthly examples are calculations from these prices and Anthropic's, without cache writes, storage or tokenizer adjustment. (OpenAI, )
- Claude Sonnet 5.5 costs $2 per million input tokens, $0.10 for cache reads and $10 for output. (Anthropic, )
What may change
- Cache lifetimes, minimum lengths and prices change with new models; OpenAI already documents different rules for GPT-5.6 and later than for earlier models. This page is reviewed quarterly.
- Google and DeepSeek do not state cache lifetimes on their pages; this page will say so until they do.
- Our monthly cost examples exclude cache writes and storage, so they slightly flatter heavy caching.
Frequently asked questions
What is prompt caching?
It is a feature of LLM APIs that reuses the work already done on the beginning of a prompt. When a new request starts with exactly the same prefix, the provider skips that work and bills the reused tokens at a lower cached rate. It saves money and time but does not change the answer.
How much does prompt caching save?
Reads from cache cost about 0.1 times the normal input price on OpenAI and Anthropic (0.05 times on GPT-6.1 Sol, Claude Opus 5.5 and Claude Sonnet 5.5, 0.025 times on Claude Fable 5.1), and OpenAI says the discount is up to 95%. Writes to the cache cost 1.25 times on both. In our calculation, a 50,000-token document reread 10,000 times a month falls from $1,050 to $195 on both GPT-6.1 Sol and Claude Sonnet 5.5 with 90% of the input cached.
Is prompt caching automatic?
On OpenAI, Google and DeepSeek it is on by default for supported models. On Anthropic you add a cache_control field, either once at the top level for automatic caching or on individual blocks for explicit breakpoints, and you can place up to four breakpoints.
How long does a cached prompt last?
On current OpenAI models a cached prefix stays eligible for at least 30 minutes after its last write or reuse. On Anthropic the default is 5 minutes, refreshed at no cost each time the cache is used, with a 1-hour option at extra cost. Google and DeepSeek do not state a lifetime on their caching pages.
Why am I not getting cache hits?
The usual causes are a prefix that is not identical (a timestamp, a reordered or edited tool definition, a changed setting), a prompt shorter than the minimum cacheable length, or requests spaced too far apart for the entry to survive. Check the cached-token count in the usage data of each response.
Is prompt caching safe for private data?
Caches are isolated between organizations at OpenAI and Anthropic, and Anthropic also isolates them per workspace. OpenAI says caching may store encrypted key-value tensors in GPU-local storage and suggests separate cache keys per customer to prevent cache-hit probing. Check each provider's retention terms for sensitive data.
Sources
- Prompt caching (OpenAI API guide), OpenAI. Accessed October 6, 2026.
- Prompt caching (Claude API): pricing, minimum lengths, lifetime and invalidation, Anthropic. Accessed October 26, 2026.
- Context caching (Gemini API), Google (Gemini API docs). Accessed October 6, 2026.
- Gemini Developer API pricing, Google (Gemini API docs). Accessed October 6, 2026.
- Context caching on disk (DeepSeek API), DeepSeek. Accessed October 6, 2026.
- DeepSeek API: models and pricing (peak and off-peak), DeepSeek. Accessed October 6, 2026.
- OpenAI API pricing (Standard and Batch, per 1M tokens), OpenAI. Accessed October 6, 2026.
- Claude API pricing: models (cache reads at 0.025x, 0.05x or 0.1x; Haiku 5.5 with its 100K-token tier) and Batch API, Anthropic. Accessed October 26, 2026.
Spotted an error or an outdated price? Tell us and we will fix it.
Change history
- : Re-checked Anthropic's prompt caching and pricing pages: Claude Sonnet 5.5 now reads from cache at 0.05x the input price ($0.10), so its column in the monthly table now matches GPT-6.1 Sol, and Claude Haiku 5.5 joins the 512-token minimum. Fixed a typo in two mentions of OpenAI models. OpenAI, Google and DeepSeek rules unchanged since October 6.
- : Wording revised; no figure, date or source changed.
- : First published from the four providers' caching documentation and pricing pages.
Next review: .
Part of our LLM APIs & Costs guide.
Keep reading
- LLM API pricing compared, with a cost calculator
API prices for OpenAI, Anthropic, Google and DeepSeek models per million tokens, plus a calculator with caching, batch discounts and tokenizer differences.
- What is a token in a language model?
What a token is in a language model, how many words it equals, why Spanish and French need more tokens than English (we measured it) and how they are billed.
- What is a context window in a language model?
What a context window is, how big it is for Claude, GPT and Gemini in 2026, what happens when it fills up, why bigger is not always better and what it costs.
- Agents for business: use cases, costs and risks
Which business tasks suit an agent, whether you need one, three ways to get one, what model calls cost in a worked example, the main risks and EU rules.
- Claude pricing: what each plan costs and what you get
Claude pricing in October 2026: what Free, Pro, Max, Team and Enterprise cost, what each plan includes, how usage limits work and when the API is cheaper.
Other topics

Assistants & Chatbots
16 guides

Agents & Automation
8 guides

Local Models & Hardware
11 guides

Language Models Explained
14 guides