r/opencode • u/sam7oon • Sep 09 '26
Switching to Openrouter API instead of Go for DS4 Flash & GLM5.3
The math is no longer making since if you are a primary user of the small cheap models like Deepseek v4 Flash , and GLM 5.3 Flash,
The price Opencode Go for API is contracted to , is much more expensive, than the one you can get on the API Market , for me, Open Router,
| Model | OpenRouter ($10 Direct) | OpenCode Go ($10 Sub) |
|---|---|---|
| DeepSeek V4 Flash | 40M – 100M+ tokens | 3M – 8M tokens |
| GLM 5.3 Flash | 20M – 40M+ tokens | 2M – 5M tokens |
For this month, i decieded to switch to Open Router and see how it goes, speceilly if i dont reach that limit,
Also most probably this means am not the heaviest user
Anyways , i think Direct API is also a better quality than OpenCode's for some user, and usually faster
6
u/Fedor_Doc Sep 09 '26
OpenRouter is a proxy, not a direct API. They will switch providers on the fly if you do not switch off all providers but one in the settings.
Providers have different pricing, generation speed, model qunatization.
3
u/squirrelscrush Sep 09 '26
It's possible to filter the providers you want if you use opencode or any other harness. Also, keep a particular provider for the whole session (disallow fallback).
1
u/sam7oon Sep 09 '26
and you can specify a specific Provider that you know have a high cache hit rate, there is a lot of documentation on Open Router for how to pick the best model providers, and actually optimize your costs
1
u/squirrelscrush Sep 10 '26
Yup, there's a slight dip with the cache hit rate on OpenRouter. It gives me 98.6% there instead of around 99.6% on direct DeepSeek.
My setup is extremely optimized for DeepSeek so this dip is a routing issue.
8
3
u/pmv143 Sep 09 '26
I would recommend InferX. Probably the cheapest and fastest.
1
2
20
u/Affectionate_Fact854 Sep 09 '26
Could you explain how you did the math on both?
22
u/BotherDesperate7169 Sep 09 '26
He mathed the numbers and got a mathematical result of maths.
7
u/Affectionate_Fact854 Sep 09 '26
Well I was using direct deepseek api and sorry to tell you but the price usage escalated to a much higher price then what OP stated
Real world work we don't feed the prompt the exact same encyclopedia 500x for it to reach that token usage and cache hits
1
u/sam7oon Sep 09 '26
you have to do tweaking, for example use the :floor to get the cheapest provider, or out right select a provider that balances price with cache hit, and specify it in your configuration,
There is a lot of techniques for Open Router sleection optimization, thay have guide, you can read them :)
3
2
u/packetflux Sep 09 '26
Honestly, the open-source and local tooling ecosystem has caught up enough that lock-in subscriptions feel less justified. Being able to bring your own API keys or run local models through an open interface gives way more control over context windows without hitting arbitrary daily usage tiers.
2
u/sam7oon Sep 09 '26
Local models can never compete with cloud provided on speed and price. Maybe on privacy, yes. But if you need speed and price and actual capable models, you can never run the same on your local machines. Quinn 27 billion is good, but it's not like GLM5.3 flash level even and this is not a very fancy model. Um maybe local in the future will be something, but not right now. This is besides actually calculating the cost of buying this hardware, which is super expensive right now.
13
7
u/Corythebeast7 Sep 09 '26
Cache hit rate will suffer immensely with Openrouter. Just watch out for it. I am honestly skeptical that you'll hit your estimated tokens, but good luck! Please report back
2
u/squirrelscrush Sep 09 '26
It depends on the provider of the particular model. In my experience, most of the direct companies like DeepSeek, z.ai, etc have the best cache hit rate.
Other providers are case to case basis.
1
u/Sympotic17 Sep 09 '26
I just allow specific providers with very less weighted input price, does the job of keeping cache hit rate high
1
u/Sufficient_Fox_4402 Sep 10 '26
buddy its useless on opencode too. it lasts only for 15mins on opencode.
7
u/xapep Sep 09 '26
The math is just tokens per dollar at list price: your own numbers show ~40-100M per $10 on OpenRouter against 3-8M on Go's rate, which is an order of magnitude per token for models that are cheap to serve. A subscription bundles a fixed per-token rate into the seat price, and for Flash-class models like DS4 Flash and GLM 5.3 Flash that contracted rate ends up way above what the market charges.
The cache warning in the comments is the real gotcha though. Flash-class models get dramatically cheaper on cache hits, but only if your requests keep landing on the same upstream and the provider actually bills cached tokens properly. Marketplace routing can shuffle you across upstreams, kill the prefix cache, and quietly eat half the savings. So run the same workload against a direct OpenAI-compatible endpoint too, and compare effective cost per real task, not per raw token. That's usually where direct providers win by more than the headline rate suggests. Full disclosure, I work on Entrim, we run V4 Flash, so I look at this cost split daily.
0
Sep 09 '26
[deleted]
3
u/xapep Sep 10 '26
With your own DeepSeek key it's automatic prefix caching on their side, nothing to turn on. Each request gets tokenized and matched against their cache: whenever the front of your prompt (system prompt, tool schemas, earlier turns) is an exact match to a recent request, those prefix tokens bill at the cache rate instead of the fresh rate. Change the ordering and the match breaks, so your hit rate mostly depends on whether your client serializes context the same way every call. Agent frameworks that rebuild or reorder context between turns quietly kill it.
Two things worth knowing: the usage object in the response reports cache hit and miss token counts separately (prompt_cache_hit_tokens / prompt_cache_miss_tokens), so you can measure real hit rate per task instead of guessing. And with a direct key you're always on the same upstream, so the cache is consistent, unlike a marketplace proxy that can shuffle you across providers and reset the prefix. Exact cache rates and how long entries live are on DeepSeek's pricing/docs page, they change often enough that I wouldn't trust a number from a comment.
2
1
u/HeavySink3303 Sep 09 '26 edited Sep 09 '26
At NW (Neuralwatt) I can get around 250M DS4F tokens per $10 and around 100M of 5.3 (full size, non-flash). Mainly due to long living cache (sometimes it is still 'alive' after a 22 hours pause).
1
0
u/sam7oon Sep 09 '26
250 Million of Output tokens ! or , you mean all including Input, because if you include input/cache tokens, then 250 Million is nothing really
1
u/DominikPlays Sep 09 '26
I use openrouter with GLM 5.3 Flash, GLM 5.2, DS 4 Pro etc and put in ~100 usd one month and spent around 1b tokens, still have 2 dollars left, used zdr only endpoints, i think it is much better than opencode, but definitely restrict via guardrails what providers are used, handpick them
1
u/sam7oon Sep 09 '26
100 USD is a lot though, maybe you meant 10 USD ! ,
Cuz for 100 USD, i hear Claude's subscription is actually more worth it , not sure though
1
u/DominikPlays Sep 11 '26
Yeah but that is not zdr, which i kind of do not need, but willing to pay extra for
1
u/DiscountFit9224 Sep 11 '26
I switched to OpenRouter, locking it to 4 providers and FP8 quantization with allow_fallback set to false so it don't route to other providers not on the list.
I mainly use AI for an assisted coding workflow, so I don't hit the $10 monthly subscription limit in OpenCode at all, the main reason I leave opencode. With OpenRouter, I can stretch that $10 even further than a month since it's pay-as-you-go.
1
u/sam7oon Sep 11 '26
What models are you using primarly , that you are able to accomadate in tat budget if i may ask , am gonna start doing the same in 3 days after my Go sub expires,
And secondly , is the :floor way to pick providers a shitty way !
2
u/DiscountFit9224 Sep 11 '26
I mainly use deepseek-v4-flash-0731 and glm-5.3-flash as sub agent for routing image input since DS doesn't have image input support and describe the image back to DS.
I don't use the ":floor" method for selecting provider. I just pin them with "order" list, though I check their pricing before I do work cause sometimes they change their prices so i look for low latency, cheap and good tps (this varies by usage since, I don't do agentic or vibe coding I look for at least ~25 tps)
But here's how I pin provider and quantization.
```
"order": ["deepinfra", "streamlake", "parasil"],
"allow_fallbacks": false,
"quantizations": ["fp8"]
```
1
1
1
u/mageblex Sep 11 '26
The token ranges hide the variable that decides this: your cache mix. Price one week of actual input, output, and cache-read totals under both plans, then include unused Go allowance. For cache-heavy coding, the cheaper option can flip.
11
5
u/smartfon Sep 09 '26 edited Sep 09 '26
DS Flash OpenRouter: $0.05 / $0.16 /$0.013
DS Flash OpenCode: $0.22 / $0.66 / $0.007 (÷3)
2% in, 1% out, 97% cache:
OR: $1.52
OC: $0.59
10% in, 50% out, 40% cache:
OR: $9.02
OC: $11.82
OpenCode is better for agentic coding that uses almost only cache, unless you're willing to configure OpenRouter to use DeepSeek's server with the low cache price.
For all other use cases, like a regular question without a followup or OpenClaw/Hermes agent, I'd use OpenRouter because the cache matters less and OpenRouter's lower input/output wins the competition.
Edit: correction, removed the 75% cache calc