anomalyco / anomalyco/opencode

openai: ChatGPT OAuth requests use Zen API key

Open
#49,847 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the OpenAI integration credential selection used by ChatGPT Codex requests, then compare the credential stored by opencode auth login openai with the outgoing Authorization header. Reproduce with opencode run --model openai/gpt-5.6-luna "hi"; done means the ChatGPT Codex endpoint uses the OpenAI OAuth token while the Zen API key remains separate.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, authentication, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.