Claude 的 5 分钟计时器占你编码账单的 23%
Claude's 5-minute timer is 23% of your coding bill

原始链接: https://www.requesty.ai/blog/claude-5-minute-prompt-cache

在30天的编码代理流量中,23.1%的Claude账单与9.3%的GPT账单用于重建过期的prompt缓存。主要原因是默认TTL:Claude为5分钟,而GPT为30分钟,尽管缓存倍率相同。在超过30分钟的中断上,损失趋同(7.8% vs 8.5%),但5–30分钟的中断使Claude损失15.2%,而GPT仅0.8%。一次8分钟暂停可将Opus 5.5上0.04美元的缓存读取变成1.05美元的写入,且81%的暂停都会发生这种情况。回放显示,30分钟默认值可将Claude损失降至8.7%,与GPT相当。相等的每token价格造成非常不同的暂停成本:Sonnet与GPT-6.1 Sol的单次未命中损失相似,但Sonnet在短暂停中断中的未命中率为81%,而GPT为2.3%。有效修复包括自适应保活ping(`max_tokens: 0`),净节省8–9%,或在暂停后冷切换到1小时缓存;全面升级或会话中途的1小时升级可能花费更多。建议:审计300秒后继续的回合中的缓存未命中,在更深的主线程上添加保活ping,并将缓存TTL视为预算科目。

Hacker News 的一个帖子讨论了一篇文章,称 Claude 的 5 分钟提示缓存 TTL 占编程账单的 23%。评论者指出默认缓存时长:Anthropic 为 5 分钟,OpenAI 为 30 分钟,还有更长选项(Claude 为 1 小时,成本 2 倍;OpenAI 为 12 小时,成本 2.5 倍)。23% 的数字假设每次请求之间离开超过 5 分钟。订阅用户不受影响;API/Vertex 用户默认为 5 分钟。缓存时长各不相同且并不总是公布,因此建议测量使用情况。有人建议使用本地模型,它可以将 KV 缓存持久化到磁盘。其他人批评这篇文章是 AI 写的且夸大,称核心观点几句话就能说清。DeepSeek 等替代方案被引用为便宜得多。总体而言,当空闲间隔超过 TTL 时,缓存未命中主导成本,用户应监控或延长缓存窗口。
相关文章

原文

Across 30 days of coding-agent traffic (October 24 to November 22, 2026), 23.1% of the total Claude bill across Claude Code, OpenCode, Codex, Pi, and Kilo went to rebuilding prompt caches that had expired while the developer was away. On GPT models across the same tools and window, the figure was 9.3%.

On breaks longer than 30 minutes, both families lose roughly the same share of the bill (7.8% on Claude, 8.5% on GPT), because both caches are gone. On breaks between 5 and 30 minutes, Claude loses 15.2% of the bill and GPT loses 0.8%. One 8-minute break on a 210,000-token Claude Opus 5.5 session turns a $0.04 cache read into a $1.05 cache write at Anthropic's list price, and that happens on 81% of Opus 5.5 pauses in that window.

Both labs charge the same per-token cache multipliers on their current models. The split comes from the default TTL:

Claude Opus 5.5 / Sonnet 5.5GPT-6.1 Sol
Cache read0.05x input0.05x input
Cache write (default)1.25x input1.25x input
Default TTL5 minutes30 minutes (minimum)
Longer TTL option1 hour at 2.0x write12 hours at 2.5x write (Responses API)
Read refreshes the timerYesYes

The one line missing from every pricing table

To see why a timer changes the economics of a coding agent, look at how a single session runs. On turn one, the agent sends the system prompt, tool definitions, and your first message. On turn twenty, it sends all of that again plus nineteen turns of tool outputs and diffs. Without prompt caching, every turn pays full input price on the entire growing prefix. With caching, you pay 1.25x once to write new tokens into cache, and 0.05x to read the cached prefix on every subsequent turn. In production, that brings Claude coding bills down to 16.7% of list price (83% saved).

