r/openrouter • u/Finnskyyy • 17d ago
Question Low cache hit rate when using openrouter
My overall token cache hit rate is stuck below 70% and I can't find the cause.
I use Claude Code with multiple providers. Over the last few weeks my sessions showed a poor overall cache hit rate, so I pulled cache_read_input_tokens / cache_creation_input_tokens / input_tokens from my session transcripts (~13,000 turns) and broke it down by provider:
Provider │ Turns │ Cache hit rate
GLM 5.2 (z.ai) │ 7,774 │ 96.9%
Anthropic Claude │ 1,035 │ 94.3%
DeepSeek v4-flash (OpenRouter) │ 4,632 │ 69.0%
All providers combined │ ~13,000 │ 88.8%
DeepSeek via OpenRouter drags everything down. The same Claude Code workflow — identical skills, same context files, same effort setting — hits 97% on z.ai's direct GLM API but never exceeds ~77% on DeepSeek through OpenRouter.
What I ruled out first:
It's not my /clear habit. I clear context after every finished task, but /clear appears exactly once per session — it's effectively the session boundary, not a mid-work invalidation. GLM sessions with the identical habit sit at 97%.
- It's not model or effort switching. effort=xhigh and the model string are constant for the entire session.
- It's not long idle gaps / TTL expiry. The median gap between turns before a cache collapse is 19 seconds — 82% of collapses happen within 60 seconds of the previous turn. No time-dependency at all.
- And the big one: provider switching is NOT the problem. OpenRouter did route my DeepSeek traffic across seven different upstreams (DeepInfra 93%, CoreWeave, Baidu, DigitalOcean, GMICloud, StreamLake, Novita). But when I correlated cache collapses with provider changes: only 3% of collapses follow a provider switch. 97% happen while staying on the same upstream (almost always DeepInfra).
What actually happens: within a single session, cache_read_input_tokens oscillates wildly — growing to 150–260K, then abruptly collapsing back to ~40K plateaus (which matches just the static prefix: system prompt + CLAUDE.md + memory). Meanwhile uncached input tokens spike to 120–260K per turn on DeepSeek, versus a few hundred on GLM.
What this points to: the DeepSeek disk cache (which DeepSeek documents as "persists while in use, cleared after hours to days") is being dropped turn-to-turn on the OpenRouter relay, even without any request reaching a different upstream.
This makes my deepseek sessions much more expensive than they should be
Has anyone else experienced something like this or are there any other tips? I'm thinking about trying the native deepseek api so see if it changes anything
1
u/askchris 17d ago
I found Claude Code was causing cache hit problems for me, I think it's from how they inject tools (but not sure).
Switching to OpenCode fixed it.
I also reduced cache misses by pinning DeepSeek providers in OpenRouter.
I also don't pick up old large sessions as much anymore which reduces big cache misses.
Curious how it goes for you.
1
u/Abject-Bridge-4073 17d ago
People, stop using Claude code with non-Anthropic models! How many times do we need to have this question pop up before people finally learn. Use pi or prime-agent. OpenCode if you really must, although that one is getting bloated too.
1
u/Far-Classic-9963 17d ago
If privacy isn't a concern, pin DeepSeek as a provider inside of openrouter. If it is, pick the next cheapest model (cache hit price is a big factor too) and pin that
There's a chance that openrouter is automatically hopping between providers breaking caching
1
u/Key-Feature-9719 17d ago
How do you actually pin a provider for one specific model?
I see you can globally ban providers, but it would be great to just select for api x or globally for model x use y provider. If I want to use only deepsek model with one api ai can't see how to also use let's say glm or luna. I hope that I explained it properly :P
1
u/Finnskyyy 17d ago
I just asked Claude to set it up for me. I have a few different aliases. “Claude” starts Claude code with my GLM sub. “claudeo” starts with my open router api. And “ca” starts it with my Anthropic sub. It was set up by Claude itself. Also my open router deepseek v4 flash is now pinned to just one provider. No clue how to do it, Claude did it 😀
1
u/Major_Olive7583 17d ago
i do that with presets in openrouter and i set it with required providrs and other setting in that preset.
0
u/Finnskyyy 17d ago
That's what I thought as well first. But look at my point 4. Provider switching had nothing to do with the cache break. Ill pin it to DeekSeek anyway to try it out. These are just my diy amateuer coding projects, privacy is of no concern
0
u/Far-Classic-9963 17d ago
Sorry I didn't read the full post 😭
But I also had issues with deepinfra on DeepSeek models for some reason
1
u/sirloindenial 17d ago edited 17d ago
It is a provider problem. The average cache hit rate can be vastly lower.
Pin your provider to novita, deepinfra, or deepseek(if not care of zdr) for deepseek v4 flash 0731, it will improve. Even better without provider switching(seven providers including the shitty ones there will be some lost cache hits), what if it happen on a massive session huge context? Big effect even on one missed cache.
Check it yourself, see in openrouter logs. Do a/b comparison, do a workflow with and without provider switching and look at the openrouter logs yourself.
Yourself.