feat(provider): add chatgpt provider with ChatGPT account sign-in#3512
Open
Sayt-0 wants to merge 1 commit into
Open
feat(provider): add chatgpt provider with ChatGPT account sign-in#3512Sayt-0 wants to merge 1 commit into
Sayt-0 wants to merge 1 commit into
Conversation
Adds a chatgpt model provider that uses a ChatGPT Plus/Pro/Business subscription instead of an OPENAI_API_KEY, via the same OAuth PKCE flow as OpenAI's Codex CLI. `docker agent auth login chatgpt` stores the credential; the access token is refreshed transparently and exposed to credential detection (doctor, setup, auto selection, first_available) as the virtual CHATGPT_OAUTH_TOKEN variable served by a new chatgpt-login environment source. Requests target the ChatGPT Codex backend (Responses API only) with the required headers and request shape.
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.
Summary
Adds a
chatgptmodel provider that uses a ChatGPT Plus/Pro/Business subscription instead of anOPENAI_API_KEY, via the same OAuth PKCE flow as OpenAI's Codex CLI.docker agent auth login chatgptstores the credential; the access token is refreshed transparently and surfaces through the standard credential machinery (doctor, setup, auto selection,first_available).How it works
Serving the login as a virtual env var lets every env-var-driven consumer work without special cases, while an explicitly set
CHATGPT_OAUTH_TOKEN(e.g. a pre-minted token in CI) keeps precedence over the stored sign-in.Changes
pkg/chatgpt(new)docker agent auth(new)login/logout/status [--json], shell completion, telemetrychatgptproviderdoctorchatgpt-login) and a sign-in hint in issuessetupchatgptordered right afteropenai, so behavior is unchanged for existing API-key users; default modelgpt-5.2CHATGPT_OAUTH_TOKENis missinggo testwithout an explicit overrideexamples/chatgpt.yamlRequest shape (Codex backend)
/responses; an explicitapi_typeoverride is ignored (debug-logged)storemust be falseinstructionsrequiredtemperature,top_p,max_output_tokensdropped (debug-logged)chatgpt-account-idparsed from the JWT claimsValidation
go build ./...and js/wasm build of touched packagesgo test ./...golangci-lint run,go run ./lint .,go mod tidy --diff37 new tests cover the OAuth mechanics (fake issuer: PKCE parameters, state validation, code exchange, refresh and token rotation), request shaping (fake Codex backend: endpoint, headers, instructions extraction, multi-turn tool calls), doctor/setup/auto integration, and the auth commands.
Notes
pkg/model/provider/openai/chatgpt.go.