Skip to content

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
continuedev:mainfrom
weike-zhang:fix/gpt-4.1-pricing
Open

fix(core): price gpt-4.1 family at OpenAI list rates instead of legacy gpt-4#13189
weike-zhang wants to merge 1 commit into
continuedev:mainfrom
weike-zhang:fix/gpt-4.1-pricing

Conversation

@weike-zhang

@weike-zhang weike-zhang commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #13184

Summary

calculateOpenAICost matches pricing rows by longest-prefix startsWith. The table had no gpt-4.1* rows, so every gpt-4.1 id (including date-stamped snapshots like gpt-4.1-2025-04-14) fell through to the legacy gpt-4 row (input $30 / output $60 per MTok) — 15x–300x over OpenAI list price.

What this does

Adds the three missing pricing rows:

model input output
gpt-4.1-mini 0.40 1.60
gpt-4.1-nano 0.10 0.40
gpt-4.1 2.00 8.00

(per million tokens, USD)

No matcher change needed: sortedKeys is longest-first, so gpt-4.1-mini/gpt-4.1-nano (12 chars) are checked before gpt-4.1 (7), which is checked before legacy gpt-4 (5).

Verification

Regression cases added to core/llm/utils/calculateRequestCost.vitest.ts (1000 in / 500 out tokens):

  • Before the fix, all four new cases fail — every gpt-4.1* model cost 0.06 USD (legacy gpt-4 rates).
  • After the fix, all pass:
    • gpt-4.1: 0.006, gpt-4.1-mini: 0.0012, gpt-4.1-nano: 0.0003, gpt-4.1-2025-04-14: 0.006
    • control gpt-4o unchanged at 0.0075

Prettier check clean on both files.

@weike-zhang
weike-zhang requested a review from a team as a code owner August 24, 2026 16:37
@weike-zhang
weike-zhang requested review from sestinj and removed request for a team August 24, 2026 16:37
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@weike-zhang

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@weike-zhang

Copy link
Copy Markdown
Author

Note: the two failing checks are infrastructure-related and pre-existing — jetbrains-tests dies extracting a corrupted xz artifact, and the e2e job fails in @vscode/ripgrep's postinstall (GitHub API 403 while fetching ripgrep-prebuilt). Both also fail on other open PRs (e.g. #13179) and neither touches this change (core/llm/utils/calculateRequestCost.ts + its test only).

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.

[Bug] gpt-4.1 / -mini / -nano are priced as legacy gpt-4 — 15x to 300x over list

1 participant