t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: OpenCode Go deepseek-v4.1-flash (and -free) usage shows Unpriced despite opencode_go LiteLLM rate

Open umeshm-infomagnus opened this issue 3 weeks ago • 2 comments

Summary

OpenCode Go usage for deepseek-v4.1-flash shows as Unpriced on Usage → Cost, even though LiteLLM has an exact entry for it (opencode_go/deepseek-v4.1-flash: $0.30 input / $1.20 output / $0.006 cache read per 1M tokens). deepseek-v4.1-flash-free is also Unpriced. Related to #19688 (same symptom for GLM).

Cause

  • The OpenCode usage reader (packages/provider-opencode/src/server/usage.ts) takes the model from message.model.id / message.modelID, which is the bare deepseek-v4.1-flash. The provider ID (opencode-go) is not used for pricing.
  • parseRateTable (apps/server/src/usage/usagePricing.ts) registers a bare-name alias only if all providers listing it agree on price. LiteLLM currently lists deepseek-v4.1-flash for 11 providers with different prices (e.g. $0.12/$0.48, $0.17/$0.63, $0.30/$1.20, $0.40/$1.60, $0.01/$1.20), and there is no first-party deepseek/ entry. mergeAliasRate returns null, so the alias is dropped and lookupRate finds nothing.
  • OpenCode records cost: 0 for subscription usage and the reader ignores cost <= 0, so there is no reported cost fallback. Result: costSource: "unpriced".
  • deepseek-v4.1-flash-free has no LiteLLM entry at all.

Expected

Go usage is priced from the opencode_go/... entry (or an equivalent provider-aware lookup), and -free models are treated as $0 rather than unpriced.

Possible fix

Pass the OpenCode provider ID through to pricing (rateModel, e.g. opencode_go/deepseek-v4.1-flash) so the exact entry is used before the ambiguous bare-name alias. Treat *-free models as zero-cost.

Workaround

Usage → environment dropdown → Model prices: add deepseek-v4.1-flash at $0.30 / $1.20 and deepseek-v4.1-flash-free at $0 / $0.

Environment

T3 Code 0.1.6 (desktop, Windows), OpenCode with an OpenCode Go subscription.

umeshm-infomagnus avatar Nov 04 '26 06:11 umeshm-infomagnus

Confirmed on 0.1.8-nightly.20261106.4275 (desktop on macOS, plus two linked Linux servers on the same build) with OpenCode v2.2.5. packages/provider-opencode/src/server/usage.ts on main still doesn't read providerID, so this remains open until #30683 or #30681 lands.

Evidence from session_message for opencode-go / deepseek-v4.1-flash, 1,288 assistant rows on one machine:

  • 846 rows have cost > 0, 438 have cost: 0, and 4 have no cost.
  • The change is a clean cut: every row up to 2026-11-03 03:00 UTC has a positive cost, and every row from 03:04 UTC has cost: 0. Usage only turns Unpriced from that point.
  • The positive rows report $0.9027 in total, exactly half of the $1.8055 they come to at the opencode_go/deepseek-v4.1-flash rates. Estimates from that entry may not match what OpenCode was reporting earlier.

The workaround above also needs a cache read price. createOverrideRateTable falls back to the input rate when it's omitted, so $0.30 / $1.20 alone prices cache reads at $0.30/M instead of $0.006/M. On a card with 5.61M input, 357M cache read and 1.73M output tokens, that gives about $111 instead of about $5.90. Overrides also replace provider-reported costs on older rows.

Triaged by Claude Opus 5.5 in Claude Code, through T3 Code.

y-u-s-u-f avatar Nov 06 '26 19:11 y-u-s-u-f

[!NOTE] Opus 5.5 writing on behalf of Pedro.

Also hitting this on Linux with an OpenCode Go subscription, and +1 to #30683 as the fix.

I checked it against real history rather than synthetic messages. session_message has 12,533 assistant rows for opencode-go / deepseek-v4.1-flash, all with cost: 0, and all of them show as Unpriced on main (8fc6fd01d7). I ran a copy of that database through a reader patched the same way as #30683's reader change, priced against the cached LiteLLM table:

Model (opencode-go) Rows On main Priced as opencode_go/<model>
deepseek-v4.1-flash 12,533 Unpriced $43.96
glm-5.3-flash 3 Unpriced priced
muse-spark-1.3-contributor 2,130 priced unchanged

The -free rows (179 for deepseek-v4.1-flash-free, 37 for muse-spark-1.3-contributor-free) stayed Unpriced in that check, as expected: they need #30683's zero-cost handling, which I didn't apply.

PedroNavHur avatar Nov 10 '26 23:11 PedroNavHur