A prompt cache that expires between requests costs more than no cache
Prompt cache TTL: Claude caches for 5 minutes or 1 hour, GPT for 30 minutes or 12 hours. Write prices, refresh rules and the gaps where caching loses money.
By Meet ModiSend Claude Opus 5.5 the same 100,000-token prefix 50 times, one request every 8 minutes, with the default prompt cache switched on. Input for that prefix costs $25.00. Switch the cache off and it costs $20.00. Every request lands after the 5-minute cache has expired, so every request pays the 1.25x write price and none of them ever reads. A cache that never hits is a 25% surcharge.
That is the whole prompt cache TTL question in one example. Claude's cache lives 5 minutes by default, or 1 hour for a higher write price. OpenAI's GPT-5.6 and later models cache for at least 30 minutes by default, or 12 hours. Both refresh on a hit, with one exception that matters. Which one is cheaper depends almost entirely on the gaps between your requests, not on the headline discount. I did not make any API calls for this: testing TTLs for real means paying for writes and waiting out timers, and I had no budget for that. Everything below is the vendors' own docs and price tables, plus a small cost model run offline against them.
How does prompt caching work
A model reads your prompt into internal state (the KV cache) before it writes a word. Prompt caching keeps that state for a shared prefix, such as a long system prompt, tool definitions, or a document, so the next request that starts with the same bytes skips the work. You pay more than normal input the first time (the write) and much less afterwards (the read). The TTL is how long the stored prefix stays readable without being used. Change one byte early in the prefix and everything after it is a miss.
I wrote about the cheapest version of this idea, generating once and reusing many times, in building the quiz before anyone presses play. Prompt caching is the vendor doing the same trick one level down.
Claude prompt caching TTL: 5 minutes or 1 hour
From Anthropic's prompt caching docs: "By default, the cache has a 5-minute lifetime. The cache is refreshed for no additional cost each time the cached content is used." The longer option is one field:
"cache_control": { "type": "ephemeral", "ttl": "1h" }- It is not automatic on the Messages API. You opt in with one cache_control field at the top level, or put it on up to 4 blocks yourself.
- Writes cost 1.25x the input price for 5 minutes and 2x for 1 hour. Reads cost 0.1x on most models, 0.05x on Opus 5.5 and Sonnet 5.5, and 0.025x on Fable and Mythos 5.1 and 5.2.
- The timer starts when the request starts, not when the response ends. Anthropic's example: after a 4-minute streamed response, the next request "must start within about 1 minute".
- Prompts below the minimum (512 tokens on the 5.x models, up to 4,096 on older ones) are processed without caching, "and no error is returned."
- Hits show up in usage as cache_read_input_tokens. Writes are cache_creation_input_tokens, split into ephemeral_5m_input_tokens and ephemeral_1h_input_tokens.
In dollars, per million tokens on Opus 5.5: $4 input, $5 for a 5-minute write, $8 for a 1-hour write, $0.20 for a read. On Sonnet 5.5, half of each.
OpenAI prompt caching TTL: 30 minutes or 12 hours
OpenAI's prompt caching guide splits by model generation, and the two halves behave differently. For GPT-5.6 and later, caching is on by default and writes cost money: "cache writes cost 1.25× the standard, uncached input-token rate for the default 30-minute lifetime. In the Responses API, you can choose a 12-hour minimum lifetime at a write rate of 2.5× ordinary input."
"prompt_cache_options": { "mode": "implicit", "ttl": "12h" }- Both TTLs are minimums. OpenAI "may retain entries longer than the requested minimum".
- Reads cost 0.1x on most models and 0.05x on GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Sol and GPT-6.1 Terra, "regardless of the selected lifetime."
- The minimum cacheable prompt is 1,024 tokens. Each request can create up to four cache writes.
- Earlier models (GPT-5.5 and before) have no write fee at all and use prompt_cache_retention instead: in_memory, "typically" 5 to 10 minutes, or 24h. The guide's migration note is "Replace prompt_cache_retention with prompt_cache_options.ttl."
- Hits are usage.input_tokens_details.cached_tokens, writes are cache_write_tokens, split into ttl_30m_tokens and ttl_12h_tokens.
And the refresh rule, quoted in full because it is the one that changes the maths: "A 30-minute read refreshes coverage to at least 30 minutes after that read. If it uses an entry with valid 12-hour coverage, it preserves the later of the existing expiry and 30 minutes after the read. It does not restart a 12-hour clock or incur another write charge." A 12-hour entry dies 12 hours after it was written, however busy it was.
Prompt caching cost: the break-even maths
Paying for the longer TTL makes sense once it saves enough cache misses to cover its higher write price. In units of the input price, the extra write costs W_long minus W_short. Each miss it avoids saves W_short minus the read price r. So the longer TTL wins once it avoids more than (W_long - W_short) / (W_short - r) misses.
Claude, 1h vs 5m: (2.0 - 1.25) / (1.25 - 0.05) = 0.625 misses
OpenAI, 12h vs 30m: (2.5 - 1.25) / (1.25 - 0.05) = 1.042 missesSo on Claude, one pause between 5 and 60 minutes is enough to make the 1-hour write worth it. On OpenAI, it takes two pauses longer than 30 minutes. Anthropic's pricing page says much the same from the other side: a 5-minute write pays for itself "after one cache read", a 1-hour write "after two cache reads".
I ran the numbers on real prices
A break-even formula hides the shape, so I put a small Python model together. It sends N requests with the same P-token prefix, one every G minutes, applies each vendor's refresh rule as the docs state it, and prices only the prefix. Prices are copied from the Anthropic and OpenAI pricing pages as of December 2. 50 requests, 100,000-token prefix, cost in dollars:
$ python3 cachecalc.py 50 100000 1,8,25,40,90,300,600
model ttl G=1m G=8m G=25m G=40m G=90m G=300m G=600m
Claude Opus 5.5 none 20.000 20.000 20.000 20.000 20.000 20.000 20.000
5m 1.480 25.000 25.000 25.000 25.000 25.000 25.000
1h 1.780 1.780 1.780 1.780 40.000 40.000 40.000
gpt-6.2-astra none 40.000 40.000 40.000 40.000 40.000 40.000 40.000
30m 2.960 2.960 2.960 50.000 50.000 50.000 50.000
12h 3.960 3.960 3.960 7.880 15.720 35.320 51.000
Writes per run (short TTL / long TTL) by gap:
Claude Opus 5.5 1/1 50/1 50/1 50/1 50/50 50/50 50/50
gpt-6.2-astra 1/1 1/1 1/1 50/3 50/7 50/17 50/25Three things in that table I did not expect before running it:
- Claude's two TTLs are a cliff, not a slope. The 1-hour cache costs $1.78 at any gap under an hour and $40.00 at any gap over it, twice the uncached price, because every request is a 2x write.
- OpenAI's 12-hour cache degrades gradually. At a 40-minute gap it writes 3 times in 50 requests, at 90 minutes 7 times. Reads keep pushing expiry out by 30 minutes, but never past the 12 hours from the write.
- At a 10-hour gap, the 12-hour cache costs $51.00 against $40.00 uncached. Every second request is a read and every other one a fresh 2.5x write, because the 12-hour clock never restarts.
The default settings are where most money goes, though. At an 8-minute gap, Claude's default 5-minute cache costs $25.00, and the same request on GPT-6.2 Astra with its default 30-minute cache costs $2.96. That is not because one model is cheaper; Astra's base input price is twice Opus 5.5's. It is purely the TTL.
What the Requesty essay got right, and what it skipped
The essay this post started from, Requesty's "Claude 5-minute prompt cache vs GPT 30-minute cache: the cost of pauses", measured 30 days of its own gateway traffic and reports that 23.1% of the Claude bill went to rebuilding caches that expired while developers were away, against 9.3% on GPT. I cannot check those numbers, they are Requesty's data. The arithmetic I could check holds up: a 210,000-token Opus 5.5 prefix is $0.042 to read and $1.05 to rewrite.
Two things it leaves out. It says both labs "charge the same per-token cache multipliers", which is true for the default 1.25x write and not for the long TTLs (2x against 2.5x) or for every model's read price. And it never mentions that OpenAI's 12-hour clock does not restart on a read, which is the reason the 12-hour row above turns expensive. Its finding that switching a warm 5-minute session to 1 hour rewrites the whole prompt is documented by Anthropic under mixing TTLs, and OpenAI has the same rule: "Upgrading valid 30-minute coverage to 12 hours charges a new 12-hour write for those tokens, without credit for the earlier write."
How to pick a prompt cache TTL
- Requests every few minutes, steadily: the default on either vendor. Anthropic's own advice: if you send a prompt "more often than every 5 minutes, continue to use the 5-minute cache".
- A person in the loop (a coding agent, a chat with a reviewer): on Claude, set ttl to 1h. One coffee break pays for it.
- Batch jobs that run every few hours on OpenAI: the 12h option helps only if they run more than once inside the 12 hours after the write.
- Jobs spaced further apart than the longest TTL: turn caching off for that prefix. On GPT-5.6 and later that means explicit mode with no breakpoints, which the guide says "does not use prompt caching or create cache writes."
- Whatever you pick, log the cache read and write token counts per request. The model above is only as good as your real gap distribution.
Open-weights models are joining in too: Amazon's Bedrock card for Ergo lists a cache write with a 30-minute TTL at 1.25x input, the same shape as OpenAI's default.
The catch: these TTLs are not quite what they say
My model treats each TTL as exact. Neither vendor promises that. OpenAI says entries may live longer than the minimum, and also that the minimum "governs eligibility for cache-read pricing. It does not guarantee that every request reuses stored KV tensors or has lower latency." Anthropic's FAQ says prefixes expire "after a minimum of 5 minutes of inactivity" and that Batch API hits are "best-effort". Neither publishes hit rates. Real bills will sit somewhere around the model, not on it.
- Claude's automatic caching is not available on Amazon Bedrock's bedrock-runtime, and Bedrock's timing rules live in AWS's docs, not Anthropic's.
- OpenAI's 12h option is documented for the Responses API only. The guide does not spell out Chat Completions.
- Caches are isolated per organisation on both, per workspace on the Claude API, and per processing region on OpenAI. Two services in two regions do not share a cache.
- None of this was measured against a live API. The numbers are list prices through a simulator, not a bill.
Questions people are asking
What is the Claude prompt caching TTL?
Claude's prompt cache lives 5 minutes by default, and each cache hit restarts the 5 minutes at no extra cost. You can set "ttl": "1h" in cache_control for a 1-hour lifetime, which costs 2x the input price to write instead of 1.25x. The timer is measured from the start of each request, not the end of the response.
What is the OpenAI prompt caching TTL?
On GPT-5.6 and later, the default is a minimum of 30 minutes, and the Responses API offers a 12-hour minimum through prompt_cache_options.ttl. Writes cost 1.25x or 2.5x the input price. Older models have no write fee and use prompt_cache_retention, with in_memory lasting typically 5 to 10 minutes, or 24h.
Is prompt caching automatic?
On OpenAI, yes: prompt caching is enabled by default for supported models, with an implicit breakpoint at the end of the latest message. On the Claude Messages API, no: you opt in with a cache_control field, either once at the top level or on up to 4 content blocks. Gemini caches implicitly on 2.5 and newer models.
Does prompt caching reduce cost?
Only when requests reuse the prefix before it expires. Reads cost 2.5 to 10 percent of the input price, but writes cost 125 percent or more. If every request arrives after the TTL, you pay the write premium every time and caching costs more than sending the prompt uncached, 25 percent more on the default settings.
Is the Claude 1-hour cache worth it?
Yes, if your requests ever pause for more than 5 minutes but less than an hour. The 1-hour write costs 2x the input price against 1.25x, and it pays for itself once it saves 0.625 cache misses, so one such pause covers it. For a prompt sent more often than every 5 minutes, keep the default.
Does a cache hit refresh the TTL?
On Claude, yes, for both the 5-minute and 1-hour caches. On OpenAI, a hit on a 30-minute entry extends it to at least 30 minutes after the read. A hit on a 12-hour entry does not restart the 12 hours: it only guarantees 30 minutes after the read, or the original expiry if that is later.
How do I check if prompt caching is working?
Read the usage block on each response. On Claude, cache_read_input_tokens counts hits and cache_creation_input_tokens counts writes. On OpenAI, input_tokens_details.cached_tokens counts billed reads and cache_write_tokens counts writes. If reads stay at zero, your prefix is changing between requests, is below the minimum length, or the cache expired.
- Prompt caching, Anthropic, Claude Platform docs
- Pricing, Anthropic, Claude Platform docs
- Prompt caching, OpenAI API docs
- Pricing, OpenAI API docs
- Context caching, Google AI Studio docs
- Claude 5-minute prompt cache vs GPT 30-minute cache: the cost of pauses, Requesty
More Posts
Next.js 16.5 compiles 4.2x faster. This blog got 1.35x
Next.js 16.5 on a 92-page static site with 2 cores: cold Turbopack compile went from 7.0 s to 5.2 s with 21% less memory. Not 4x. Warm builds didn't move.
I made a post-quantum SSH key. GitHub never answered it
A post-quantum SSH key is one ssh-keygen command in OpenSSH 10.6. GitHub, GitLab, Bitbucket, Codeberg and sourcehut can't use it, and GitHub just hangs.
I painted over a 4-digit code and read it back from the pixels outside the box
Can you unredact an image? From lossy WebP, yes: I got a hidden 4-digit code back from pixels 96 px outside the box. JPEG with a 16 px margin leaked nothing.