-
Notifications
You must be signed in to change notification settings - Fork 61
Fix: Route gpt-5.1 models to Responses API #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, only gpt-5-pro and gpt-5-codex were routed to OpenAI's Responses API. This caused gpt-5.1 models (including gpt-5.1-codex and gpt-5.1-codex-mini) to incorrectly use the Chat Completions API, resulting in errors. This change adds gpt-5.1 model prefix to the routing logic so all gpt-5.1 models (gpt-5.1, gpt-5.1-codex, gpt-5.1-codex-mini, etc.) are properly routed to the Responses API via fetchOpenAIResponsesTranslate. Fixes issue where customers using invoke() or online scorers with gpt-5.1-codex models were getting errors due to incorrect endpoint routing. Related models affected: - gpt-5.1 - gpt-5.1-2025-11-13 - gpt-5.1-chat-latest - gpt-5.1-codex - gpt-5.1-codex-mini
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 921a22954f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
921a229 to
265873c
Compare
Updated routing logic to target all gpt-5 codex variants using a flexible pattern that matches gpt-5-codex, gpt-5.1-codex, gpt-5.2-codex, gpt-5.3-codex, and any future gpt-5.x-codex models. Changes: - Added flexible pattern: starts with 'gpt-5' AND contains '-codex' (proxy.ts:2092-2093) - Updated test to validate gpt-5.x-codex routing (openai.test.ts) Models affected: - gpt-5-codex (existing) - gpt-5.1-codex - gpt-5.1-codex-mini - gpt-5.2-codex (future) - gpt-5.3-codex (future) - Any future gpt-5.x-codex variants Other gpt-5 models (gpt-5-mini, gpt-5.1, gpt-5.1-chat-latest, etc.) will continue to use the Chat Completions API as before. Fixes customer issue where gpt-5.x-codex models failed with invoke() and online scorers due to incorrect endpoint routing.
265873c to
c939744
Compare
| bodyData?.model?.startsWith("gpt-5-pro") || | ||
| bodyData?.model?.startsWith("gpt-5-codex") | ||
| (bodyData?.model?.startsWith("gpt-5") && | ||
| bodyData?.model?.includes("-codex")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very tiny nit, i would probably test that it starts with "gpt" and ends with "codex" to be safe. but i dont think it matters.
Problem
Customers using
gpt-5.x-codexmodels (e.g.,gpt-5.1-codex,gpt-5.2-codex,gpt-5.3-codex) with:invoke()method for Braintrust promptsWere encountering errors because these models were being routed to the Chat Completions API (
/v1/chat/completions) instead of the Responses API (/v1/responses).Root Cause
The proxy routing logic only matched:
gpt-5-progpt-5-codexo1-proo3-proThe pattern
startsWith("gpt-5-codex")matched "gpt-5-codex" but NOT "gpt-5.1-codex", "gpt-5.2-codex", "gpt-5.3-codex", etc.Solution
Added a flexible pattern in
packages/proxy/src/proxy.ts:2092-2093that matches any gpt-5 codex variant:This pattern matches models that:
This is a conservative but future-proof approach that only routes codex variants to the Responses API, while leaving other gpt-5 models on the Chat Completions API.
Models Fixed
✅
gpt-5-codex✅
gpt-5.1-codex✅
gpt-5.1-codex-mini✅
gpt-5.2-codex✅
gpt-5.3-codex✅ Any future
gpt-5.x-codexvariantsModels Unchanged
Other gpt-5 models continue to use Chat Completions API:
gpt-5-minigpt-5-nanogpt-5.1gpt-5.1-2025-11-13gpt-5.1-chat-latestTesting
openai.test.tspassreasoning_effort: "minimal"are properly converted toreasoning.effort: "low"in the Responses API formatImpact
Files Changed
packages/proxy/src/proxy.ts- Added flexible gpt-5.x-codex routing patternpackages/proxy/src/providers/openai.test.ts- Updated test to reflect flexible pattern🤖 Generated with Claude Code