I find it really weird that Anthropic uses only a five minute cache on the API. Even in the course of active work, many commands—compiling, running tests, etc—take longer than five minutes to complete.
I of course don't know what it costs Anthropic to keep the cache warm—but since their subscription plans use one hour, Anthropic must have concluded a longer cache is more economical for most users. And there's a big difference between one hour and five minutes.
Aurornis 49 minutes ago [-]
> I find it really weird that Anthropic uses only a five minute cache on the API.
You can set 5 minute or 1 hour with API requests. It's the user's choice, not something they force on you. You get the cheapest option (5 minutes) if you don't specify the time.
> You get the cheapest option (5 minutes) if you don't specify the time.
Okay, but isn't it weird that the default is a giant footgun?
Aurornis 43 minutes ago [-]
The API is used for a lot more than agentic coding. I would not be surprised if 5 minute was preferred on average across all types of usage.
If Anthropic set it to the more expensive option by default, we'd be reading articles about people complaining how evil they were for defaulting to the more expensive option.
gobdovan 23 minutes ago [-]
yeah, not sure why you're downvoted, but the API is clearly for using Claude in your products that you serve to your users. It's also why it's priced higher since it's assumed to be close to where you make money. It's the same with cloud computing, where clouds could charge 1000x the involved compute for some per-access DB, but you wouldn't run a nuclear reactor simulation on Firebase.
anakaine 15 minutes ago [-]
> you wouldn't run a nuclear reactor simulation on Firebase.
I mean... you say I wouldn't, but im all up for trying.
Loquebantur 41 minutes ago [-]
It's what their business model tells them to do: maximize profit per token.
Making you spend tokens without noticing it is a free meal to them.
There are various other possibilities to clandestinely extract tokens from you. People just haven't thought about it yet.
2001zhaozhao 22 minutes ago [-]
> footgun
What a load-bearing observation. Good instinct!
PaulKeeble 44 minutes ago [-]
Deepseek seemingly stores the cache for literally days, so its a really odd choice to have it so short.
speedping 36 minutes ago [-]
Latest deepseek kv cache is tiny compared to other models thanks to its architecture, so storing it requires much less space
minraws 15 minutes ago [-]
It's also less vram and hence bandwidth hungry so much friendlier to hold for longer and swapping in and out to storage. If kv cache is large enough and slow enough, then prefill could turn out to be faster than cache restore... Although it depends on how the cluster and infra is setup, either way, Anthropic is subsidizing the subscriptions if all benefits and limits and etc. are included by at least 2 orders of magnitude aka ~100x compared to API which is rather insane..
It's surprising, and also not really surprising that they then charge enterprises and companies with over 100/150 employees full API prices with some bulk discounts.
I have seen a bill for a small 100+ person company for their tokens and it's insane when you compare it to how many tokens I burn in a week.
I waste more tokens on chasing useless stuff over a couple weeks, then their entire company spends in an entire month tbh that might include resets but this is madness, I am not sure if the music will stop but if it does I don't feel like I nor my current employer will be paying the full price for the tokens.
gleenn 30 minutes ago [-]
If the KV cache is in RAM (whether system or GPU) it's because RAM is at a huge $$$ premium right now.
auspiv 21 minutes ago [-]
it takes claude 15-30 min to add a disk layer cache after system memory FYI... have this going on my 8x v100 server for all openweight models I'm running. currently preferring glm-5.3-flash. prefill is around 3k tok/s, decode is about 80 tok/s. have room for 3x 262k sessions with room to spare. and memory for another million. then a 6.4TB NVMe for quite a bit more.
deepseek-v4.1-flash per token kv is IIRC 600-700 bytes. this is much, much less than other models. and 500x less than deepseek v3.
Majromax 60 minutes ago [-]
Since the API is bare, the use cases will be broader than just agent sessions -- automated scripting and customer-served chatbotting are two obvious supplemental use-cases. Those are likely to have very different cache dynamics compared to a Claude Code session, so 5m expiry might be the hit-rate-optimizing point.
iaaan 1 hours ago [-]
Interesting that you'd conclude Anthropic is looking out for the economic interests of their customers over their own.
vineyardmike 60 minutes ago [-]
They are for subscription plans, where they pay by token and the user pays a fixed cost.
Subscription plans best align the user’s interest with the company’s interest. Presumably, the user’s goal is not token burn but some underlying task. The cheaper the company can accomplish that task, the more money the company keeps. If the user has to constantly retry because the model is bad, that’s more cost to the provider. If the model is big and slow and wastes tokens, that’s more cost to the provider. The more tasks that can be accomplished in the fixed quota, the better value perception by the user.
bee_rider 56 minutes ago [-]
It seems like what would best align the interests of the customer and company would be if they’d charge by completed task instead of… tokens/time. (Why are these internal compute metrics being exposed to the customers?).
dotancohen 52 minutes ago [-]
For the same reason cars are sold with fuel gauges and people ask how many liters of gas they need to go 100 km.
It's a useful metric, especially for those who know what it means.
Loquebantur 54 minutes ago [-]
That's not true.
It's rather an equilibrium based on what they can get away with.
It's safe to say, that equilibrium is a safe distance from what's in the users interest.
Wowfunhappy 55 minutes ago [-]
The amount Anthropic can charge per token is determined by how much value users get from those tokens. If users are getting more value, Anthropic can charge more and take a bigger profit.
Which means it is in Anthropic's interest to set cache lifetimes at a number that will let users get the most value from their tokens, relative to whatever it costs Anthropic to maintain the cache.
Capricorn2481 43 minutes ago [-]
Does the average user even know what value they are getting from Anthropic? As though there is some kind of metric?
I don't think value is some immediately obvious and observable phenomenon. The average person doesn't even know what prompt caching is. It's completely feasible for them to set defaults that overcharge customers without them knowing.
10111001 35 minutes ago [-]
> The amount Anthropic can charge per token is determined by how much value users get from those tokens. If users are getting more value, Anthropic can charge more and take a bigger profit.
I feel like statements like that, looked at most charitably, benefit from the confusion between some technical definition of "value" and a a more colloquial definition.
The easiest way to interpret that is: "what's good for you is good for Anthropic, so trust Anthropic," but that's almost never what's going on when you're dealing with a sophisticated business. In all market interactions, "value" is relative and everything is almost always obscured by intense information asymmetries. The business wants to maximize profit for itself, which often entails minimizing the value provided to customers (because more "value" usually costs something) and maximizing the price they pay for it.
Loquebantur 45 minutes ago [-]
The interest of any provider of proprietary inference is to make the most money per token.
Users don't have such a precise metric that would allow them to discriminate value per token reliably. Or have you never seen those comparison sites, with dozens of different scales?
If they can make you reload your cache statistically more often without you noticing (increasing their profits), their business model mandates them doing so.
dpz 44 minutes ago [-]
From their side as well it's preferable for uses to hit the cache. Definitely cheaper for them too
traviswingo 1 hours ago [-]
I regularly favor the economic interests of my customers over my own.
I’m also not running a multi billion or trillion dollar company, and probably never will if I keep doing it.
I’m okay with that.
Loquebantur 56 minutes ago [-]
There are many such open questions about "clandestine token-maxing" that get glossed over.
For any provider of proprietary inference, the targeted optimization of how (long) their models work according to their own goals is a central part of their business.
People believe those optimizations being about giving them the "best" inference. They fail to notice whose "best".
cavemandaveman 1 hours ago [-]
It's a competitive market, is it not? If they don't, they'll lose market share to Google or OpenAI
eli 58 minutes ago [-]
They probably do around the edges. But I bet they'd lose more if they raised the list price per token and included a longer cache time by default even if it the average bill works out the same.
xenoci 32 minutes ago [-]
[dead]
michaelmrose 31 minutes ago [-]
[dead]
compiler-guy 1 hours ago [-]
Everything old is new again. Something similar was a time honored technique for getting an OS scheduler to keep a long-running task at interactive priority by writing a character to the console every so often, so it looked like an interactive process.
How to defeat these countermeasures used to be covered in os courses. I suspect the llm vendors will adopt similar techniques.
On a subscription plan (not API requests) Claude Code defaults to 1-hour cache duration for the main conversation and 5 minutes for subagents.
So if you're not paying API rates, you need not worry. You can force the main conversation or subagents to either 5 minute or 1 hour in the Claude settings file if you would like.
If you are paying API rates, paying close attention to caching is important. 1 hour is best for sessions where you have to think a lot, examine output, or wait for long builds because 5 minute interruptions are very common. The price premium for 1-hour TTL isn't that high over 5-minute, so I use it by default.
It's also good to get in the habit of doing /compact when you know you might be AFK for more than the cache TTL. Doing the /compact on a long context conversation after the cache has expired is much more expensive.
giancarlostoro 31 minutes ago [-]
> and 5 minutes for subagents.
Ah, this explains so much, I need to adjust my settings. Lately I've been using bigger models to drive smaller models to do changes, sometimes they run for 45 minutes or more, so I definitely need to tweak my subagent cache time window. I'm not on API billing, but still.
ffsm8 32 minutes ago [-]
Claude code actually compacts the main session just before the cache runs out automatically.
No idea when they added that, Its gray text that looks exactly like the auto summary line, so easy to miss (as it only shows up when you're idle for 55 minutes or so, and have a session that's compact worthy - again no idea what threshold they use)
skerit 30 minutes ago [-]
That is indeed a setting that is in by default now, though I've noticed in some session that it doesn't trigger and I have no idea why
whatifitoldyou 1 hours ago [-]
Is there a pi plugin for resetting the keepalive? Sounds simple enough. From the article:
What is a keep-alive ping for prompt caching?
-
You send the last request again with max_tokens set to 0 about every 4.5 minutes. The API reads the cached prefix, returns no output tokens and restarts the cache timer. In our replay, keep-alive pings capped by session depth cut a Claude coding bill by about 8 to 9% net.
"hey claude make a plugin for our api proxy that removes 1hr cache requests" and sends keepalives like this ^^^
lol if this works there is no way they are gonna let you keep getting away with it
Aurornis 52 minutes ago [-]
You pay for the cache reads. It's not a loophole.
8cvor6j844qw_d6 2 hours ago [-]
If I'm not mistaken, on subscription plans your main agent defaults to 1 hour cache with subagents spawned by the main session on 5 minute cache timer.
Best ensure your subagents avoid getting blocked if there's any wait or command that takes more than 5 minute.
staticshock 2 hours ago [-]
Yeah, this looks like a discussion of API traffic, not claude code subscription traffic. I'd be shocked to find out that my claude code sessions, which auto-compact "before the cache expires", after 54 minutes of idle time, due to claude code's own idleCompaction setting, was actually already expired at that point.
viccis 1 hours ago [-]
You can also spawn subagents with 1h TTLs if you know they'll be doing activity with lots of time spent waiting
jondwillis 1 hours ago [-]
Welp, doing this immediately. I had to build a Rust build queue and a client lease system for a game I have been building entirely with agents (intentionally with a lot of subagents and multiple top-level sessions) just to avoid consuming all available memory and compute on a server I have laying around. I have a lot of subagents that end up having to wait for a long time for their turn to build and run the game to verify behavior.
bigmadshoe 1 hours ago [-]
Do those tokens cost more? Why would anyone choose the shorter cache?
viccis 38 minutes ago [-]
They cost 2x as much
Ask your agent to look at its own usage metrics to see if you would have saved money by doing so. If your test suite is >5 mins then you likely will.
Bolwin 1 hours ago [-]
Probably takes more usage though, so it's the same deal
bensyverson 2 hours ago [-]
Isn't Claude Code on a 1hr cache?
qwertox 57 minutes ago [-]
On the subscription plan it is 1h for the main agent, its subagents get 5m with some exceptions that also get 1h.
API is all 5m but apparently keeping it warm every 4.5 mins on API is fine.
This is what i heard.
extr 2 hours ago [-]
It's not Claude Code so much as provider. If you're on a subscription plan this article doesn't apply to you. If you're using Vertex API or similar it defaults to 5m.
shahbaby 2 hours ago [-]
It applies on a subscription too. Not using the cache burns your usage faster.
jadar 2 hours ago [-]
Yes but the cache on subscription plans is 1hr
FiReaNG3L 2 hours ago [-]
Not for subagents it isnt, 5 minutes for them
extr 36 minutes ago [-]
Okay and? The article is not about subagents, and subagents are a natural fit for the shorter cache window.
wahnfrieden 1 hours ago [-]
For some context, on Codex subscriptions, the cache is forever
andai 57 minutes ago [-]
I guess that refers to cache pricing? (Surely after some time the tokens are no longer cached, but you mean they still charge you as though they were?) Either way, that's surprising.
theturtletalks 1 hours ago [-]
I also make it compact at 200K tokens and not 1M. Has anyone seen a benefit to using 1M context wth Fable?
andai 54 minutes ago [-]
Several studies have found that performance degrades sharply after 100k tokens or so, even in models with much larger contexts. (The further out you get the lossier the attention gets from what I understood.)
(Which is funny, because you pay a premium on many providers for the worse attention!)
The last study I found was from a little while ago though, and there's been a lot of development in attention mechanisms since then. So it might be less bad now.
nimchimpsky 1 hours ago [-]
[dead]
extr 2 hours ago [-]
This is obvious if you just put cache timeout in your statusline. If the nature of your work is such that every time you return to the window the 5m cache is expired, bump it up.
theanonymousone 2 hours ago [-]
Where can I find cache "duration" of different providers? I have never seen such information, despite it being a very big deal in cost estimation. Or maybe it's dynamic?
daemonologist 2 hours ago [-]
Not all providers publish it, and aren't always correct when they do. For some providers (e.g. DeepSeek, Antigravity Gemini) it is indeed dynamic/not guaranteed.
Bet bet is to measure it yourself by observing billing/credit usage or time-to-first-token.
It's not dynamic, in the sense pricing has rules, but, it is dynamic in the sense you won't always hit the cache.
Generally, by Googling "(provider) llm cache cost and duration" - can't recommend any source that collects them all.
Generally OpenAI and Anthropic are very serious about this and document it well.
Google is currently a shit show but getting better if you're on Interactions API.
The not-$1T crowd, i.e. other inference providers, can't and won't really guarantee anything.
OpenRouter shows data on their cache hit rates.
On not-$1T-crowd APIs, they'll want to set an arbitrary hint that they'll use for server affinity. (i.e. Fireworks needs to know this request wants to run on the same server/cluster/whatever as the last request so it can get a cache hit)
rishabhaiover 2 hours ago [-]
This is a big contributor to long-running sessions. I built a small CLI that opens in a tmux popup and shows what my Cursor agents cost: https://github.com/rishabhBudhouliya/tend.
It uses a ridgeline chart to show how big each chat's context has grown and what it's spending.
larodi 1 hours ago [-]
I've felt this long before and my agent's contexts are compacted very very often. Even though they work on a common bus, I try to keep them regularly pooled back to minimum.
superjan 2 hours ago [-]
What helps: run agents in a VM so they can have full control and don’t need to wait for your approval. Firewall it from your local network.
And start a new blank session with its own branch (and have the agent update the project readme) so you can restart without context.
sneak 2 hours ago [-]
Why firewall it from your local network?
kreyenborgi 11 minutes ago [-]
Many services have ports open, which could give access to things you dont want to share. E.g. if you run syncthing, there's full access to your synced folders if you have localhost access.
superjan 42 minutes ago [-]
As stated by others, it’s a precaution. It’s been shown that agents can get desperate and use whatever they can get their hands on to solve the problem at hand. I don’t want them snooping around the network for information, credentials or test data.
Edit: Not likely to happen currently but having this infra makes it easier to demonstrate compliance with your orgs rules.
ticulatedspline 2 hours ago [-]
isolation from your own agents hacking you.
It's a bit overkill for most users but depending on what you're asking it to work on it could theoretically traverse your local network to compromise devices/computers and escape the sandbox.
eptcyka 2 hours ago [-]
To not let the clanker own every computer on your local network?
refulgentis 2 hours ago [-]
These AI written articles are exhaustingly long, and the #s included make it feel very scientific but are one offs for one person.
It's self-labelled as a 15m read and a human in the loop should recognize it's about 3m, tops. Here:
LLM API context caches, by default, only last for 5 minutes on Anthropic and 30m on OpenAI.
If you use Claude, there's an hour cache for 2x the cost of the 5 minute one.
If you use OpenAI, there's a 12 hour cache for 2.5x the cost of the 30m one.
FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
gcr 2 hours ago [-]
There’s potential for a 12hr cache on OpenAI?? That’s so good! Thank you I didn’t know this, I’ll have to configure that
viccis 1 hours ago [-]
>FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
I did indeed run into this problem when I was steering 4 or 5 chats that would ask for feedback that took a few minutes to provide. Pretty soon you're juggling a bunch of 5 min timers if you don't want every single response to have to rebuild the cache.
vikramkr 2 hours ago [-]
Not even 3 min. Took like 3 seconds to skim the title and understand that it's about cache misses (and that Claude is probably presenting it in some inane incomprehensible technobabble so someone who isn't familiar with prompt caching's budget impact already is going to read the whole thing and still have zero idea wtf is going on)
cespare 2 hours ago [-]
Nice summary.
I could tell that this was AI-written just from the turn of phrase in the title before I even clicked :\
jmkni 1 hours ago [-]
Yep, KISS seems to have been thrown out the window in the age of AI
matkoniecz 58 minutes ago [-]
> FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
On subscription (so 1h cache) I run into this being even higher, reaching 50%, before I noticed problem.
Are they offering Opus 5.5 quality and quantity of 20$ Claude subscription at and 2$/month? Or 0.2$/month?
ggregoire 2 hours ago [-]
shhh don't share our secret
2 hours ago [-]
the_mitsuhiko 1 hours ago [-]
That's why pi has cache warming.
julianlam 2 hours ago [-]
Requisite smarmy comment about how this is not an issue with local models.
There's even the ability to persist your kv cache to disk, so future session resumptions load back into context instantly without needing to do a full prefill ingestion by the LLM. (CachyLLaMA, iirc, not sure where the project is now)
haolez 2 hours ago [-]
Up until a few weeks ago, I wouldn't say it (at least for my use case).
But now, with Bonsai 2.5 27B, this is the first time that I don't need Haiku (or a similar cheap model) for tasks in their scope. I think local models are close to an inflection point in usefulness.
Note: I don't have anything local remotely close to reasoning capabilities of SOTA models such as Opus/Neon/Astra.
Forgeties79 2 hours ago [-]
What do you use bonsai for? I haven’t really played with it yet
spillguard 57 minutes ago [-]
Requisite smarmy reply about how local models are still a subscription, NVIDIA just bills you for it up front
vikramkr 2 hours ago [-]
Neon really cooked with tamping down on the inane incomprehensible Claude slop huh? It's so damn annoying when they spew this poetic babbling gibberish.
TDLR prompts are cached. Prompt cache hit == $. Cache miss == $$$$$$$. Claude ttl is 5 min. Codex ttl is 30 min. If u take longer than 5 min between turns then $$$$
knollimar 27 minutes ago [-]
Are you saying this is neon? This one sounds like slop to me.
j45 2 hours ago [-]
It feels a little click baity to not include the word API in that title somewhere.
edwinarbus 1 hours ago [-]
Edwin from Anthropic here. Thanks for the thorough writeup. I will point out two things:
1. This looks like API-billed traffic only. Claude Code defaults to a 1 hour cache, not 5 min! So if you're within your plan's usage, this doesn't really apply [1].
2. In the API, we have 5 min and 1 hour TTL options. The "23%" here for the 5 min option includes breaks over 30 min, where both Claude's and GPT's default caches have expired and the loss is the ~same (7.8% vs. 8.5%). If you run long sessions with breaks, and are using an API key, you could set "ttl": "1h". There will be a bit higher write price, though [2].
I of course don't know what it costs Anthropic to keep the cache warm—but since their subscription plans use one hour, Anthropic must have concluded a longer cache is more economical for most users. And there's a big difference between one hour and five minutes.
You can set 5 minute or 1 hour with API requests. It's the user's choice, not something they force on you. You get the cheapest option (5 minutes) if you don't specify the time.
https://platform.claude.com/docs/en/build-with-claude/prompt...
Okay, but isn't it weird that the default is a giant footgun?
If Anthropic set it to the more expensive option by default, we'd be reading articles about people complaining how evil they were for defaulting to the more expensive option.
I mean... you say I wouldn't, but im all up for trying.
Making you spend tokens without noticing it is a free meal to them.
There are various other possibilities to clandestinely extract tokens from you. People just haven't thought about it yet.
What a load-bearing observation. Good instinct!
It's surprising, and also not really surprising that they then charge enterprises and companies with over 100/150 employees full API prices with some bulk discounts. I have seen a bill for a small 100+ person company for their tokens and it's insane when you compare it to how many tokens I burn in a week.
I waste more tokens on chasing useless stuff over a couple weeks, then their entire company spends in an entire month tbh that might include resets but this is madness, I am not sure if the music will stop but if it does I don't feel like I nor my current employer will be paying the full price for the tokens.
deepseek-v4.1-flash per token kv is IIRC 600-700 bytes. this is much, much less than other models. and 500x less than deepseek v3.
Subscription plans best align the user’s interest with the company’s interest. Presumably, the user’s goal is not token burn but some underlying task. The cheaper the company can accomplish that task, the more money the company keeps. If the user has to constantly retry because the model is bad, that’s more cost to the provider. If the model is big and slow and wastes tokens, that’s more cost to the provider. The more tasks that can be accomplished in the fixed quota, the better value perception by the user.
It's a useful metric, especially for those who know what it means.
It's rather an equilibrium based on what they can get away with.
It's safe to say, that equilibrium is a safe distance from what's in the users interest.
Which means it is in Anthropic's interest to set cache lifetimes at a number that will let users get the most value from their tokens, relative to whatever it costs Anthropic to maintain the cache.
I don't think value is some immediately obvious and observable phenomenon. The average person doesn't even know what prompt caching is. It's completely feasible for them to set defaults that overcharge customers without them knowing.
I feel like statements like that, looked at most charitably, benefit from the confusion between some technical definition of "value" and a a more colloquial definition.
The easiest way to interpret that is: "what's good for you is good for Anthropic, so trust Anthropic," but that's almost never what's going on when you're dealing with a sophisticated business. In all market interactions, "value" is relative and everything is almost always obscured by intense information asymmetries. The business wants to maximize profit for itself, which often entails minimizing the value provided to customers (because more "value" usually costs something) and maximizing the price they pay for it.
Users don't have such a precise metric that would allow them to discriminate value per token reliably. Or have you never seen those comparison sites, with dozens of different scales?
If they can make you reload your cache statistically more often without you noticing (increasing their profits), their business model mandates them doing so.
I’m also not running a multi billion or trillion dollar company, and probably never will if I keep doing it.
I’m okay with that.
For any provider of proprietary inference, the targeted optimization of how (long) their models work according to their own goals is a central part of their business.
People believe those optimizations being about giving them the "best" inference. They fail to notice whose "best".
How to defeat these countermeasures used to be covered in os courses. I suspect the llm vendors will adopt similar techniques.
https://algomaster.io/learn/operating-systems/multilevel-que...
So if you're not paying API rates, you need not worry. You can force the main conversation or subagents to either 5 minute or 1 hour in the Claude settings file if you would like.
If you are paying API rates, paying close attention to caching is important. 1 hour is best for sessions where you have to think a lot, examine output, or wait for long builds because 5 minute interruptions are very common. The price premium for 1-hour TTL isn't that high over 5-minute, so I use it by default.
It's also good to get in the habit of doing /compact when you know you might be AFK for more than the cache TTL. Doing the /compact on a long context conversation after the cache has expired is much more expensive.
Ah, this explains so much, I need to adjust my settings. Lately I've been using bigger models to drive smaller models to do changes, sometimes they run for 45 minutes or more, so I definitely need to tweak my subagent cache time window. I'm not on API billing, but still.
No idea when they added that, Its gray text that looks exactly like the auto summary line, so easy to miss (as it only shows up when you're idle for 55 minutes or so, and have a session that's compact worthy - again no idea what threshold they use)
What is a keep-alive ping for prompt caching? - You send the last request again with max_tokens set to 0 about every 4.5 minutes. The API reads the cached prefix, returns no output tokens and restarts the cache timer. In our replay, keep-alive pings capped by session depth cut a Claude coding bill by about 8 to 9% net.
lol if this works there is no way they are gonna let you keep getting away with it
Best ensure your subagents avoid getting blocked if there's any wait or command that takes more than 5 minute.
Ask your agent to look at its own usage metrics to see if you would have saved money by doing so. If your test suite is >5 mins then you likely will.
API is all 5m but apparently keeping it warm every 4.5 mins on API is fine.
This is what i heard.
(Which is funny, because you pay a premium on many providers for the worse attention!)
The last study I found was from a little while ago though, and there's been a lot of development in attention mechanisms since then. So it might be less bad now.
Bet bet is to measure it yourself by observing billing/credit usage or time-to-first-token.
Claude Code is here: https://code.claude.com/docs/en/prompt-caching
If you're using OpenRouter they publish cache hit rates, which can be used as a sort of proxy, e.g.: https://openrouter.ai/deepseek/deepseek-v4.1-flash-1017#pric...
Generally, by Googling "(provider) llm cache cost and duration" - can't recommend any source that collects them all.
Generally OpenAI and Anthropic are very serious about this and document it well.
Google is currently a shit show but getting better if you're on Interactions API.
The not-$1T crowd, i.e. other inference providers, can't and won't really guarantee anything.
OpenRouter shows data on their cache hit rates.
On not-$1T-crowd APIs, they'll want to set an arbitrary hint that they'll use for server affinity. (i.e. Fireworks needs to know this request wants to run on the same server/cluster/whatever as the last request so it can get a cache hit)
It uses a ridgeline chart to show how big each chat's context has grown and what it's spending.
And start a new blank session with its own branch (and have the agent update the project readme) so you can restart without context.
Edit: Not likely to happen currently but having this infra makes it easier to demonstrate compliance with your orgs rules.
It's a bit overkill for most users but depending on what you're asking it to work on it could theoretically traverse your local network to compromise devices/computers and escape the sandbox.
It's self-labelled as a 15m read and a human in the loop should recognize it's about 3m, tops. Here:
LLM API context caches, by default, only last for 5 minutes on Anthropic and 30m on OpenAI.
If you use Claude, there's an hour cache for 2x the cost of the 5 minute one.
If you use OpenAI, there's a 12 hour cache for 2.5x the cost of the 30m one.
FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
I did indeed run into this problem when I was steering 4 or 5 chats that would ask for feedback that took a few minutes to provide. Pretty soon you're juggling a bunch of 5 min timers if you don't want every single response to have to rebuild the cache.
I could tell that this was AI-written just from the turn of phrase in the title before I even clicked :\
On subscription (so 1h cache) I run into this being even higher, reaching 50%, before I noticed problem.
10-100x cheaper is not something to sneeze at
Are they offering Opus 5.5 quality and quantity of 20$ Claude subscription at and 2$/month? Or 0.2$/month?
There's even the ability to persist your kv cache to disk, so future session resumptions load back into context instantly without needing to do a full prefill ingestion by the LLM. (CachyLLaMA, iirc, not sure where the project is now)
But now, with Bonsai 2.5 27B, this is the first time that I don't need Haiku (or a similar cheap model) for tasks in their scope. I think local models are close to an inflection point in usefulness.
Note: I don't have anything local remotely close to reasoning capabilities of SOTA models such as Opus/Neon/Astra.
TDLR prompts are cached. Prompt cache hit == $. Cache miss == $$$$$$$. Claude ttl is 5 min. Codex ttl is 30 min. If u take longer than 5 min between turns then $$$$
1. This looks like API-billed traffic only. Claude Code defaults to a 1 hour cache, not 5 min! So if you're within your plan's usage, this doesn't really apply [1].
2. In the API, we have 5 min and 1 hour TTL options. The "23%" here for the 5 min option includes breaks over 30 min, where both Claude's and GPT's default caches have expired and the loss is the ~same (7.8% vs. 8.5%). If you run long sessions with breaks, and are using an API key, you could set "ttl": "1h". There will be a bit higher write price, though [2].
[1] https://code.claude.com/docs/en/prompt-caching
[2] https://platform.claude.com/docs/en/build-with-claude/prompt...
for +i; send prompt=prompt+"."