Skip to content

Allow custom upstream URLs for the ChatGPT OAuth provider #1091

Closed as not planned

Description

@chris6621

Client or integration

Codex CLI / OpenAI-compatible client

Provider or upstream service

ChatGPT/Codex OAuth upstream

OpenCodex version

2.10.0

Endpoint or capability

ChatGPT OAuth provider, /v1/responses, custom upstream routing, and account pooling

Current behaviour

The built-in ChatGPT OAuth provider appears to require the canonical upstream URL:

https://chatgpt.com/backend-api/codex

When a custom baseUrl is configured, the provider loses its canonical openai status and codexAccountMode: "pool" is rejected by configuration validation.

This prevents ChatGPT OAuth traffic from being routed through a local OpenAI-compatible gateway or reverse proxy, such as Headroom.

The openai-responses adapter already forwards the relevant OAuth headers, including Authorization, ChatGPT-Account-Id, and Codex-related headers.

Expected behaviour

The built-in ChatGPT OAuth provider should allow a custom HTTP(S) baseUrl while retaining its OAuth credential and account-pool behaviour.

For example:

{
  "adapter": "openai-responses",
  "baseUrl": "http://127.0.0.1:8787/v1",
  "authMode": "forward",
  "codexAccountMode": "pool"
}

The OAuth credentials and headers could remain restricted to the built-in provider, while the upstream URL is configurable.

Minimal redacted request or reproduction

{
  "providers": {
    "openai": {
      "adapter": "openai-responses",
      "baseUrl": "http://127.0.0.1:8787/v1",
      "authMode": "forward",
      "codexAccountMode": "pool"
    }
  }
}

No credentials are included. This configuration is rejected because the provider is no longer considered the canonical built-in openai provider.

Actual response or error

codexAccountMode is valid only on the canonical built-in openai provider

Upstream documentation

The relevant protocol behaviour is the ChatGPT/Codex OAuth Responses API. No public specification was found for requiring the canonical upstream URL when using OAuth headers.

Related Hermes Agent issue:
NousResearch/hermes-agent#40913

Suggested mapping or implementation notes

Consider decoupling the OAuth provider identity and credential handling from the upstream URL validation. The built-in provider could retain the special OAuth/account-pool logic while allowing an explicitly configured HTTP(S) upstream.

A similar GPT OAuth upstream-routing issue was reported in Hermes Agent, where the credential-pool path hardcoded the ChatGPT Codex upstream. Hermes has started addressing that issue by separating OAuth credential handling from upstream URL resolution.

Additional context and attachments

This does not appear to be documented or tracked in the current public OpenCodex issues. The goal is to route the existing OAuth request through an OpenAI-compatible local gateway, not to alter or expose OAuth credentials.

Checks

  • I searched existing provider and compatibility issues.
  • The request and response were redacted.
  • The expected behaviour is based on a concrete client and gateway integration requirement.

Activity

  1. github-actions commented on Aug 6, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: unknown.

  2. added
    account-pool
    on Aug 6, 2026
  3. github-actions commented on Aug 6, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  4. added
    provider-compatibility
    provider
    proxy
    on Aug 6, 2026
  5. lidge-jun commented on Aug 6, 2026

    @lidge-jun
    Owner

    This is a legitimate request and we want to support it; flagging why it is not a quick change. The pool-eligibility gate that rejects non-default base URLs (src/config.ts provider validation) is deliberate: OAuth tokens for chatgpt.com must not be sendable to an arbitrary URL by a config edit, so lifting the restriction needs an explicit trust design (allowlist semantics, SSRF/private-network policy, and tests for header and account-selection behavior against a custom upstream). Keeping this open as a design-needed enhancement.

  6. chris6621 commented on Aug 6, 2026

    @chris6621
    Author

    Thank you for looking into this and for explaining the security concern.

    I agree that OAuth credentials should not be sent to an arbitrary endpoint through an accidental configuration change. My use case is an explicitly configured, trusted local gateway (Headroom), not unrestricted forwarding to arbitrary URLs.

    An allowlist or an explicit opt-in setting for custom OAuth upstreams would work well for this use case. I also agree that the OAuth headers, account-pool selection, and private-network/SSRF behavior should be covered by tests.

    Thanks for keeping this open as a design-needed enhancement.

  7. added
    enhancement
    on Aug 15, 2026
  8. lidge-jun commented on Aug 18, 2026

    @lidge-jun
    Owner

    Closing on the security boundary discussed above. Pointing the ChatGPT OAuth provider at a custom upstream means sending OAuth credentials to a non-canonical endpoint, and a configuration-file field that can redirect credentials is exactly the shape of quiet exfiltration we hard-block elsewhere (the web-search sidecar keyed-backend design in #1616 fails closed on the same principle). An explicit allowlist/opt-in design was suggested, but the risk-to-benefit for a trusted-local-gateway use case does not justify opening that surface now — a local gateway can already sit in front of the proxy at the network layer without touching credential destinations. If a concrete design with a capability-gated, non-config-editable consent path materializes, reopen with that design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolenhancementproviderprovider-compatibilityproxy

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions