
Prompt Caching Explained: How to Cut LLM API Input Costs
Prompt caching lets LLM APIs reuse a repeated prefix at up to 95% off. Learn how Claude, OpenAI, Gemini and Qwen handle it and how to structure prompts.
Prompt caching is the closest thing to free money in LLM engineering. If your application sends the same instructions, tool definitions or reference documents with every request, the provider can remember the work it already did on that repeated prefix and bill you a small fraction of the normal input price the next time it shows up. This guide explains how prompt caching works, how the major APIs differ, and how to structure prompts so the discount actually lands.
- The idea: the API reuses a prompt prefix it has already processed, so repeated input tokens are billed at a steep discount
- The size of the discount: cached input costs 0.1x the base input price or less on current Claude models, and OpenAI advertises discounts of up to 95%
- The catch: the cached part must be an exact, unchanged prefix, and it must be long enough to qualify
- The habit to build: stable content first, changing content last
Quick Picks: Prompt Caching in 60 Seconds
- Chat apps and agents on Claude: turn on automatic caching with a single cache_control field at the top level of the request
- OpenAI apps: caching is on by default, so your main job is to keep the start of the prompt stable
- Gemini apps: implicit caching is on by default for Gemini 2.5 and newer, with a 4,096-token minimum on Gemini 4 models
- Long gaps between requests: pay for a longer cache lifetime, such as the 1-hour option on Claude or the 12-hour option on newer OpenAI models
- Everyone: read the cached-token fields in the usage object to confirm you are getting hits
What Is Prompt Caching?
Every time a model reads your prompt, it processes the tokens from the first one forward. When two requests begin with the same long block of text, that early work is identical. Prompt caching stores the result of processing a prefix so a later request with the same prefix can resume from there instead of starting over.
OpenAI's documentation sums up the benefits as three things: less wasted compute, cheaper input tokens, and less time spent processing input before the response starts. Caching does not change what the model says. It changes what you pay and how long you wait.
The word to remember is prefix. Caches match from the very beginning of the prompt. Change a single character near the top and everything after it stops matching.
How Much Does Prompt Caching Save?
The savings depend on the provider and the model, so here are the published numbers.
Anthropic (Claude). Cache reads are billed at 0.1 times the base input price as the standard multiplier. Some current models go lower: reads cost 0.05 times the base price on Claude Opus 5.5 and Claude Sonnet 5.5. Writing to the cache costs slightly more than normal input, at 1.25 times the base price for the default 5-minute lifetime and 2 times for the 1-hour lifetime.
OpenAI. Reused tokens are billed at each model's reduced cached-input rate, which OpenAI describes as discounted up to 95%. Rates vary by model, so check the pricing page for the one you use.
Google (Gemini). With implicit caching, Google says it automatically passes on the cost savings whenever a request hits the cache.
Alibaba (Qwen). The QwenCloud page for Qwen4-Max lists input at $1.50 per million tokens and implicit cache hits at $0.075 per million, which works out to 95% off.
A Worked Example
Say your agent on Claude Sonnet 5.5 carries a 10,000-token block of instructions and tool definitions, and a user session makes 50 requests. Sonnet 5.5 input costs $2 per million tokens, a 5-minute cache write costs $2.50 per million, and cache hits cost $0.10 per million.
- Without caching: 50 requests times 10,000 tokens is 500,000 tokens, or $1.00
- With caching: one write of 10,000 tokens costs $0.025, and 49 reads of 10,000 tokens cost about $0.049, for a total near $0.074
That is roughly a 93% cut on the repeated portion of the prompt. The new part of each request, such as the user's latest message, is still billed at the normal rate.
When Does Caching Pay for Itself?
Because a cache write can cost more than ordinary input, the first request is slightly more expensive. Using Anthropic's multipliers, the math is friendly:
- 5-minute cache: one write plus one read costs 1.35 times the base price, against 2 times for sending the prefix twice uncached. It pays off on the second request
- 1-hour cache: one write plus two reads costs 2.2 times the base price, against 3 times uncached. It pays off on the third request
If a prefix will only ever be sent once, caching it is not worth it. If it will be sent again within the cache lifetime, it almost always is.
How Do You Structure a Prompt for Cache Hits?
This is where most of the savings are won or lost. The rules are the same on every platform.
- Put stable content first. System instructions, tool definitions, examples and reference documents go at the top. Google's guidance is to put large and common contents at the beginning of the prompt.
- Put changing content last. The user's question, timestamps, and per-request context belong at the end. Anthropic's documentation says to place the cache boundary at the end of the static prefix, not on the block that varies.
- Do not edit the top. On Claude, the cache follows a fixed order of tools, then system, then messages. Changing tool definitions invalidates the entire cache.
- Meet the minimum length. Short prompts cannot be cached. The minimum is 512 tokens on current Claude models, and 4,096 tokens for implicit caching on Gemini 4 models (2,048 on Gemini 2.5).
- Keep requests close together. A cache entry expires. Google suggests sending requests with a similar prefix within a short amount of time.
A common mistake is putting today's date or a user ID in the first line of the system prompt. That one line makes every request unique from the first token, and nothing after it can match.
How Do Claude, OpenAI and Gemini Differ?
The concept is shared, but the controls are not.
Claude gives you the most explicit control. You can add one cache_control field at the top level and let the system move the cache point forward as a conversation grows, or you can mark up to 4 cache breakpoints yourself. Multiple breakpoints help when parts of the prompt change at different speeds, for example tools that rarely change and context that updates daily. The default lifetime is 5 minutes and is refreshed at no extra cost each time the cached content is used.
OpenAI caches by default. There is nothing to switch on for supported models. On GPT-5.6 and later, the Responses API accepts a prompt_cache_options setting with a 30-minute default lifetime and a 12-hour option for instructions or reference material reused across longer gaps. On earlier models, a stable prompt_cache_key helps route related requests to the same cache.
Gemini leans on implicit caching. It is enabled by default for Gemini 2.5 and newer models. Google's documentation notes that explicit caching, where you create and manage cache objects yourself, is not supported for Gemini 4 models. For agent loops on Gemini 4, the full previous request is cached only if the new request adds at least 2,050 tokens.
How Can You Tell If Caching Is Working?
Do not assume. Every provider reports cached tokens in the response, and checking takes one line of logging.
- Claude: look at cache_creation_input_tokens and cache_read_input_tokens in the usage block. If both are zero, the prompt was not cached, most likely because it was too short
- OpenAI: look at cached_tokens inside the input token details. OpenAI also offers a Prompt Caching Dashboard for monitoring hit rates
- Gemini: look at total_cached_tokens in the usage object
Log these fields for a day and compute a hit rate. If it is low, compare two consecutive prompts side by side and find the first place they differ. That is your cache breaker.
Is Cached Data Shared With Other Customers?
It is a fair question, and the documented answer is reassuring. OpenAI states that caches are not shared across organizations and cannot be reused across regional processing boundaries. Caching also does not replace your provider's data retention settings, so teams with strict requirements should read the retention section of the docs for the model they use.
Where Does Prompt Caching Matter Most?
Three patterns benefit more than any others:
- Agents. An agent resends its instructions, tools and growing history on every step. Our look at how one team cut browser agent costs 76x shows how much of that bill is repeated context
- Document question answering. One long document, many questions. Cache the document once and each follow-up is billed mostly at the cached rate
- Long system prompts. Style guides, policies and few-shot examples are perfect cache material because they never change between requests
Caching also changes how you read a price list. A model's headline input price matters less for agent workloads than its cached-input price, which is why rate cards like the ones in our Claude Fable 5.2 pricing breakdown and Gemini 4 Hydrogen pricing guide list both.
The Bottom Line
Prompt caching rewards a small amount of discipline: keep the top of your prompt stable, keep the changing parts at the bottom, and verify hits in the usage data. Do that and a large share of your input bill drops by 90% or more, with faster responses as a bonus. For more practical guides like this one, browse our AI coverage.
Sources: Anthropic prompt caching documentation — accessed November 17, 2026; OpenAI prompt caching guide — accessed November 17, 2026; Google Gemini API context caching documentation — accessed November 17, 2026; QwenCloud Qwen4-Max model page — accessed November 17, 2026.
More AI Stories

GPT-6.2 Astra and Sol: Prices, Scores and Who Should Switch
GPT-6.2 Astra drops to $8 per million input tokens as Sol holds at $2. Here is what changed, what independent tests show and which model fits your work.

Rumble-2-Flash: A Tiny Open Speech Model for 40+ Languages
Rumble-2-Flash is a 0.5B open speech recognition model for 40+ languages. Reson8 says it can transcribe an hour of audio in about half a second.

Gemini Google Wallet Integration: AI Budgeting Explained
Gemini can now read your Google Wallet spending to chart budgets, flag pricier subscriptions and plan holiday costs. Here's how the US rollout works.
