Formula: Prompt Caching Savings Calculator
- T,N: Repeated prefix tokens and monthly requests
- h: Cache hit fraction
- pᵢ,pᵣ,p𝓌: Input, cache-read, and cache-write price per million
Compare uncached prefix processing with cache reads and cache writes.
Illustrate an 80% cache hit rate with user-entered cache rates.
No. Cache writes and low hit rates can reduce or eliminate savings.
Only the part of the prompt that is identical at the start of every request: typically system instructions, fixed examples and stable reference text. It must come before anything that changes. User messages, per-query search results and model outputs are not part of it. Enter just that stable block's token count, not the full size of each request.
Both the cached and uncached costs grow in proportion to the prefix length, so their ratio does not move. Only the hit rate and the gap between the input and read rates change the percentage. The token count changes the dollar figures, which is why the 3,000 and 7,500 token cases show different savings but the same reduction.
90%. A cache read costs 0.2 per million against 2 per million for normal input, so even a perfect 100% hit rate leaves a tenth of the original bill. If your provider discounts cached reads by a different amount, the ceiling changes with it. The maximum reduction is always one minus the read rate divided by the input rate.
Most providers report cached input tokens separately in usage data or API responses. Divide cached prefix tokens by total prefix tokens over a representative period. If you cannot measure yet, start low, because small differences at the top of the prompt, such as a date or request ID, can stop the cache matching at all.
Barely. The page charges a single write per month, so even a large change to the write rate shifts the result by a few cents. Real caches expire and are rewritten, sometimes on every miss. If that applies to you, add the extra write cost yourself or the page will look more favourable than your invoice.
The message is fixed text that appears whenever the cached scenario costs more. It always blames writes, even when the cause is a read rate at or above the standard input rate. If you see it, compare the read and input rates first. A read rate higher than the input rate is almost certainly a typing mistake.
No. Prompt caching applies to input tokens that repeat across requests. Output tokens are generated fresh every time and billed at the output rate. This calculator ignores output entirely, so to see your full bill, add output costs from a separate estimate. Caching often makes a large difference to input spend and none to output spend.
Only if requests arrive close enough together to keep the cache alive. With long gaps, entries expire, each request becomes a miss and you pay write costs on top. The page will still show a saving at low volume because it assumes one write a month, so lower the hit rate to reflect how often requests actually reuse a warm cache.
Run the page once for each prefix with its own token count, request volume and hit rate, then add the savings. A product with separate system prompts for different features has a separate cache for each, and their hit rates can differ a lot. Combining them into one average prefix can hide a feature that is not caching well.
Treat it as an upper estimate. It assumes a constant hit rate, steady volume and one write. Use it to decide whether caching is worth engineering time, then measure the real cached-token share for a week. Budget with that measured figure, not the estimate, once you have it.
Only the symbol changes. The figures stay numerically identical, so the default still shows a saving of 215.99, just with a different sign in front. Enter your provider's rates in the currency they bill you in and pick the matching symbol. If you need another currency for a report, convert the final saving at your own rate.
Picture an application that sends the same 5,000-token block at the start of every request: a system prompt, a set of instructions, maybe a product catalogue or a policy document. It does this 30,000 times a month. That repeated block is the only thing this calculator looks at.
Without caching, every one of those tokens is billed at the standard input rate of 2 per million. That gives the without-caching figure of $300.00 a month.
With caching switched on, the calculator splits the requests in two. 80% are cache hits, billed at the cache read rate of 0.2 per million, a tenth of the normal price. The other 20% are misses, billed at the full input rate. Add one cache write at 2.5 per million and the cached cost comes to $84.01.
The difference is the headline: an estimated monthly saving of $215.99, or a 72% reduction. Almost all of that comes from the hits. The misses alone cost about $60, which is why the hit rate matters so much more than any other field on the page.
Change only the Cache Hit Rate and watch the reduction percentage. The default 80% gives 72%. At 100% the reduction reaches 90%, which is the ceiling with these prices: a cache read costs one tenth of a normal input token, so you can never save more than nine tenths. At 50% the reduction falls to 45%. At 20% it is 18%. At 0% the cached scenario costs a cent more than doing nothing, because you paid for a write that was never used.
That pattern is a straight line. With these default prices, each percentage point of hit rate is worth roughly nine tenths of a point of reduction. If you know your hit rate, you can estimate the saving in your head.
The hard part is knowing it. A hit only happens when the cached prefix is byte-for-byte identical to the one stored and the cache has not yet expired. Put a timestamp, a user name or a request ID near the top of the prompt and the hit rate collapses, even though the calculator will still assume whatever you typed. Move anything that changes between requests below the reusable block.
Traffic shape matters as well. A steady stream of requests keeps a cache warm. Bursty traffic with long gaps lets entries expire between bursts, so the first request of each burst is a miss. If your provider reports cached-token counts in its usage data, use the measured ratio rather than a guess.
The page offers two alternatives to the 5,000-token default. With a 3,000-token prefix, the without-caching cost is $180.00, the cached cost is $50.41 and the saving is $129.59. With a 7,500-token prefix, the figures are $450.00, $126.02 and $323.98.
All three cases show the same 72% reduction. That is not a coincidence. Both the cached and uncached costs scale with the number of tokens, so the ratio between them stays put. The prefix length tells you how many dollars are at stake; the hit rate and the price ratio tell you what share of them you keep.
This has a practical use. If you are deciding how much context to move into a cached block, the percentage will not tell you whether it is worth it. The dollar saving will. A longer stable prefix, such as fuller instructions or more examples, costs less per request once cached than you might expect, which can change how generous you are with context.
Remember that only the repeated prefix belongs in the token field. The user's own message, retrieved documents that differ per query and the model's output are billed separately and are not touched by caching. Entering total tokens per request will overstate the saving.
A quick example shows the scale. Dropping the prefix from the default to a fifth of its length leaves the reduction at 72% but cuts the saving to $43.20 a month, against a without-caching cost of $60.00. If trimming the prompt and caching it are competing ideas, the two can be run side by side here before anyone touches the code.
The formula adds one cache write per month: the prefix tokens multiplied by the write rate, once. With the defaults that write costs about a cent. In testing, raising the write rate from 2.5 to 10 per million changed the saving by only four cents, and setting it to zero changed it by one cent.
That makes the write rate nearly irrelevant on this page, and real billing is usually less kind. Provider caches expire after a period of inactivity, and a new write is charged each time the prefix is stored again. Many systems also write on a miss, which means the misses in your traffic may be billed at the write rate rather than the plain input rate.
You can correct for that by hand. If every miss also creates a cache entry, the misses in the default cost about $15 more than the page shows, because they are priced at 2.5 instead of 2 per million. The cached figure of $84.01 then rises to roughly $99, and the saving shrinks by the same amount. If the cache expires many times a day, multiply the single write by the number of refreshes you expect and subtract it.
For high-volume, steady traffic these corrections are small next to the read savings. For low-volume traffic with long gaps, they can wipe out most of the benefit, which is the situation the page summary warns about.
Because the page charges one write and nothing else, it breaks even almost immediately. Cut the monthly requests to 100 and it still reports a 70.8% reduction. Cut them to 10 and the reduction is 59.5%. Only at a single request a month does caching come out worse, with the cached scenario costing about 53% more.
Compare that with the default 30,000 requests and its 72% reduction. Going from thirty thousand requests down to a hundred barely moves the percentage in this model, because the one write is spread thinly in both cases. In a real system the low-volume case would look much worse, for the reason below.
That is the arithmetic of the model, not a promise. At 10 requests a month the requests are probably hours or days apart, and a short-lived cache would have expired long before the next one arrived. Every request would be a miss plus a fresh write, and caching would cost more than not caching.
So use the low-volume results with care. If your requests arrive less often than your provider's cache lifetime, set the hit rate close to zero and add the write costs yourself. The page will then show you what is really going on: little or nothing to gain.
The three rate fields are entered per million tokens in your own currency. The Display Currency selector only changes the symbol; it does not convert anything, so enter prices in the currency your provider bills.
The saving depends on the gap between the input rate and the cache read rate. Set the read rate equal to the input rate and the saving disappears, leaving only the write cost. Set the read rate higher than the input rate, which no sensible pricing would do, and the page reports a loss. It then explains that loss as cache writes making the cached scenario more expensive, which is not the real cause. If you ever see that message, check the read rate first.
Also check the minimum prefix size your provider requires before it will cache anything. A prefix below that size is simply not cached, and the true hit rate is zero whatever you enter here.
A useful sanity check on any prices you enter: divide the read rate by the input rate. With the defaults that gives one tenth, which caps the saving at 90% however good the hit rate is. If your provider's ratio is different, the ceiling moves with it, and the 72% figure at an 80% hit rate will move too.
The result is most useful as a ceiling on what restructuring your prompts can earn. If the default traffic can save at most $215.99 a month at an 80% hit rate, that tells you how much engineering time it is worth spending to get the cache working well.
Run it twice: once at the hit rate you hope for and once at a pessimistic rate. If the gap is large, the next step is measurement, not more modelling. Send a day of real traffic with caching on, read the cached-token counts from your usage report, and enter that ratio.
Finally, put this saving next to your other levers. A shorter prefix, a cheaper model for simple requests, or batch pricing for jobs that can wait may each save more than caching alone, and they can be combined.
When you present the result, show the inputs with it. A saving quoted without the hit rate behind it invites people to assume the best case, and the hit rate is the number most likely to be wrong in the first month.