fix(core): price gpt-4.1 family at OpenAI list rates instead of legacy gpt-4 - #13189
Open
weike-zhang wants to merge 1 commit into
Open
fix(core): price gpt-4.1 family at OpenAI list rates instead of legacy gpt-4#13189weike-zhang wants to merge 1 commit into
weike-zhang wants to merge 1 commit into
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
Note: the two failing checks are infrastructure-related and pre-existing — |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13184
Summary
calculateOpenAICostmatches pricing rows by longest-prefixstartsWith. The table had nogpt-4.1*rows, so everygpt-4.1id (including date-stamped snapshots likegpt-4.1-2025-04-14) fell through to the legacygpt-4row (input $30 / output $60 per MTok) — 15x–300x over OpenAI list price.What this does
Adds the three missing pricing rows:
gpt-4.1-minigpt-4.1-nanogpt-4.1(per million tokens, USD)
No matcher change needed:
sortedKeysis longest-first, sogpt-4.1-mini/gpt-4.1-nano(12 chars) are checked beforegpt-4.1(7), which is checked before legacygpt-4(5).Verification
Regression cases added to
core/llm/utils/calculateRequestCost.vitest.ts(1000 in / 500 out tokens):gpt-4.1*model cost 0.06 USD (legacy gpt-4 rates).gpt-4.1: 0.006,gpt-4.1-mini: 0.0012,gpt-4.1-nano: 0.0003,gpt-4.1-2025-04-14: 0.006gpt-4ounchanged at 0.0075Prettier check clean on both files.