Repository navigation
fix(cost-map): lower openai chat-latest max_input_tokens to the 272000 the API enforces - #54260
Conversation
…0 the API enforces
|
|
PR overviewNo security issues were found in this pull request. Reviews
|
|
bugbot run |
[Low impact] The PR appears safe to merge, with no new actionable issues found.
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 664a18c. Configure here.
Handwritten 1-3 sentence description
OpenAI refuses chat-latest prompts above 272000 input tokens but our cost map said 400000. This sets the row to the limit the model page states and the API enforces.
Details
Link to Devin session: https://app.devin.ai/sessions/fbee90f9dcb145e98d41754319056a24
Open in Devin Desktop: https://app.devin.ai/desktop/session/fbee90f9dcb145e98d41754319056a24?variant=devin
Requested by: @kerry-berri
TLDR
Problem this solves:
chat-latestadvertises a 400000 token input limitchat-latestprompts above 272000 tokensHow it solves it:
max_input_tokensto 272000 onchat-latestUser Flow
Before: a developer reading the limit of
chat-latestfrom the proxy is told a prompt size that OpenAI refusesmax_input_tokens: 400000forchat-latestchat-latestand a prompt of about 280000 tokensAfter: the limit the proxy reports is the one OpenAI enforces
max_input_tokens: 272000forchat-latestRows changed
One row, kind page, applied under ruling
openai-chat-latest-max-input-272000(recorded 2026-11-24 by the cost tracking bot from live API evidence, not by a human)chat-latestmax_input_tokensThe ruling also quotes the API itself. A
chat-latestcall on/v1/chat/completionsreturned "Input tokens exceed the configured limit of 272000 tokens. Your messages resulted in 280007 tokens" (request req_d5517510b8d84e5e8a1f446c81364384), and on/v1/responsesan input of 271125 tokens returned 200 while about 272040 tokens returnedcontext_length_exceeded. Those calls were made by the ruling's author and were not repeated in this PRmax_output_tokensstays 128000, and the ruling covers only the bare openaichat-latestkey, so azure and chatgpt rows are untouchedChatGPT subscription rows
https://developers.openai.com/codex/models changed in markup only. Its
codex -mids are stillgpt-6-astra,gpt-6-luna,gpt-6.1-sol,gpt-6.1-terra,gpt-6.2-astraandgpt-6.2-sol, each already has achatgpt/row, and the three dated ChatGPT sign-in retirements on the page (gpt-5.4 on 2026-08-31, gpt-5.3-codex-spark on 2026-09-14, gpt-5.5 on 2026-10-14) are already on their rowsDelisted by the provider
Ids missing from the list API with no date in the catalog and no mention on https://developers.openai.com/api/docs/deprecations, left for a human:
daybreak-blue-latest,daybreak-red-latest,gpt-daybreak-blue-latest,gpt-daybreak-red-latest,gpt-4o-mini-search-preview,gpt-4o-search-preview,gpt-5.5-cyber,gpt-5.6,gpt-5.6-cyber,gpt-6-cyber,gpt-6-rosalind,gpt-rosalind-discovery,gpt-rosalind-research,omni-moderation-csam-latest.gpt-6-astra-lawandgpt-6.2-astra-lawwere added from the pricing page before the list API carried them (rulingopenai-gpt-6-astra-law-add-from-pricing-page). The other delisted ids in the diff already carry adeprecation_dateCoverage gaps and not delistings:
openai/container(container pricing pseudo key) andtext-embedding-ada-002-v2(alias oftext-embedding-ada-002)Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Before and after through a live proxy with a real OpenAI key on 2026-11-24. The before proxy ran at the merge base e35ef28 and the after proxy at 664a18c, each from its own checkout with its own Rust extension built by
maturin build --release, because the bundled cost map is compiled into the extension. Both ran one worker with no Redis and no database, since the change is a single catalog value read at startup. Before the fix the proxy reports 400000, passes a 360010 token prompt to OpenAI and OpenAI refuses it at 272000. After the fix the proxy reports 272000 and the router pre-call check refuses the same prompt before it is sentProxy command, config and client
config.yaml
client.py
The focused checks at the tip also pass
Type
🐛 Bug Fix
Caveats (if any)
Low
enable_pre_call_checkson, achat-latestprompt between 272000 and 400000 tokens is now refused by the router and no longer by OpenAI. The status is 400 either way