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.
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.
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.