Skip to content

fix(server): price ledger runs by model, not a per-1K provider table - #16

Open
Mattbusel wants to merge 1 commit into
RelayPlane:mainfrom
tensorust-ai:fix/server-cost-by-model
Open

Mattbusel wants to merge 1 commit into
RelayPlane:mainfrom
tensorust-ai:fix/server-cost-by-model

Conversation

@Mattbusel

Copy link
Copy Markdown

ProxyServer.estimateCost in src/server.ts (line 1363 on main) keeps its own per-1K table, so every OpenAI run lands in the ledger at $5/$15 per 1M (GPT-4o lists at $2.50/$10) and every Claude run at Sonnet rates whatever the model: a Haiku 4.5 run is recorded at 3x its price and an Opus 4.6 run at 60%. That table is also the only Claude/GPT price outside model-pricing.ts, which its header says should not happen.

This prices each run by request.model through telemetry.ts MODEL_PRICING (aliases and provider/ prefixes included) and only falls back to a per-provider row, now real list prices, when the model has no price. __tests__/server-estimate-cost.test.ts adds 7 cases, including one that checks the new helper agrees with estimateCost for every row; tsc --noEmit is clean and model-pricing and run-attribution still pass (the suites that need the monorepo or dist/ fail the same way on main).

I also added .github/workflows/llm-prices.yml, which runs on PRs touching src/ and weekly and fails if a hard-coded price drifts from the official pages. It uses llm-prices, an MIT action I maintain: on main it flags exactly the two values above, and on this branch it finds 54 prices for 22 models with no drift. Since this repo is synced from packages/proxy, the workflow may belong in the monorepo instead, and I am happy to drop it if you would rather keep the PR to the fix.

ProxyServer.estimateCost kept its own per-1K table that priced every
OpenAI run at $5/$15 per 1M (GPT-4o is $2.50/$10) and every Claude run
at Sonnet rates regardless of model, so a Haiku 4.5 run was billed 3x
and an Opus 4.6 run at 60% of list.

Price by request.model through telemetry.ts MODEL_PRICING (which takes
its Claude and GPT-5 rows from model-pricing.ts), and fall back to a
per-provider row only when the model has no price. Adds a regression
test and a weekly drift check on src/ against the providers' pricing
pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant