Repository navigation
Description
Description
getUsage prices any request between 200,001 tokens and the model's actual context threshold at the high tier. For the GPT-5.6 family, whose tier steps at 272k, a 250k-token request is estimated at $0.40/M input instead of the documented $0.20/M — 2× the real rate.
The cause is the ?? in the cost selection:
opencode/packages/opencode/src/session/session.ts
Lines 380 to 386 in 3a31c4e
| const costInfo = | |
| input.model.cost?.tiers | |
| ?.filter((item) => item.tier.type === "context" && contextTokens > item.tier.size) | |
| .sort((a, b) => b.tier.size - a.tier.size)[0] ?? | |
| (input.model.cost?.experimentalOver200K && contextTokens > 200_000 | |
| ? input.model.cost.experimentalOver200K | |
| : input.model.cost) |
The tier filter returns empty exactly when the request is below every threshold. That is precisely when the ?? fires, handing control to experimentalOver200K && contextTokens > 200_000 — a different, hardcoded number. So being below the real threshold is what triggers the high price.
experimentalOver200K is not a second, cheaper threshold. Against today's https://models.dev/api.json:
- 361 models carry both
tiersandcontext_over_200k - in all 361,
context_over_200k's prices equal the lowest context tier's exactly (input, output, cache read, cache write) - 0 models carry
context_over_200kwithouttiers
It is the legacy spelling of the lowest tier, from when 200k was the only threshold in the catalog. 252 context tier entries now sit at some other number — 137 at 272k, 56 at 256k, 31 at 128k, 20 at 32k, 6 at 512k, 2 at 262144 — and every one of them has this band.
Steps to reproduce
Run the cost expression against the real models.dev payload for gpt-5.6-luna (input $0.20/M, tier at 272k):
| context tokens | costInfo.input | documented |
|---|---|---|
| 199 000 | $0.20/M | $0.20/M |
| 200 001 | $0.40/M | $0.20/M ❌ |
| 250 000 | $0.40/M | $0.20/M ❌ |
| 271 999 | $0.40/M | $0.20/M ❌ |
| 272 001 | $0.40/M | $0.40/M |
Same shape for gpt-5.6 ($5 → $10/M).
This affects the local estimate shown in the TUI, not what the provider actually bills.
OpenCode version
Read on dev at 3a31c4e.
Activity
github-actions commentedon Aug 22, 2026
This issue might be a duplicate of existing issues. Please check:
experimentalOver200K/ tier selection logic ingetUsage), though from the opposite direction (under-estimation vs over-estimation described here).fix(opencode): let catalog tiers own the threshold over the legacy ov…
fix(opencode): price long-context steps at the catalog tier, includin…
neriousy commentedon Oct 19, 2026
Since v2.0.22, local cost estimates no longer apply the legacy 200k catalog price. The base price is used until the model's own context-tier threshold is exceeded, so a 250k-token request on a model whose tier starts at 272k is estimated at the base rate. To get v2:
npm i -g @opencode/cli@latestorcurl -fsSL https://opencode.ai/v2/install | bash(desktop: update the app). If you still see this on v2, please open a new issue with the details.