Fix: Route gpt-5.1 models to Responses API#384
Merged
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.
💡 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
ankrgyl
reviewed
Feb 5, 2026
| bodyData?.model?.startsWith("gpt-5-pro") || | ||
| bodyData?.model?.startsWith("gpt-5-codex") | ||
| (bodyData?.model?.startsWith("gpt-5") && | ||
| bodyData?.model?.includes("-codex")) |
Contributor
There was a problem hiding this comment.
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.
ankrgyl
approved these changes
Feb 5, 2026
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.
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