Bridge between Anthropic's Claude Code CLI and OpenAI Codex (ChatGPT Plus/Pro subscription).
Lets you run claude using your existing ChatGPT plan instead of a separate Anthropic API key or subscription.
Claude Code → localhost proxy (Anthropic format)
→ codex-proxy (translates to OpenAI Responses API)
→ chatgpt.com/backend-api/codex/responses
- Authenticates via OAuth with your OpenAI account (same as opencode's Codex plugin)
- Translates Anthropic Messages API and OpenAI-compatible requests to Codex Responses on the fly
- Routes through
chatgpt.com/backend-api/codex/responsesusing your subscription token - Maps Claude models to equivalent GPT models (e.g.
claude-opus-4-7→gpt-5.5)
- Node.js 18+
- A ChatGPT Plus, Pro, or Team subscription with Codex access
- Claude Code CLI
# 1. Authenticate with OpenAI (one-time)
./codex-proxy.js auth
# 2. Start the proxy (leave running in a terminal)
./codex-proxy.js proxy 9876
# 3. In a separate terminal, run Claude Code through the proxy
ANTHROPIC_BASE_URL=http://127.0.0.1:9876 ANTHROPIC_API_KEY=any claude --bare
# Or point OpenAI-compatible clients at the same proxy
OPENAI_BASE_URL=http://127.0.0.1:9876/v1 OPENAI_API_KEY=any your-openai-client| Command | Description |
|---|---|
codex-proxy.js auth [browser|headless] |
Authenticate with OpenAI (browser or device flow) |
codex-proxy.js proxy [port] |
Start proxy server (default port: 9876) |
codex-proxy.js token |
Print current access token |
-
Auth: Uses OAuth PKCE flow (browser) or device code flow (headless) to authenticate with your OpenAI/ChatGPT account. Tokens are stored in
~/.opencode-codex/token.jsonand auto-refreshed. -
Translation: Converts Anthropic Messages API requests and OpenAI-compatible
/v1/responsesor/v1/chat/completionsrequests to OpenAI Responses API format:- System prompts →
instructionsfield - User/assistant messages →
inputarray - Tool definitions →
toolsarray - Tool calls →
function_call/function_call_outputitems
- System prompts →
-
Routing: Forwards to
https://chatgpt.com/backend-api/codex/responseswith your OAuth access token. -
Response: Streams Codex SSE events back as Anthropic SSE when Claude requests streaming, or returns Anthropic JSON for non-streaming requests.
Set these environment variables before starting the proxy:
| Variable | Description | Default |
|---|---|---|
CODEX_PROXY_REASONING_EFFORT |
Codex reasoning effort for normal requests | low |
CODEX_PROXY_TEXT_VERBOSITY |
Codex text verbosity | low |
CODEX_PROXY_INFLIGHT_LOG_MS |
Interval for verbose in-flight waiting logs; set 0 to disable |
15000 |
CODEX_PROXY_RESPONSE_TIMEOUT_MS |
Total response timeout/retry budget; set 0 to disable |
45000 |
CODEX_PROXY_VERBOSE_LOGS |
Set to 1 for detailed per-stage request logs |
0 |
CODEX_PROXY_LOG_STREAM_EVENTS |
Set to 1 to include per-event stream logs |
0 |
- The proxy streams responses to Claude Code when
stream: trueis requested. - Before an upstream response starts, response timeouts are retried across 3 attempts with 10s/20s exponential backoff inside the response timeout budget.
- Requests use Claude's session metadata as a stable
prompt_cache_keywhen available. - Default per-request logs include request summaries, completion summaries, and errors. Set
CODEX_PROXY_VERBOSE_LOGS=1for detailed timing and stream diagnostics. - Token refresh happens automatically when the access token expires (checks before each request).
- Model mapping: Claude models → GPT equivalents:
claude-sonnet-4-*,claude-opus-4-*,claude-3-5-sonnet-*→gpt-5.5claude-haiku-3-5*,claude-3-5-haiku*→gpt-5.4-mini- Detected compact/summary requests for other models →
gpt-5.4-mini - Unknown models default to
gpt-5.5(logged to stderr). - Model routing is fixed and has no environment variable override.