fix(server): price Daybreak models under their LiteLLM alias - #7802
fix(server): price Daybreak models under their LiteLLM alias#7802Exotic209093 wants to merge 1 commit into
Conversation
Codex records Daybreak usage as gpt-daybreak-blue-latest and gpt-daybreak-red-latest, but LiteLLM's price table keys those same models without the gpt- prefix. The mismatch made lookupRate miss the table and report both models as unpriced ($0.00) even though tokens were counted correctly. Add a narrow, explicit two-entry alias map consulted after normalization and before the table lookup. This is intentionally not a generic gpt- prefix strip, since LiteLLM prices real GPT models (gpt-5, gpt-4, ...) with that prefix intact, and stripping it generically would send those lookups at the wrong key. Fixes pingdotgg#7752
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1223d7f070
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const aliased = MODEL_NAME_ALIASES.get(normalized) ?? normalized; | ||
| return table.get(aliased) ?? null; |
There was a problem hiding this comment.
Prefer the exact rate before applying the alias
If LiteLLM starts publishing either Daybreak model under its provider-recorded gpt-daybreak-… key—especially if it removes the current unprefixed key—this unconditional rewrite ignores the exact entry and returns null, making the model unpriced again. Since the rate document is fetched dynamically, look up normalized first and use the alias only as a fallback.
Useful? React with 👍 / 👎.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Small, targeted fix adding two explicit model name aliases for pricing lookups, with comprehensive test coverage. The unresolved review comment suggests defensive future-proofing but does not identify a bug in the current implementation. You can add or adjust custom eligibility rules. Learn more. |
Summary
Fixes #7752. Codex records Daybreak model usage as
gpt-daybreak-blue-latestandgpt-daybreak-red-latest. LiteLLM'smodel_prices_and_context_window.jsonpublishes rates for these same models under different keys, without thegpt-prefix:daybreak-blue-latestanddaybreak-red-latest. BecauselookupRateinapps/server/src/usage/usagePricing.tslooks the model up by its exact normalized name, the mismatch means both models miss the rate table entirely and get reported as unpriced ($0.00), even though token counts are recorded correctly.Fix
Added a narrow, explicit two-entry alias map (
MODEL_NAME_ALIASES) consulted inlookupRateafter normalization and before the table lookup. This is deliberately not a generic "strip a leadinggpt-" transform: LiteLLM prices real GPT models (gpt-5,gpt-4, ...) with thegpt-prefix intact, so a generic strip would send those lookups at the wrong (and likely nonexistent) key.normalizeModelNameandparseRateTableare unchanged — the alias only applies at lookup time, not when building the table from LiteLLM's document.Test plan
apps/server/src/usage/usagePricing.test.tscovering:daybreak-blue-latest/daybreak-red-latestpriced correctly via their Codexgpt-prefixed names; the alias is case-insensitive; a realgpt-model (gpt-5) still resolves under its own key and is unaffected by the alias; a realgpt-model absent from the table (gpt-4) stays unpriced rather than matching a stripped-prefix key. Confirmed the tests fail before the fix and pass after.vp test run apps/server/src/usage/usagePricing.test.ts— 5 passed.vp linton both changed files — clean.vp run --filter t3 typecheck— clean (only pre-existing, unrelated suggestions in other files).Note
Low Risk
Narrow lookup-only alias for two model names; no billing write path, auth, or table-parse changes.
Overview
Fixes Daybreak usage showing as $0.00 because Codex records
gpt-daybreak-blue-latest/gpt-daybreak-red-latestwhile LiteLLM prices those models without thegpt-prefix.lookupRatenow remaps those two names via an explicitMODEL_NAME_ALIASESmap after normalization. Real GPT models keep their prefixed keys; there is no generic prefix strip. Tests cover both aliases, case-insensitivity, and thatgpt-5/ missinggpt-4are unchanged.Reviewed by Cursor Bugbot for commit 1223d7f. Configure here.
Note
Fix pricing for Daybreak models by aliasing
gpt-daybreak-*to unprefixed rate keysAdds a
MODEL_NAME_ALIASESmap in usagePricing.ts that mapsgpt-daybreak-blue-latestandgpt-daybreak-red-latestto their unprefixed rate-table keys.lookupRatenow checks this map after normalization and unpriceable checks, using the aliased key when present and falling back to the normalized name otherwise.gpt--prefixed models, and non-stripping of absent entries likegpt-4.gpt-daybreak-*names are remapped; othergpt--prefixed model lookups are unchanged.Macroscope summarized 1223d7f.