anomalyco / anomalyco/opencode
Local cost estimate uses the 200k price below a model's real context threshold
@jlongster is already working on this.
Since Aug 22, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
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:
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 3a31c4ea801915c0b050df4b3842997ea62b6e93.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.