Skip to the page
Tecyfy

Does prompt caching pay off?

An assistant with a 20,000-token prompt asked 300 times a day costs $405 a month on Claude Sonnet 5.5 without caching, $99.78 with the 5-minute cache and $65.34 with the 1-hour cache.

A cache write costs more than a normal input token and a read costs a tenth or less, so caching pays only when requests reuse the cache before it expires. Say how big the repeated part of your prompt is and how often requests come, and the calculator prices all 3 ways side by side.

The calculator

tokens

Tools, system prompt and documents that every request repeats.

tokens

The question or latest turn, after the prefix.

tokens
requests
10hours

About 30 requests an hour while busy.

The answer

At 300 requests a day over 10 hours, the 1-hour cache cuts $405 a month to $65.34, 84% less, with under 1% of requests writing the cache and the rest reading it.

Cost with no caching, the 5-minute cache and the 1-hour cache
Right awayRequests writingPer requestA month
No cachingnone4.5 cents$405
5-minute cache9%1.1 cents$99.78
1-hour cacheCheapestunder 1%0.73 cents$65.34
Cost per request as traffic changesNo caching5-minute cache1-hour cache
04.6 cents0.11101001K

Requests an hour, at random

  1. The prices. Sonnet 5.5 charges $2 per million input tokens. Writing the cache costs $2.50 for 5 minutes or $4 for 1 hour, and reading it $0.10.
  2. When a write pays back. A 5-minute write pays for itself after 1 read; a 1-hour write after 2 reads. Each read also restarts the lifetime, for no charge.
  3. When requests share it. Arriving at random, the 5-minute cache costs less than none from about 2.8 requests an hour, and the 1-hour cache from about 0.7.
  4. The minimum. Sonnet 5.5 caches a prefix of 512 tokens or more. A shorter one is sent uncached, with no error.

How the calculator works it out

Caching stores the start of a prompt, the part that repeats: tool definitions, then the system prompt, then documents, in that order. The first request writes it, which costs 1.25 times the input price for a 5-minute cache or 2 times for a 1-hour cache. Requests that repeat the same start before the cache expires read it instead, at 0.1 times the input price, or less on the newest models. Every read restarts the lifetime for no charge.

So the cost depends on how often a request finds the cache gone. The day's first request always writes it. After that, with requests arriving at random, the chance that the gap before one is longer than the lifetime falls fast as traffic grows. In the example, 9% of requests write the 5-minute cache and under 1% the 1-hour one, which is why the 1-hour cache, despite its dearer writes, is the cheaper of the 2 at 30 requests an hour.

With requests arriving at random, the 5-minute cache costs less than no cache from about 2.8 requests an hour, and the 1-hour cache from about 0.7. Evenly spaced requests, such as a scheduled job, read the cache whenever the gap between them is shorter than its lifetime.

A batch halves every price, writes and reads included, since the discounts stack. But requests in a batch run at the same time, so a hit is not guaranteed: Anthropic reports hit rates of 30 to 98% and suggests the 1-hour cache for batches. The calculator prices the hits it would expect from your traffic, so treat a batch figure as the best case. A prefix shorter than the model's minimum is sent uncached, with no error.

Questions

How much does prompt caching save?
Up to about 90% of the cost of the repeated part, when nearly every request reads the cache. An assistant with a 20,000-token prompt, a 500-token question and a 400-token answer, asked 300 times a day over 10 hours, costs $405 a month on Claude Sonnet 5.5 without caching and $65.34 with the 1-hour cache, 84% less.
Should I use the 5-minute or the 1-hour cache?
The 5-minute cache when requests come more often than every 5 minutes, since each read refreshes it for free. The 1-hour cache when gaps are longer: it costs more to write but expires far less often. At 30 requests an hour arriving at random, 9% of requests rewrite the 5-minute cache, and the 1-hour cache costs less overall, $65.34 a month against $99.78.
When does prompt caching cost more than not caching?
When the cache usually expires before the next request. Every write costs more than plain input, so a cache that is written and never read loses money. At 20 requests a day over 10 hours, the 5-minute cache costs $28.80 a month against $27.00 without it, while the 1-hour cache still saves, at $12.56.
How much does a cache write cost on the Claude API?
1.25 times the base input price for a 5-minute cache and 2 times for a 1-hour cache. A cache read costs 0.1 times the input price, and less on some of the newest models. The multipliers stack with the Batch API discount and long-context prices.
Does prompt caching work with the Batch API?
Yes, and the discounts stack: a batch is half price, cache writes and reads included. Hits are best effort, because a batch's requests run at the same time; Anthropic reports 30 to 98%, and suggests the 1-hour cache and identical cache_control blocks in every request.
What is the minimum prompt length for caching?
It depends on the model: 512 tokens for the newest Claude models, and 1,024 to 4,096 for older ones. A shorter prefix marked for caching is simply sent uncached, and the response's usage shows 0 tokens written and read.
What part of a prompt does the cache store?
Everything from the start up to the block marked with cache_control: tools first, then the system prompt, then messages. Any change before that point, even one character, means a new prefix and a new write, so put what changes, such as the user's question or a timestamp, after it.

Put this calculator on your own site

Copy the code into any web page: a blog post, a course page or your team's wiki. The calculator runs in a frame and shows the same figures as this page, so when the prices change here they change on your page too. It is free and needs no account, and nothing a reader types is sent anywhere.

The code opens the calculator with the settings you have chosen above.

The short script at the end lets the frame grow and shrink with the calculator. Where a page cannot take scripts, choose a fixed height and the frame scrolls.

<iframe src="https://tecyfy.com/embed/prompt-caching-calculator" title="Prompt caching calculator" width="100%" height="2800" style="border:0;display:block" loading="lazy" allow="clipboard-write"></iframe>
<p><a href="https://tecyfy.com/ai-agents/prompt-caching-calculator">Prompt caching calculator</a> by Tecyfy</p>
<script>addEventListener("message",function(e){if(e.origin!=="https://tecyfy.com"||!e.data||e.data.type!=="tecyfy:height")return;var h=Number(e.data.height);if(!(h>0))return;document.querySelectorAll("iframe").forEach(function(f){if(f.contentWindow===e.source)f.style.height=Math.min(h,20000)+"px"})})</script>