Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path
Prompt Caching Savings Calculator
Prompt caching is the biggest cost lever on repetitive LLM workloads — a shared system prompt or RAG context read on every call is charged at a fraction of the price once cached. Put in your prompt shape (cached prefix vs fresh tokens), a cache hit rate, and the provider's cache-write and cache-read multipliers, and see your effective cost per request and the percentage saved versus paying full price every time.
Effective input = fresh + hit×(prefix×read) + miss×(prefix×write). A written prefix pays for itself after 1.3 reuses at these multipliers. Set write/read × to your provider's published cache prices.
On a repetitive LLM workload, most of the input bill is the same tokens sent over and over. A system prompt, tool definitions and a shared document are processed at full price on every request unless the provider can reuse them. This calculator compares a request with and without prompt caching and scales the difference to a month of traffic.
What it computes
price = input $ per 1M tokens / 1,000,000
no cache = (prefix + fresh) × price
with cache = fresh × price
+ hit × prefix × price × read
+ (1 − hit) × prefix × price × write
saved % = 1 − with cache / no cache
monthly = per-request cost × requests per month
break-even = 1 + (write − 1) / (1 − read) uses of one written prefix
- Prefix is the cacheable part: identical at the start of every request.
- Fresh tokens change per request and always pay full price.
- Hit is the share of requests that find the prefix already cached. A miss writes it.
- Write and read are multipliers on the base input price for writing and reading the cache.
Output tokens are not part of the calculation, because caching only discounts input.
A worked example
The defaults are an 8,000-token prefix, 400 fresh tokens, an 85% hit rate, $3 per million input tokens, a 1.25× write, a 0.1× read and 1,000,000 requests a month.
- No cache:
8,400 × $0.000003 = $0.0252per request. - Fresh tokens:
400 × $0.000003 = $0.0012. - Hits:
0.85 × 8,000 × $0.000003 × 0.1 = $0.00204. - Misses:
0.15 × 8,000 × $0.000003 × 1.25 = $0.0045. - With cache:
$0.0012 + $0.00204 + $0.0045 = $0.00774, shown as $0.0077, so 69% cheaper per request. - Monthly: $25.2K without caching against $7.7K with it, $17.5K saved. Break-even is
1 + 0.25 / 0.9 = 1.28, shown as 1.3 reuses.
Notice that the 15% of misses cost more than the 85% of hits. The hit rate, not the discount, is what moves the result:
| Hit rate | Cost per request | Saved | Monthly |
|---|---|---|---|
| 0% | $0.0312 | −24% | $31.2K |
| 50% | $0.0174 | 31% | $17.4K |
| 85% | $0.0077 | 69% | $7.7K |
| 95% | $0.0050 | 80% | $5.0K |
| 100% | $0.0036 | 86% | $3.6K |
Assumptions and limits
- Hit rate is an input. The tool does not model traffic, cache lifetimes or how many prefixes you have; you supply the rate.
- One prefix, written whole. Real caches can match several breakpoints, and a partial match still saves on the matching part.
- Provider rules are not modeled. Minimum cacheable lengths, commonly around 1,024 tokens, longer lifetimes at a higher write price, storage fees and automatic caching all change the result.
- Input only. Output pricing, rate limits and the latency benefit of caching, which is often large, are left out.
How to use the result
- Order the prompt for caching. Stable content first, per-request content last, with no timestamps or IDs in the prefix.
- Measure your real hit rate from the usage fields providers return, then plug it in rather than guessing.
- Keep traffic warm. If gaps between requests exceed the cache lifetime, every request is a miss and caching costs extra.
- Compare reuse with break-even. At an 85% hit rate each write is followed by about 5.7 reads on average, far above the 1.3 uses needed. At these multipliers caching only breaks even at about a 22% hit rate, and below that it costs more than it saves.
- Cache big shared context. Savings scale with the prefix’s share of the prompt; a 200-token system prompt is usually below the provider’s minimum cacheable length, so it is not cached at all.
When to use it, and when not
Use it to decide whether restructuring prompts around a stable prefix is worth the engineering, to set a hit-rate target before launch, and to compare providers’ pricing models by entering each one’s multipliers against the same traffic. Once the hit rate is known the arithmetic is exact, so the only real uncertainty is the rate you type in.
Once caching is live, stop estimating. Responses report cached and uncached input tokens separately, and those fields give the real hit rate and the real bill. The model also does not fit workloads where the shared content is not at the front of the prompt, where most prompts are unique, or where the prefix is shorter than the provider’s minimum: the tool will show savings that cannot happen.
Trade-offs and limits
The percentage on screen is a saving on input, and it is the number most often over-quoted. Add 500 output tokens per request at $15 per million, five times the default input price, which is the output-to-input ratio of every Claude and GPT-6.1 model in the pricing comparator, and the default request costs $0.0327 without caching and $0.01524 with it. The whole bill falls 53%, not 69%, and the more output-heavy the workload, the smaller the real figure.
| Not modeled | Effect |
|---|---|
| Latency | A cached prefix is not reprocessed, so time to first token falls; often worth as much as the cost saving |
| Cache lifetime | Gaps longer than the lifetime turn hits into misses; the tool assumes your rate holds |
| Several breakpoints | A partial match still saves on the matched part; the tool is all or nothing |
| Concurrent first requests | A burst of identical requests that arrive before the first write lands can each pay to write |
| Pricier long-lived caches | At a 2× write, break-even rises from 1.3 to 2.1 uses and the default saving falls from 69% to 59% |
Common mistakes
- Unstable serialization. The prefix can change when the content does not: tool definitions built from an unordered map, JSON keys in varying order, or reformatted whitespace each break the exact match without anyone editing the prompt.
- Forgetting that deploys reset the cache. A new system prompt, tool list or model starts every prefix cold, so right after a release every request is a miss and pays the write premium. Frequent prompt edits quietly lower the real hit rate.
- Computing the hit rate from all input tokens. The tool’s rate is the share of requests whose prefix hits. At the defaults 85% of requests hit, but cached tokens are only
6,800 / 8,400 = 81%of average input, because fresh tokens are never cached. Divide cached tokens by prefix tokens, not by all input. - A prefix under the minimum. Below the provider’s minimum length nothing is cached and there is no error: requests simply pay full price, and the usage fields report no cached tokens.
Check yourself
Someone adds a request ID to the first line of the system prompt. What happens to the monthly bill at the defaults?
Every prefix is now unique, so the hit rate is 0% and every request writes the cache: $0.0012 + 8,000 × $0.000003 × 1.25 = $0.0312 per request. That is $31.2K a month against $25.2K with no caching at all, $6.0K worse than doing nothing. Move the ID after the prefix and the 85% hit rate returns.
A provider charges no write premium (1.0×) but discounts reads only to 0.5×. What does the default prompt save at an 85% hit rate?
Prefix cost 8,000 × (0.85 × 0.5 + 0.15 × 1.0) = 4,600 token-equivalents, plus 400 fresh, is 5,000; times $0.000003 is $0.015 against $0.0252, a 40% saving. Break-even is 1 + 0 / 0.5 = 1 use, so this pricing never loses money at any hit rate, but at high hit rates it saves far less than 1.25× / 0.1×.
The prefix grows to a 50,000-token document with the same 400 fresh tokens and 85% hits. Does the saving grow?
No cache: 50,400 × $0.000003 = $0.1512. With cache: $0.0012 + $0.01275 + $0.028125 = $0.042075, a 72% saving against 69% before. It cannot pass 1 − (0.85 × 0.1 + 0.15 × 1.25) = 72.75% at this hit rate: a bigger prefix only shrinks the fresh tokens’ share, it does not change the hit-and-miss blend.
A longer-lived cache costs 2× to write instead of 1.25×, reads still 0.1×. What hit rate must it reach to beat the default 85%?
Per request it costs $0.0012 + $0.024 × (0.1h + 2(1 − h)). Setting that equal to the default $0.00774 gives 2 − 1.9h = 0.2725, so h ≈ 91%. Its own break-even, against no caching, is 1 / 1.9 = 53%. The longer lifetime pays only if it lifts the hit rate from 85% to above 91%.
How it works
- Effective input = fresh + hit × prefix × read + miss × prefix × write.
- Cache write premium is paid on misses; read discount on hits.
- Break-even uses = (write − read) ÷ (1 − read); 1.3 at the defaults.
- Set the multipliers to your provider’s published numbers.
Frequently asked questions
How does prompt caching save money?
Providers let a stable prefix, such as a system prompt, tool definitions or a long document, be cached after it is first processed. Later requests that start with the same prefix read it from the cache at a steep discount instead of paying full input price to process it again. On workloads where most of the prompt is fixed context and only a short user turn changes, that shrinks the largest line on the bill. With this tool’s defaults it cuts input cost per request by 69%.
What is the cache-write premium?
The call that populates the cache can cost more than a normal input token, because the provider stores the processed prefix; the default here is 1.25 times the base price. Caching pays off only when a written prefix is reused enough to recover that premium. The tool charges the write price on every miss and the read price on every hit, and reports the break-even: at 1.25 times to write and 0.1 times to read, a prefix pays for itself after about 1.3 uses.
What hit rate should I expect?
It depends on how often the same prefix repeats before the cache expires. A chatbot with one fixed system prompt and steady traffic can reach a very high rate, while a workload where every prompt is unique gets little benefit. Caches typically expire after a few minutes without use, so sparse traffic keeps paying the write premium. In this tool the default prompt saves 31% at a 50% hit rate, 69% at 85% and 80% at 95%, and costs more than no cache at 0%.
Which providers support this and are the multipliers exact?
Anthropic, OpenAI and Google all offer prompt or context caching, with different write premiums, read discounts, lifetimes and minimum prefix lengths. The defaults, a 1.25 times write and a 0.1 times read, match Anthropic’s published five-minute cache pricing on most Claude models, though its newest read cheaper still: 0.05 times on Claude Opus 5.5 and Sonnet 5.5, 0.025 times on Fable 5.1. Some providers charge no write premium but give a smaller read discount, and some bill for storage time. Set the write and read multipliers to your provider’s current numbers for an accurate figure.
What should go in the cached prefix?
Everything that is identical across requests and comes first: the system prompt, tool definitions, fixed instructions and examples, and any shared document or retrieved context reused across turns. Caches match on an exact prefix, so one changed character, such as a timestamp or a user name near the top, breaks the match for everything after it. Put the stable material first, the per-request material last, and keep the prefix byte-for-byte identical.