codex-for-claude-code
v0.2.6
Published
Run Claude Code against ChatGPT Codex via your Codex CLI OAuth.
Readme
codex-for-claude-code
Run Claude Code against ChatGPT Codex using your existing Codex CLI subscription.
[!IMPORTANT] If you hit a 401 error, just launch the Codex CLI once (
codex) to refresh the OAuth token, then rerunclaude-codex.
Install
Requires Node.js ≥ 20, Claude Code, and a logged-in Codex CLI (codex login).
npm install -g codex-for-claude-codeHow to run
claude-codex # launch Claude Code in Codex mode
claude-codex --resume my-session # any extra args forward to `claude`How it works
Claude Code TUI ──► codex-proxy :3099 ──► chatgpt.com/backend-api/codex
(translates Anthropic ↔ Responses API,
auth: Codex OAuth from ~/.codex/auth.json)On each launch claude-codex:
- Reads
~/.codex/auth.jsonfor your Codex OAuth token. - Starts the local proxy on
127.0.0.1:3099(if not already running). - Uses an isolated Claude config dir
~/.claude-codexso Codex model-picker state cannot bleed into plainclaudewindows. Shared assets (settings.json,agents,commands,hooks,plugins) are symlinked from~/.claudeso there is still one source of truth for configuration. - Writes Codex model options to
~/.claude-codex/.claude.json— Claude Code v2.1+ reads${CLAUDE_CONFIG_DIR}/.claude.json(non-hashed) to populate the model picker. - Spawns
claudewithANTHROPIC_BASE_URL=http://127.0.0.1:3099andCLAUDE_CONFIG_DIR=~/.claude-codex.
Claude model IDs (claude-*, opus, sonnet, haiku) pass through unchanged to api.anthropic.com. Only Codex IDs hit ChatGPT.
Troubleshooting
401 Unauthorized from ChatGPT backend
OAuth token expired. Run codex once to refresh, then rerun claude-codex.
**No Codex auth: login via \codex` CLI**
Run codex login. Verify ~/.codex/auth.jsoncontainstokens.access_token`.
Could not find Claude Code binary
Install Claude Code, or set CLAUDE_CODEX_CLAUDE_BIN=/path/to/claude.
Model picker shows only Claude models
Quit the TUI and relaunch claude-codex.
claude-codex --resume cannot see my plain Claude sessions
Current builds keep session/history interoperability by symlinking shared Claude assets from ~/.claude into ~/.claude-codex. If plain claude sessions still do not appear, restart both TUIs so they reread the shared config tree.
Port 3099 in use
pkill -f codex-proxy.mjs or set CODEX_PROXY_PORT=3199.
Requests hang / 502
curl http://127.0.0.1:3099/health. Next claude-codex run auto-restarts on version mismatch.
MIT © Yusang Park
