Repository navigation
fix(gateway): list every model a ChatGPT account can use; stop forwarding the ChatGPT app's identity - #217
Merged
Conversation
…ding the ChatGPT app's identity The Codex backend hides models whose minimal_client_version is above the client_version a client reports when it lists models. ThinkWatch reported 0.0.0, so gpt-6-luna (which needs 0.155.0) was missing from a ChatGPT account upstream's list, and requests for it were refused with "No upstream serves model ..." although the account can use it: a Free account generates with it normally. Report 99999.0.0 instead, so the list shows whatever the account can use and the client decides what it can drive. Who is asking is still stated by ThinkWatch's own originator and User-Agent. The Codex inside the ChatGPT desktop app, while signed in to ChatGPT, adds the app's per-request attestation (x-oai-attestation), its installation ID (x-codex-installation-id) and turn metadata that embeds the installation ID (x-codex-turn-metadata), and repeats the last two in the body's client_metadata. The gateway replaced originator, User-Agent and version but forwarded these, so the backend saw the official app's attestation on a token that ThinkWatch had obtained. The account's token was revoked within 20 seconds of the first such request. The three headers join IDENTITY_HEADERS: they are not forwarded to a ChatGPT account upstream and cannot be set in its configured headers. The two client_metadata entries are removed from passthrough bodies, and like the identity headers they are not reported as dropped fields. Co-Authored-By: Claude Opus 5.5 <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.
Two problems with ChatGPT account upstreams
1. New models were missing from the model list
The Codex backend hides models whose
minimal_client_versionis above theclient_versiona client reports onGET /models. Measured on 2026-09-27 with a Free account:client_version0.0.0,0.154.90.158.0,99999.0.0minimal_client_version0.155.0)ThinkWatch reported
0.0.0, so gpt-6-luna was not in the upstream's list and admission refused it withNo upstream serves model gpt-6-luna(the ChatGPT app offers it from its bundled catalog). The account can use it: a plain Responses request for gpt-6-luna with ThinkWatch's own identity completed normally.CLIENT_VERSIONis now99999.0.0: the list shows whatever the account can use, and the client decides what it can drive. It only filters the list;originatorandUser-Agentstill say ThinkWatch. A99999.0.0listing returned nothing beyond what0.158.0returns, and the account's token was still valid three minutes after it.2. The ChatGPT app's identity was forwarded
The Codex inside the ChatGPT desktop app, while signed in to ChatGPT, adds per request:
x-oai-attestation: an attestation generated by the appx-codex-installation-idx-codex-turn-metadata: JSON that embeds the installation IDIt also repeats
x-codex-installation-idandx-codex-turn-metadatainside the body'sclient_metadata.The gateway replaced
originator,User-Agentandversionbut forwarded all of these, so the backend received the official app's attestation on a token that ThinkWatch had obtained. On 2026-09-27 the account's token was revoked within 20 seconds of the first request the app sent through the gateway. The request itself succeeded, and later tests with ThinkWatch's own identity did not revoke the new token.tw_config::chatgpt::IDENTITY_HEADERS: they are not forwarded to a ChatGPT account upstream, and an upstream's configured headers cannot contain them.shape_passthroughremoves the twoclient_metadataentries. Like the identity headers, they are not reported as dropped fields, so a Codex request is not shown as translated.session_id,x-codex-window-idand the rest ofclient_metadataare forwarded as before.Tests
tw-gateway/tests/chatgpt.rs: a Codex request that carries the three headers and the twoclient_metadataentries reaches the backend without them, and withx-codex-window-idandclient_metadata.session_idintact. The models request usesclient_version=99999.0.0.chatgpt.rsunit tests:keeps_client_headerrefuses the three headers;shape_passthroughremoves only the identity entries and still reports onlymax_output_tokensas dropped.credential.rs: the three headers are rejected in a ChatGPT account upstream's configured headers.cargo fmt --check,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepass locally. No control-protocol change (25), no request store schema change (21), no new message codes.🤖 Generated with Claude Code