Skip to content

openai: ChatGPT OAuth requests use Zen API key #49847

Description

@jhsu

Description

incorrectly binds the OpenAI provider to the OpenCode Zen integration, causing a Zen API key to be sent to ChatGPT’s OAuth-only Codex endpoint. OpenAI rejects the key with “API keys are not supported by this endpoint.” The correct OpenAI OAuth credential works when restored at request time.

ChatGPT OAuth login succeeds and stores a valid token, but OpenAI model requests fail with:

API keys are not supported by this endpoint.

The request goes to the correct ChatGPT Codex endpoint and includes the correct chatgpt-account-id, but its Authorization header contains the OpenCode Zen API key instead of the OpenAI OAuth token.

Re-authenticating with OpenAI does not help. This began without any local configuration changes.

Expected: requests routed to the ChatGPT Codex endpoint use the credential from the openai integration.

Plugins

No response

OpenCode version

2.0.8

Steps to reproduce

  1. Have an OpenCode Zen credential configured.
  2. Run opencode auth login openai and complete ChatGPT OAuth in the browser.
  3. Run:
    opencode run --model openai/gpt-5.6-luna "hi"
  4. Observe:
    API keys are not supported by this endpoint.

The outgoing request targets:
https://chatgpt.com/backend-api/codex/responses
but uses the Zen API key in Authorization rather than the ChatGPT OAuth token.

Screenshot and/or share link

No response

Operating System

macOS 25.5.0

Terminal

Ghostty

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions