Prompt Caching Savings Calculator

Caching a long, unchanging prompt prefix is not free: the first request pays a premium to write the cache, and every hit after that pays a discounted read rate. Whether you come out ahead depends on how many requests reuse the entry before it expires. This calculator takes your prefix length, your provider's write and read multipliers and your base input price, and returns the cost with and without caching, the saving per cache lifetime, the saving as a percentage and the number of requests you need before caching pays for itself.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Cached prefix lengthTokens at the start of every request that never change: system prompt, tool schemas, style guide, fixed documents.10000 tok
Requests per cache lifetimeHow many requests reuse one cache entry before it expires. Count only requests inside the entry's time-to-live.50
Base input price per 1M tokensThe uncached input rate for the model you are using, before any cache multiplier.3 $
Cache write multiplierWhat the first request pays per cached token, as a multiple of the base input rate.1.25 ×
Cache read multiplierWhat a cache hit pays per cached token, as a multiple of the base input rate.0.1 ×
Requests per monthTotal requests carrying this prefix in a month, used to scale the per-lifetime saving.200000

It returns

  • Monthly saving from caching — Negative means the write premium is not recovered at this number of requests per lifetime.
  • Cost per cache lifetime without caching
  • Cost per cache lifetime with caching
  • Saving per cache lifetime
  • Saving on the cached prefix
  • Requests needed to break even

The formula

Ccached=pbw+(R1)pbk
R*=wk1k
s=1w+(R1)kR

In plain text: Cost with caching = p·b·w + (R − 1)·p·b·k, against p·b·R without

  • pCached prefix length, in millions of tokens when multiplied by b (tokens)
  • bBase input price per million tokens ($ / 1M tok)
  • wCache write multiplier applied to the first request (×)
  • kCache read multiplier applied to each hit (×)
  • RRequests served within one cache lifetime (requests)

Only the prefix is affected. Tokens after the cache breakpoint are billed normally in both cases, so they cancel out of the comparison.

Updated Category LLM Inference Cost & Serving Verified against published test cases Reading time 11 min

What prompt caching charges you for

Prompt caching stores the model's internal state for a prefix of your request so that identical prefixes on later requests skip the work of processing those tokens again. Providers price this in three tiers rather than two: the normal input rate for uncached tokens, a higher rate on the request that writes the cache, and a much lower rate on each request that reads it.

That structure is what makes caching a break-even question rather than a free win. Writing the cache costs more than not caching at all. If the entry expires before enough requests reuse it, you have paid a premium for nothing. If many requests reuse it, the premium is spread thin and you approach the read rate, which is a fraction of what you were paying.

The calculator works in units of a cache lifetime: one write followed by however many hits occur before the entry expires. That is the correct accounting boundary, because an entry that expires after four hits and is rewritten costs the write premium again. Two hundred requests spread over a day with a five-minute time-to-live are not two hundred hits on one entry — they may be dozens of separate lifetimes, each paying a write.

What caching does not touch is everything after the prefix. The user's actual message, the retrieved documents that change per request, and the model's reply are billed exactly as before. So the saving is bounded by the share of your input that is genuinely constant, which is why the first question to answer is how many of your tokens never change.

The formula, and where the break-even comes from

Let p·b be the cost of sending the prefix once at the base rate, where p is the prefix length in millions of tokens and b the price per million. Over R requests:

Without caching: R × p × b

With caching: p × b × w + (R − 1) × p × b × k

One write at the multiplier w, then R − 1 hits at the multiplier k. Set the two equal and the prefix cost p·b cancels out entirely:

R = w + (R − 1)k → R − Rk = w − k → R* = (w − k) ÷ (1 − k)

Three things follow from that expression, and each is worth internalising.

Break-even does not depend on prefix length or price. Both cancel. A 200,000-token prefix on an expensive model and a 2,000-token prefix on a cheap one break even at the same number of requests. Length and price decide how much you save, not whether you save.

Break-even is usually small. With a 1.25× write and a 0.10× read, R* = (1.25 − 0.10) ÷ 0.90 = 1.278, so two requests inside one lifetime already put you ahead. With a 2.0× write and a 0.25× read, R* = 1.75 ÷ 0.75 = 2.333, so you need three.

The saving has a ceiling of 1 − k. As R grows, the write premium is amortised away and the cost per request tends to k times base. At a 0.10× read rate the maximum possible saving on the cached prefix is 90%, and you get most of the way there within a few dozen requests. Chasing higher reuse past that point buys very little.

The formula assumes k < 1. If your read multiplier is 1 or above there is no discount to earn, the cached path never costs less, and the calculator reports no break-even.

Worked example: a 10,000-token system prompt at $3 per million

Your agent carries a 10,000-token prefix on every call: a system prompt, a tool schema and a fixed style guide. The base input rate is $3.00 per million tokens, the cache write multiplier is 1.25× and the read multiplier is 0.10×. Traffic is dense enough that 50 requests hit each cache entry before it expires, and you serve 200,000 such requests a month.

  1. Cost of the prefix once. 10,000 ÷ 1,000,000 = 0.01 million tokens; 0.01 × $3.00 = $0.03 per request uncached.
  2. Without caching, per lifetime. 50 × $0.03 = $1.50.
  3. The write. $0.03 × 1.25 = $0.0375.
  4. The 49 hits. 49 × $0.03 × 0.10 = 49 × $0.003 = $0.147.
  5. With caching, per lifetime. $0.0375 + $0.147 = $0.1845.
  6. Saving per lifetime. $1.50 − $0.1845 = $1.3155, which is 1.3155 ÷ 1.50 = 87.7% of the prefix cost.
  7. Break-even. (1.25 − 0.10) ÷ 0.90 = 1.278, so 2 requests per lifetime is enough to be ahead.
  8. Monthly. 200,000 requests ÷ 50 per lifetime = 4,000 lifetimes; 4,000 × $1.3155 = $5,262 a month.

Check the ceiling: 87.7% against a maximum of 1 − 0.10 = 90%. The remaining 2.3 percentage points are the write premium spread across 50 requests, and pushing reuse to 100 requests would only reach 88.85%. The bulk of the win arrives in the first handful of hits.

Now the failure case. Suppose the entry expires before the second request, so every request is a write with no hits. Cost per request becomes $0.0375 against $0.03, and you have made the prompt 25% more expensive. That is the whole risk of caching, and it is entirely a question of traffic density against time-to-live.

How to read the result

Compare requests per lifetime with the break-even count first. Everything else is secondary. Above it you save, below it you pay a premium, and the calculator says which side you are on. Because break-even is typically two or three requests, most production traffic clears it easily — the cases that fail are low-volume endpoints, per-user prefixes that only one user touches, and batch jobs that run once an hour against a five-minute time-to-live.

Read the percentage against its ceiling of 1 − k, not against 100%. A saving of 87.7% where 90% is the maximum means you have captured nearly all of what is available. A saving of 40% where 90% is available means your reuse count is low and there is real room to improve it by extending the entry lifetime or routing more traffic through the same prefix.

Remember the percentage applies to the prefix only. If the prefix is 10,000 of a 12,000-token request, an 87.7% saving on the prefix is a large cut in the total bill. If the prefix is 2,000 of a 12,000-token request, the same 87.7% barely moves it. Work out the prefix share of your total input before deciding this is the lever that matters; the token cost calculator gives the full request breakdown.

If the monthly figure is negative, the fix is structural rather than numerical. Raise the number of requests that share one entry: use a single global prefix instead of a per-user one, order your prompt so the stable content comes first, and keep any per-request content strictly after the cache breakpoint. A prefix that varies by even one token is a different prefix and a different cache entry.

Saving on the cached prefix by reuse count and multiplier pair

Each cell is 1 − (w + (R − 1)k) ÷ R, the share of the uncached prefix cost you avoid. Negative values mean the cached path costs more at that reuse count.
Requests per cache lifetimeWrite 1.25× / read 0.10×Write 2.00× / read 0.25×
1−25.0%−100.0%
232.5%−12.5%
351.7%16.7%
567.0%40.0%
1078.5%57.5%
2585.4%68.0%
5087.7%71.5%
10088.9%73.3%
Ceiling (R → ∞)90.0%75.0%

Break-even is 1.28 requests in the first column and 2.33 in the second, which is why the first column is already positive at two requests and the second is not. Both curves flatten quickly: more than three quarters of the achievable saving arrives by the tenth request.

The cache key is an exact prefix match

A cache entry is found only when the beginning of your request matches the cached content exactly, token for token. Injecting the current timestamp, a request identifier, a user name or a randomised instruction anywhere in the prefix produces a different prefix and therefore a miss — and a miss means you pay the write premium again. This is the most common reason a deployment reports far fewer hits than expected. Put every stable element first, in a fixed order, and place anything that varies after the cache breakpoint. The same applies to tool definitions serialised from a hash map with non-deterministic ordering.

