t3code icon indicating copy to clipboard operation
t3code copied to clipboard

Usage page presents a rate-table failure as $0.00 instead of saying cost is unavailable

Open wezzcoetzee opened this issue 3 months ago • 2 comments

What happens

When the LiteLLM model rate table cannot be loaded, the usage page reports $0.00 for every model, 0.0% of cost for every provider, and $0.00 cache savings — beside perfectly correct token counts. Nothing on the page indicates that the cost figures are missing rather than genuinely zero.

UsageService.ensureRates swallows the fetch failure on purpose (apps/server/src/usage/UsageService.ts:164), which is the right call — degrading beats a broken page. Every bucket then falls through lookupRate to { costUsd: 0, costSource: "unpriced" } (usagePricing.ts:129). The bug is that it degrades invisibly.

The signal already exists and is discarded

The server computes and ships the diagnosis on every request:

  • UsageSummary.pricing.status — fresh | cached | unavailable, documented in packages/contracts/src/usage.ts:146 as existing "so the UI can be honest about how good the cost figures are"
  • per-bucket unpricedRecords

No client reads either one. grep -rn "pricing" apps/web/src apps/mobile/src returns nothing. So pricing.status is a dead field inside a versioned contract, and the one signal that says "these numbers are meaningless" is dropped at the client boundary.

Reproduce

With an isolated state dir (so no rate cache exists) and outbound HTTPS blackholed:

BASE=$(mktemp -d)
NODE_USE_ENV_PROXY=1 HTTPS_PROXY=http://127.0.0.1:9 NO_PROXY=localhost,127.0.0.1 \
  pnpm run dev --home-dir "$BASE"

Against ~960M real tokens the page reported $0.00 across every model and provider, with no indication anything had failed.

Originally hit on a laptop behind corporate TLS inspection, where the fetch to raw.githubusercontent.com fails. Diagnosing it required reading server.trace.ndjson and noticing usage-model-rates.json was absent from the state dir. That should not be the discovery path.

Related, but not this issue

The rate table has no bundled fallback — its only source is one hardcoded URL (UsageService.ts:56) with an empty Map as the starting state (UsageService.ts:131), so any offline or proxied install starts with no prices at all. Fixing that means committing a LiteLLM snapshot and owning its refresh cadence, which is a product decision rather than a bug fix. Tracked separately.

wezzcoetzee avatar Aug 10 '26 04:08 wezzcoetzee

Fix is in #7181. When the rate table cannot be loaded, the usage page reports that cost is unavailable instead of showing $0.00.

maslinedwin avatar Aug 16 '26 09:08 maslinedwin

closing as a duplicate of #5799 so the issue stays tracked in one place.

t3-code-bot[bot] avatar Aug 20 '26 21:08 t3-code-bot[bot]