Skip to content

Local cost estimate uses the 200k price below a model's real context threshold #44224

Closed

Description

@xyzs996

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:

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 tiers and context_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_200k without tiers

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

  1. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    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@latest or curl -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions