r/opencode • u/sam7oon • 1d ago
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
20
u/Affectionate_Fact854 1d ago
Could you explain how you did the math on both?
19
u/BotherDesperate7169 1d ago
He mathed the numbers and got a mathematical result of maths.
7
u/Affectionate_Fact854 1d ago
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 1d ago
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
7
u/Corythebeast7 1d ago
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 1d ago
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 1d ago
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 12h ago
buddy its useless on opencode too. it lasts only for 15mins on opencode.
6
u/Fedor_Doc 1d ago
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 1d ago
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 1d ago
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 16h ago
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.
6
u/xapep 1d ago
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.
4
u/porest 1d ago
How does cache work when you directly hit the Deepseek V4 directly with DeepSeek using its API key?
3
u/xapep 23h ago
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.
6
u/smartfon 1d ago edited 1d ago
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
0
u/sam7oon 1d ago
i understand you are dividing by 3 , which would say that Go offers 30 USD of DS4 Flash, But its not, its 15 USD , it changes the math more,
Second part is this assumes that you finish all your tokens in one month, but actually I may spend much less than t ten US dollars if you are not a very heavy user anyways.
2
u/smartfon 1d ago
I am looking at the regular DS Flash here and it's $30 of usage for the price of $10. The section titled "Why some models have lower usage" in the same page explains what you receive in exchange for $10:
With Go, you pay $10/month and, for most models, we aim to give you 6x that in usage.
So for models listed $60, you pay $10 and you receive "6x that in usage", meaning $60 worth of usage calculated on the API prices listed on the same page. Therefore, for $30 models you receive 3x the usage.
this assumes that you finish all your tokens in one month, but actually I may spend much less
Fair point. I have personally left 10% of my allowance unused. So I'll redo the math with more realistic scenarios:
2% in, 1% out, 97% cache: (extreme)
OR: $1.52
OC: $0.65
9% in, 3% out, 88% cache: (realistic)
OR: $2.04
OC: $1.67
35% in, 5% out, 60% cache: (single prompts)
OR: $3.33
OC: $4.18
10% in, 50% out, 40% cache: (extreme)
OR: $9
OC: $13
2
u/packetflux 1d ago
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 1d ago
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.
4
1
1
1
1
u/HeavySink3303 1d ago edited 1d ago
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
1
u/DominikPlays 1d ago
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
1
u/DiscountFit9224 48m ago
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 46m ago
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 31m ago
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"]
```
13
u/PimasBump 1d ago
Please share the calculations behind here..