Find how many repeated requests repay a cache write. This calculator isolates one reusable prompt prefix; output tokens and non-cached input are deliberately excluded because they do not change in this comparison.
When does Claude prompt caching save money?
When the savings from reusing a prefix exceed its initial write premium. With the illustrative $3 input, $3.75 five-minute write and $0.30 read rates below, the second request already saves money across the pair. A more expensive one-hour write needs more reuse: at $6, the first strictly cheaper total occurs on request three. A cache that misses every time can cost more than uncached input.
These are editable assumptions, not live prices or promised hit rates. Confirm the model, context length, cache minimum and TTL with your provider before budgeting.
Calculate with your assumptions
Sample inputs are illustrative. Calculations run locally. Input values are not sent to analytics or included in a shared link; only tool event names and the tool ID are measured.
The formula
Let P be reusable prefix tokens, N requests, B uncached input rate, W cache-write rate, and R cache-read rate. All rates are USD per million tokens.
Without cache = P / 1,000,000 × N × B
With cache = P / 1,000,000 × [W + (N − 1) × R]
Savings = without cache − with cache
When B > R and W ≥ B, the first whole request count with strictly positive savings is floor((W − R) / (B − R)) + 1. Equality is break-even, not savings. If the write already costs less than base input, the first request saves; later reads can still erase savings when R > B.
A worked example you can reproduce
With a 10,000-token prefix, 10 requests, and illustrative rates of $3 / $3.75 / $0.30, uncached prefix cost is $0.30. One write plus nine reads costs $0.0645. Savings are $0.2355 (78.5%). These defaults are assumptions, not a live price quote.
Five-minute cache, one-hour cache, or no reuse?
All scenarios use ten requests with the same 10,000-token prefix, $3/million uncached input and $0.30/million cache reads. The uncached comparison is $0.30. Each group begins with a new write; enter each group's request count in the calculator, then sum the groups.
| Scenario | Writes / reads | Total cost | Compared with no cache |
|---|---|---|---|
| 5-minute, one group · write $3.75/million | 1 / 9 | $0.0645 | $0.2355 saved |
| 1-hour, one group · write $6/million | 1 / 9 | $0.087 | $0.213 saved |
| 5-minute, five two-request groups | 5 / 5 | $0.2025 | $0.0975 saved |
| 5-minute, ten single-request groups | 10 / 0 | $0.375 | $0.075 more expensive |
Expiry or a changed prefix can create a new group. A real request may contain several separately metered prefixes; use its observed write/read counts rather than assigning every request a single hit or miss. The runnable Claude example shows how to inspect those counters.
When this estimate stops being valid
The cache must hit the exact reusable prefix after the initial write. Expiry, changed context, minimum cacheable lengths, cache misses and multiple writes need separate groups; sum those groups, not an optimistic 100% hit-rate estimate. Enter the correct TTL-specific write rate from your provider contract. This is not a claim that every API exposes identical cache-write billing.
A zero-token prefix never saves money. Rates may be zero, but blank fields are invalid. Output cost, suffix input, storage charges and product quality are outside this isolated comparison.
Next: measure actual cache usage
Use the cache cost by customer recipe to separate read, short-lived write and long-lived write usage. Compare the whole workflow in the AI agent cost per success calculator.
Primary references
Anthropic prompt caching documents cache lifetimes and separate read/write categories. OpenAI prompt caching explains prefix reuse. Verify your actual model and contract before entering prices.
Cache savings only count with the matching write cost.
- Anthropic cache cost by customer — Keep 5-minute and 1-hour writes separate.
- AI cost per user — Cached input is a different meter from uncached input.
- All calculators — Free local tools, no signup.