While the agent is looping on its own (running tests and editing files), requests arrive every few seconds. Each cache read resets the timer on both providers, so the prefix stays warm and you pay 0.05x over and over.

The bill jumps when the agent stops and waits for you. If you read a diff or grab coffee for 8 minutes, Claude's 5-minute TTL expires and the next turn pays 1.25x across the entire conversation prefix, 25x what a warm read would have cost. GPT-6.1 Sol (which bills the same 1.25x write fee on GPT-5.6 and later, unlike GPT-5.5 and earlier) still has 22 minutes left on its clock and serves the read at 0.05x. Most coding tools never opt into Claude's 1-hour option at 2.0x writes: across our 30-day window, OpenCode sent 0% of large Claude writes at 1 hour, and Claude Code used 1 hour on 2% to 10% across most routes.

A cliff at 5 minutes versus a cliff at 30

Measure how often a continuing turn reads at least 90% of the prior prompt from cache, plot it against the time elapsed since the last request, and the two providers draw two different cliffs.

Line chart of cache full-hit rate by minutes since the previous request. Claude routes on Anthropic API, Vertex and Bedrock drop from about 98% to under 7% just after 5 minutes; GPT-6.1 Sol on Azure holds about 96% until 27 minutes and falls to 1.9% by 31 minutes.

On the Anthropic API, the full-hit rate sits at 98.4% between 4:45 and 5:00, then falls off a ledge to 6.5% at 5:15 to 5:30. Vertex mirrors it (92.2% down to 5.0%). GPT-6.1 Sol on Azure holds 95.8% all the way to 27 to 29 minutes, hits 52.5% across minutes 29 to 31, and drops to 1.9% by 31 to 33 minutes, matching OpenAI's documented 30-minute floor.

Bedrock runs the same 5-minute TTL on a slightly friendlier clock. Measured start-to-start, Bedrock's hit rate only falls to 54.6% at minute five. Measured from the end of the previous response to the start of the next request, it drops cleanly from 91.3% at 4:45 to 5:00 to 2.5% at 5:00 to 5:15. Anthropic and Vertex start the clock when a request begins (so slow reasoning turns eat into your 5 minutes, and turns running past 5 minutes expire their own cache, 0.19% of input spend today).

We checked both sides live with random prompts on fresh sessions. After a 12-minute pause, GPT-6.1 Sol read the entire prefix on both OpenAI direct and Azure Sweden Central, then missed at 40 minutes. After 12 to 13.5 minutes, every Claude route we tested (Anthropic API, Bedrock, and Vertex) had evicted the cache and billed a full rewrite.

Could the gap in coding bills still come from different developer behavior or different coding tools? No. Main-agent pauses over 5 minutes happen at the same rate across session lengths on both families:

Session lengthPauses over 5 min per session (Claude)Pauses over 5 min per session (GPT)
15 to 60 minutes1.11.1
1 to 4 hours3.33.3
4 to 24 hours5.95.9
Over 24 hours13.913.2

Restrict the comparison to a single tool with persistent conversation IDs on both families (OpenCode), and the result gets even cleaner: pause rebuilds took 30.6% of the Claude bill versus 11.3% on GPT. On breaks over 30 minutes, OpenCode lost the exact same share on both models (3.7% for 30 to 60 minutes, 6.7% past an hour). The difference came entirely from 5 to 30 minute pauses: 20.2% on Claude, 0.9% on GPT.

Minutes five through ten cost more than overnight breaks

Most engineers assume the big cache misses happen when you close your laptop overnight and resume a thread the next morning. The production data says the opposite.

Away forClaude miss rateClaude share of bill lostGPT miss rateGPT share of bill lost
5 to 10 min77%8.0%4%0.4%
10 to 15 min81%3.5%4%0.2%
15 to 30 min81%3.8%6%0.2%
30 to 60 min82%2.6%94%3.5%
1 to 6 hours87%2.8%96%2.8%
6 to 24 hours88%1.5%98%1.4%
Over 24 hours87%0.9%96%0.7%
Total (over 5 min)23.1%9.3%
Bar chart of the share of coding bill lost by break length. Claude loses 8.0% in 5 to 10 minute breaks against 0.4% on GPT; from 5 to 30 minutes Claude loses 15.2% against 0.8%, while breaks over 30 minutes cost both families about the same.

On Claude, pauses between 5 and 10 minutes eat 8.0% of the entire coding bill. That single five-minute slice costs more than every break over an hour combined (5.3%). Nearly half of all Claude pause losses happen within 15 minutes of the last message, and two-thirds happen within 30 minutes (15.2% of the bill, against 0.8% on GPT). Once a break passes 30 minutes, both caches are gone and the two curves converge: 7.8% on Claude, 8.5% on GPT.

Replay each family's real sessions under different cache lifetimes (holding prompts, gaps, and read multipliers fixed, assuming a 1.25x rebuild whenever a gap exceeds the TTL), and the two families collapse onto the same line:

Sessions5-min cache10-min cache15-min cache30-min cache60-min cache
Claude coding sessions27.5%17.1%13.1%8.7%5.7%
GPT coding sessions35.6%20.7%14.9%8.7%5.0%
Line chart of modelled share of bill lost by cache TTL. At 5 minutes Claude sessions lose 27.5% and GPT sessions 35.6%; both converge at 8.7% with a 30 minute TTL.

With a 30-minute default, Claude sessions lose 8.7%, identical to GPT's 8.7% (and about 14% below Claude's measured 23.1%). Put GPT on a 5-minute cache and its loss jumps to 35.6%, because input tokens are a bigger share of GPT coding bills. (Because this is a replay that assumes every turn past the TTL misses and ignores the small share already on 1-hour writes, its 5-minute Claude estimate of 27.5% sits above the measured 23.1%.)

This pattern holds across nearly every team in the dataset. Among active coding organizations ($100+ monthly spend), the median Claude team loses 23.3% of its bill to pauses (IQR 11.1% to 29.4%, p90 34.7%), versus 7.8% on GPT (IQR 3.1% to 14.2%). Restrict it to 5 to 30 minute pauses, and ~85% of Claude teams lose more than 5% of their bill, while 0% of GPT teams do.

Two models at $2 per million tokens, 34x apart on a coffee break

On Claude Opus 5.5, a single 5 to 30 minute pause misses 81% of the time on a median prompt of 207,000 tokens. One miss adds $1.06 in write cost ($3.09 at p90), making the expected cost of every 5 to 30 minute break $0.86.

Opus 5.5 sits at a higher list price than GPT-6.1 Sol, so to keep input and output pricing matched, compare Claude Sonnet 5.5 against GPT-6.1 Sol. Both list at $2 per million input tokens and $10 per million output tokens direct, both bill 1.25x to write and 0.05x to read, and both reach roughly 140,000 tokens at a pause miss:

Model (5 to 30 min pauses)Direct input / outputMiss rateMedian prompt at missMedian loss per missExpected cost per pause
Claude Opus 5.5$4 / $20 per MTok81.0%207K tokens$1.06$0.86
Claude Sonnet 5.5$2 / $10 per MTok81.2%140K tokens$0.35$0.28
GPT-6.1 Sol$2 / $10 per MTok2.3%142K tokens$0.37$0.008
Horizontal bar chart of expected cost of a 5 to 30 minute pause by model: Claude Opus 5.5 $0.86, Claude Sonnet 5.5 $0.28, GPT-6.1 Sol $0.008, a 34x gap between Sonnet 5.5 and GPT-6.1 Sol at the same $2 / $10 price.

Look at the last two rows. When a miss happens, the dollar damage is virtually identical ($0.35 on Sonnet 5.5, $0.37 on GPT-6.1 Sol). The difference is frequency: Sonnet 5.5 misses 81.2% of 5 to 30 minute breaks while GPT-6.1 Sol misses 2.3%, turning an identical price sheet into $0.28 per break versus $0.008 (less than a penny, a 34x gap).

Stretch that across a 20-workday month. Our assumption: a developer pauses four times a day for 5 to 30 minutes (20 breaks per week, 80 per month, consistent with the 3.3 to 5.9 pauses over 5 minutes measured in 1 to 24 hour sessions). That adds ~$5.70 a week (~$23 a month) per seat on Sonnet 5.5 against ~$0.17 a week (~$0.66 a month) on GPT-6.1 Sol. On Opus 5.5, the same four short breaks a day cost ~$17 a week (~$69 a month per developer, or ~$1,380 a month across a 20-person engineering team). Cut the break rate in half to two a day and an Opus 5.5 team of 20 still pays ~$690 a month just for breaks under half an hour.

One reason teams miss this on day one is where the waste concentrates. Under 15 minutes, median pause loss is 0% on both families, and 76% of all Claude coding conversations finish inside 5 minutes. Conversations running past an hour carry ~80% of total spend, and that is where the timer compounds:

Session lengthClaude median (p25 to p75)GPT median (p25 to p75)Claude weightedGPT weighted
15 to 60 min2.4% (0% to 20.5%)0.0% (0% to 0%)8.2%1.8%
1 to 4 hours17.9% (5.9% to 30.1%)4.3% (0% to 18.5%)16.9%7.2%
4 to 24 hours22.4% (11.1% to 34.2%)12.0% (5.0% to 23.6%)22.1%10.7%
Over 24 hours27.7% (14.9% to 40.8%)18.8% (8.7% to 29.8%)34.0%20.9%
Chart of share of session bill lost by session length. Claude median rises from 2.4% in 15 to 60 minute sessions to 27.7% in sessions over 24 hours; GPT rises from 0% to 18.8%.

Expressed against a perfect warm cache that never expires on pauses (1 / (1 - share lost)), Claude's 23.1% loss means you pay 1.30x the warm-cache bill across coding traffic, while GPT's 9.3% loss puts it at 1.10x.

What worked when we tried to fix it

We tested five fixes on live Claude endpoints (Anthropic API, Bedrock, and Vertex across Haiku, Sonnet, and Opus 5.5) and replayed them across 30 days of coding traffic in two simulators and a cohort replay:

FixNet saving on Claude coding billMain catch
Adaptive keep-alive pings (max_tokens: 0)~8% to 9% net (12% to 14% gross)Holds last request in memory; max_tokens: 0 API limits
2 fixed pings on every idle main turn~7% to 9% netWastes pings on short threads
Cold switch to 1h after first pause (turn >= 10)~5% to 7% netWaits for one miss first
Blanket 1h from turn 1+1% to +10% (model-dependent)87% to 89% of sessions pay more
Mid-session switch to 1h on warm cache~0% (Anthropic API and Vertex)Rewrites the entire prompt at 2.0x (live-tested)
Range chart of net Claude coding bill savings across five fixes: adaptive keep-alive pings 8.1% to 9.0%, 2 fixed pings 6.9% to 9.5%, cold switch to 1 hour 5.2% to 6.7%, blanket 1 hour 1.4% to 9.7%, mid-session switch on a warm cache about 0%.

The 1-hour cache has two catches. Turning it on from turn 1 charges 2.0x (an extra 0.75x) on every write, so 87% to 89% of sessions end up paying more. Switching a warm 5-minute conversation to 1 hour mid-session backfires even harder: in live runs on Anthropic API (Haiku, Sonnet, and Opus 5.5) and single-region Vertex (europe-west1), sending a new turn with 1-hour markers against a warm 5-minute cache read 0 tokens and rewrote the entire prompt at 2.0x. On Anthropic API and Vertex, a 1-hour write can only extend a 1-hour entry (an exact repeat reads 5m without creating a 1h entry; AWS Bedrock was an undocumented exception in 4 of 4 runs, reading the 5m prefix and surviving 12 minutes). If you want 1-hour caching without the upfront tax, switch cold on the first turn after a 5-minute pause (~5% to 7% net), or put static tools and system prompts on 1 hour and messages on 5 minutes from turn 1 (1-hour markers must precede 5-minute ones, or you get HTTP 400).

Bar chart of a live test switching a warm 5 minute cache to 1 hour. Anthropic API and Vertex read 0 tokens and rewrite about 28,000 tokens at 2.0x; Bedrock reads 23,194 tokens and writes only the 5,178 token new turn.

Adaptive keep-alive pings beat every 1-hour option. After 4.5 minutes idle, re-send the exact last request body with max_tokens: 0 (removing stream: true) to the same provider, region, and credentials:

def keep_alive(client, last_request: dict):
    # Keep model, system, tools, messages, thinking, and effort identical.
    body = {**last_request, "max_tokens": 0}
    body.pop("stream", None)  # stream: true is rejected with max_tokens: 0
    return client.messages.create(**body)

Live runs on Anthropic API (Opus 5.5), Bedrock (eu-central-1, Opus 5.5), Vertex (europe-west1, Sonnet 4.6), and with tool schemas attached all confirmed 0 output tokens, 100% prefix reads, and warm survival past 13.5 minutes (count_tokens does not refresh the cache). A ping pays off whenever return odds beat read / (write - read), which is 4.2% on Opus 5.5 and Sonnet 5.5 (8.7% on 0.10x models; 2.0% on Fable 5.2). Because production return probability rises from 2.7% on turns 1 to 5 to 10.7% on turns 6 to 10, 15.9% on turns 11 to 20, 19.5% on turns 21 to 40, 24.2% on turns 41 to 100, and 30.8% past turn 100 (halving roughly per ping), capping pings by turn depth (0 early, 2 to 6 on deeper threads, including after tool calls) cuts ~8% to 9% net off the Claude coding bill, closing over half of the 14-point gap to GPT.

Line chart of the chance a developer returns before the next expiry for pings 1 to 6, by turn depth, against break-even lines at 8.7%, 4.2% and 2.0%. Threads past turn 100 stay above the 4.2% break-even through ping 6.

Three limits to keep in mind. Anthropic documents that max_tokens: 0 is rejected with thinking.type: "enabled", structured outputs (output_config.format), forced tool_choice, and Message Batches (and altering thinking settings changes the cache key, so those requests need cold-switching or turn-1 1-hour caching). Your harness must store the last request body for up to ~30 minutes. And terminal pings after a developer stops working go unused: in our replay, 43% to 52% of long sessions spent more in pings than they saved individually, even while aggregate coding spend fell 8% to 9%.

How we measured

We analyzed 30 days (October 24 to November 22, 2026) of production coding traffic across Claude Code, OpenCode, Codex, Pi, and Kilo on Anthropic API, Bedrock, Vertex, OpenAI, and Azure using token and billing counters only (no prompt text). A pause miss is a continuing turn after a gap over 5 minutes that reads under 10% of the prior prompt from cache, priced strictly at the avoidable write-minus-read cost; swaps and fixes are replays on those sessions, and live checks used fresh random prompts per run.

So what?

Stop benchmarking coding models on per-token price sheets alone. Pull your own usage logs this afternoon and count every continuing turn past 300 seconds where cache_read_input_tokens drops near zero and cache_creation_input_tokens spikes to full prompt size; that number is your pause bill.

If you build a coding agent, leave short runs and subagents on 5 minutes and add a turn-depth max_tokens: 0 keep-alive schedule on main threads past turn 5 (or, where max_tokens: 0 is unsupported or state cannot be held, switch cold to 1 hour on the first turn after a 5-minute miss, and never upgrade a warm 5-minute cache mid-session on Anthropic API or Vertex). If you are evaluating models for a team, test them across real multi-hour workdays with human breaks, because a 5-minute clock turns equal sticker prices into very different monthly bills.

The cleanest fix sits upstream with the model providers: publish default cache TTL right beside input and output rates, move the default closer to how long engineers spend reading a diff, or allow a 1-hour write to extend a warm 5-minute entry instead of rebuilding it at 2.0x. Until then, treat cache lifetime as a first-class line item in every coding-agent budget.

联系我们 contact @ memedata.com