fix(codex): advertise a paid plan in the stub id_token so OAuth codex routes to chatgpt.com - #426
Open
robbyczgw-cla wants to merge 1 commit into
Open
Conversation
… routes to chatgpt.com codex-cli >= 0.14x picks its model backend from the chatgpt_plan_type claim in the id_token. The stub advertised "free", which routes model calls to wss://api.openai.com/v1/responses (API mode) where the injected ChatGPT-OAuth subscription token is rejected with 401. Advertising a paid plan routes codex to wss://chatgpt.com/backend-api/codex/responses, where the injected subscription token is valid. The real entitlement remains enforced upstream by the injected token. Fixes onecli#425 Co-Authored-By: Claude <noreply@anthropic.com>
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.
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
Fixes #425.
Codex model calls made with a ChatGPT-OAuth (subscription) credential fail with:
The stub
id_tokeninpackages/api/src/lib/codex-stubs.tsadvertiseschatgpt_plan_type: "free". codex-cli (>= 0.14x) selects its model backend from this claim: a free plan routes towss://api.openai.com/v1/responses(API mode), where the injected ChatGPT-OAuth subscription token is not accepted → 401. The credential injection is correct; only the routing is wrong.What is the new behavior?
The stub
id_tokennow advertises a paid plan (plus), so codex routes towss://chatgpt.com/backend-api/codex/responses, where the injected subscription token is accepted. The real entitlement stays enforced upstream by the injected token — this claim only steers routing.The functional change (the single
chatgpt_plan_typeclaim in the stub JWT) is identical to what we have compiled and running in production: after it, theapi.openai.comWS 401s stop and codex traffic flows overchatgpt.com/backend-api/codex/responseswith injections applied, returning 200.Additional context
Single data-literal change (one claim in the stub JWT) plus an explanatory comment. Gateway logs from one Codex session before the fix:
HTTP calls to
chatgpt.cominject fine; only theapi.openai.comWS upgrade 401s — consistent with wrong-endpoint routing rather than a missing injection.