Mistakes that make the saving smaller than modelled

  • Counting monthly requests as requests per lifetime. A cache entry has a time-to-live measured in minutes. Only requests arriving inside that window count as hits on the same entry.
  • Per-user or per-session prefixes. One entry per user means the reuse count is that user's request rate, not your total traffic. Global prefixes are what deliver high reuse.
  • Variable content before the stable content. Anything that changes must come after the cached prefix, or nothing behind it can be cached.
  • Ignoring the minimum cacheable length. Providers set a floor on how long a prefix must be to be cacheable. A prefix below it is billed normally and the write premium may still apply to the attempt.
  • Assuming the reply is cached. Caching covers input processing, not generation. Output tokens are billed at their usual rate no matter how repetitive the answer is.
  • Forgetting concurrency. Several instances warming the same prefix at once can each write the cache, multiplying the premium. Warm deliberately with one request before opening the traffic gate.
  • Comparing against the wrong baseline. If you would have shortened the prompt instead, the fair comparison is caching against the shorter prompt, not against the long one you kept.

Where caching sits among the other cost levers

Caching is the cheapest of the major cost levers to implement, which is why it belongs first in any optimisation sequence. It requires no change to model behaviour, no evaluation work and usually no more than reordering a prompt and adding a breakpoint. The savings arrive on the same day.

The next lever is shortening the context itself. That reduces the prefix you cache and the tokens you never cache alike, and it speeds up prefill, so it improves latency as well as cost — see the throughput and latency calculator for how prompt length maps to time to first token. Caching and shortening are complements, not alternatives: cache what must stay, cut what need not.

Further along sits fine-tuning, which removes a long few-shot prompt permanently by putting the behaviour in the weights. That trade has its own break-even in requests, and it competes directly with caching, because a cached few-shot prompt is already cheap. Work out both before committing: the fine-tuning versus long-prompt calculator handles the training-cost side, and if the prompt is cached at a 0.10× read rate the case for fine-tuning is considerably weaker than the uncached comparison suggests.

Finally, translate whatever you save into the metric your business actually reports. A monthly saving is an infrastructure number; gross margin per user is the one that decides pricing. Feed the reduced blended rate into the cost per user per month calculator to see how far the saving moves it.

Frequently asked questions

How many requests do I need before caching pays off?

Compute (w − k) ÷ (1 − k) with your provider's write and read multipliers. At a 1.25× write and a 0.10× read that is 1.28, so two requests inside one cache lifetime are enough. At a 2.0× write and a 0.25× read it is 2.33, so you need three. The threshold is independent of prefix length and of the base price, because both cancel out of the equation.

What counts as one cache lifetime?

The period from writing an entry until it expires, which is governed by the provider's time-to-live. Count only the requests that hit that same entry within the window. If your traffic is bursty, the practical reuse count is the number of requests in a typical burst, not your monthly total divided by anything. Some providers extend the lifetime on each hit, which raises the effective reuse count considerably.

Can prompt caching ever cost me more?

Yes, whenever the entry is written and reused fewer times than the break-even count. In the worst case every request writes a fresh entry and never reads one, so a 1.25× write multiplier makes the prefix 25% more expensive. Low-traffic endpoints, per-user prefixes and any prompt containing a timestamp or request identifier are the usual causes.

Does caching reduce latency as well as cost?

Yes, and often that matters more than the money. A cache hit skips recomputing attention over the cached tokens, which is the bulk of prefill for a long prefix, so time to first token falls substantially. The saving in seconds is roughly proportional to the saving in prefill work, so a prefix that is most of your input gives a large latency improvement while a short one gives little.

What should go in the cached prefix?

Everything that is byte-identical across requests, ordered from most stable to least: system instructions, tool and function schemas, style guides, few-shot examples, and any reference documents that do not change per user. Then place the cache breakpoint, and put the conversation history and the user's message after it. Nothing behind a varying element can be cached, so a single misplaced timestamp can disable caching for the entire prompt.

Does the saving percentage apply to my whole bill?

No. It applies to the cached prefix only. Uncached input tokens and all output tokens are billed at their normal rates. To get the effect on your total, multiply the percentage by the prefix's share of your input cost — an 87.7% saving on a prefix that is 80% of input tokens cuts input cost by about 70%, while the same percentage on a prefix that is 15% of input tokens cuts it by about 13%.

Why do the write and read multipliers differ between providers?

Because they reflect a genuine cost structure: writing an entry means computing and storing the model's internal state for those tokens, and storage of that state is expensive per unit time. Providers price the write premium to cover the compute and the storage, and the read discount to reflect the work skipped. Enter your own provider's published multipliers rather than assuming any particular pair — the break-even they imply differs, as the reference table shows.

Is caching still worth it if I could just shorten the prompt?

Shorten first where you can, then cache what remains. The two attack different things: shortening reduces tokens sent, caching reduces the price paid for tokens you must send. A prompt that is long because it carries genuinely necessary instructions and schemas is the ideal caching candidate. A prompt that is long because nobody has pruned it in six months should be pruned, since a cached read rate applied to unnecessary tokens is still money spent on unnecessary tokens.

References