{"slug": "claudex-use-claude-code-s-interface-with-gpt-codex-models-through-cliproxyapi", "title": "claudex: use Claude Code's interface with GPT/Codex models through CLIProxyAPI", "summary": "A developer created claudex, a tool that allows users to run OpenAI's GPT/Codex models through Claude Code's interface and terminal UX. It uses a local CLIProxyAPI server to translate and route requests, preserving the original Claude Code and Codex configurations. The tool is designed for developers who prefer Claude Code's agent harness but want to use GPT models underneath.", "body_md": "Inspired by\n\n[Theo's original post on X].\n\nThe basic idea: if you prefer Claude Code's agent harness and terminal UX to the Codex CLI, `claudex`\n\nlets you keep Claude Code's interface, tools, permissions, plugins, and workflow while using GPT/Codex models underneath. A local [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) server translates and routes Claude Code's requests to a model available through Codex OAuth.\n\nThe important isolation rule is:\n\n`claude`\n\ncontinues to work normally with its existing account and configuration.`codex`\n\ncontinues to work normally with its existing configuration.- Only\n`claudex`\n\nuses the local proxy and the selected Codex model.\n\n```\nSet up a new `claudex` command on my machine. It must run the Claude Code CLI interface and tooling while using `gpt-5.6-sol` through my Codex OAuth account and a localhost-only CLIProxyAPI server.\n\nRequirements:\n\n1. Inspect before changing anything\n   - Locate `cli-proxy-api`, `claude`, and `codex` and report their versions.\n   - Inspect `cli-proxy-api --help` and any installed example config or systemd unit.\n   - Inspect my shell configuration for existing `claude`, `claudex`, or similar aliases/functions.\n   - Preserve all existing Claude Code and Codex behavior.\n   - Do not print existing OAuth tokens, API keys, or credential-file contents.\n\n2. Install CLIProxyAPI if it is missing\n   - Use the official CLIProxyAPI quick-start documentation for the detected operating system. Do not invent package names or download URLs.\n   - macOS with Homebrew:\n     `brew install cliproxyapi`\n     Be aware that `brew services` expects its config at `$(brew --prefix)/etc/cliproxyapi.conf`. If this setup uses `~/.cli-proxy-api/config.yaml`, safely back up any existing Homebrew config and symlink that expected path to the user config before starting the service.\n   - Arch Linux:\n     `yay -S cli-proxy-api-bin`\n     or `paru -S cli-proxy-api-bin`\n     The package includes an example config and a systemd user service.\n   - Other Linux distributions:\n     use the official installer from `router-for-me/cliproxyapi-installer`. Download it to a temporary file, inspect it, then run it; do not blindly execute a remote script if the environment's security policy forbids that.\n   - Windows:\n     use the current binary from the official GitHub releases page. This particular `claudex` alias targets zsh on macOS/Linux/WSL; adapt it to a PowerShell function only if the user explicitly wants native Windows.\n   - Building from source is a fallback only when packages/releases are unsuitable; use the repository's documented `go build -o cli-proxy-api ./cmd/server` command and verify the required Go version first.\n   - After installation, run `cli-proxy-api --help` and record the installed version. Confirm that the build exposes Codex and Claude OAuth flags before continuing.\n   - Do not start the background service until a valid config file exists.\n\n3. Configure CLIProxyAPI\n   - Use `~/.cli-proxy-api/config.yaml` unless the installed service requires another path.\n   - Bind only to `127.0.0.1` on port `8317`.\n   - Disable TLS for this localhost-only connection.\n   - Disable remote management and its control panel.\n   - Use `~/.cli-proxy-api` as the OAuth auth directory.\n   - Generate a new cryptographically random local API key. Never use an example or predictable key.\n   - Store the client copy in `~/.cli-proxy-api/client.key`, not directly in the shell alias.\n   - Set the directory to mode `0700` and all config, key, and OAuth JSON files to mode `0600`.\n   - Keep normal retry defaults and use round-robin routing with session affinity disabled.\n\n   The effective server config should be equivalent to:\n\n   host: \"127.0.0.1\"\n   port: 8317\n   tls:\n     enable: false\n     cert: \"\"\n     key: \"\"\n   remote-management:\n     allow-remote: false\n     secret-key: \"\"\n     disable-control-panel: true\n   auth-dir: \"~/.cli-proxy-api\"\n   api-keys:\n     - \"GENERATE_A_RANDOM_LOCAL_KEY\"\n   debug: false\n   logging-to-file: false\n   usage-statistics-enabled: false\n   request-retry: 3\n   max-retry-credentials: 0\n   max-retry-interval: 30\n   routing:\n     strategy: \"round-robin\"\n     session-affinity: false\n   ws-auth: true\n\n4. Run it as a user service\n   - Prefer the systemd user unit included by the installed CLIProxyAPI package.\n   - If no unit exists, create a user unit whose ExecStart runs the discovered binary with `-config %h/.cli-proxy-api/config.yaml`, restarts on failure, and starts after the network is available.\n   - Run `systemctl --user daemon-reload` and enable/start the service.\n   - Verify it is active and listening only on `127.0.0.1:8317`.\n\n5. Authenticate both upstream accounts\n   - Run the installed binary's Codex OAuth flow with the explicit config path. Current CLIProxyAPI builds use:\n     `cli-proxy-api -config ~/.cli-proxy-api/config.yaml -codex-login`\n   - Let me complete the browser approval when prompted.\n   - Run the Claude OAuth flow similarly:\n     `cli-proxy-api -config ~/.cli-proxy-api/config.yaml -claude-login`\n   - Let me complete that browser approval too.\n   - After each login, set newly created OAuth JSON files to mode `0600`.\n   - Confirm the service hot-loaded both credentials, restarting it only if necessary.\n\n6. Add only the `claudex` alias\n   - Add the following logical alias to the correct zsh startup file, adapting paths if my shell or home layout differs:\n\n   alias claudex='ANTHROPIC_BASE_URL=http://127.0.0.1:8317 ANTHROPIC_AUTH_TOKEN=\"$(<\"$HOME/.cli-proxy-api/client.key\")\" CLAUDE_CODE_SUBAGENT_MODEL=gpt-5.6-sol CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1 CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY=3 ENABLE_TOOL_SEARCH=false claude --model gpt-5.6-sol'\n\n   - Keep these environment variables invocation-scoped. Do not export them globally and do not add them to `~/.claude/settings.json`.\n   - Preserve argument forwarding so commands such as `claudex --continue`, `claudex --resume`, and `claudex -p \"...\"` work.\n   - Do not redefine or wrap the normal `claude` or `codex` commands.\n\n7. Verify the complete setup\n   - An unauthenticated request to `http://127.0.0.1:8317/v1/models` must be rejected.\n   - An authenticated request using `client.key` must succeed.\n   - Confirm the returned model catalog contains `gpt-5.6-sol` and Claude models.\n   - If `gpt-5.6-sol` is unavailable, stop and tell me; do not silently choose another model.\n   - Run `claudex --version` to confirm argument forwarding.\n   - Run one minimal request: `claudex -p \"Reply with exactly: claudex route works\"`.\n   - Require the exact successful response before declaring completion.\n   - Open a clean shell and prove `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` are unset globally.\n   - Prove normal `claude` and `codex` still resolve exactly as they did before.\n   - Report the final service status and credential permissions without revealing any secrets.\n\nSecurity constraints:\n\n- Never expose the proxy beyond localhost.\n- Never commit, paste, log, or display the generated local key or OAuth credentials.\n- Do not weaken TLS verification, Claude Code permissions, or sandbox settings.\n- Do not overwrite whole config files when a narrow merge is possible.\n- Ask me only for browser OAuth approval or genuinely missing product choices; handle discoverable machine details yourself.\n```\n\n`ANTHROPIC_BASE_URL`\n\nsends this Claude Code invocation to the local Anthropic-compatible proxy.`ANTHROPIC_AUTH_TOKEN`\n\nauthenticates to the local proxy using a protected file.`--model gpt-5.6-sol`\n\nselects the Codex-backed model for the main Claude Code session.`CLAUDE_CODE_SUBAGENT_MODEL`\n\nkeeps Claude Code subagents on the same model.`CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1`\n\nenables effort controls for the custom model.`CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY=3`\n\ncaps concurrent tool calls.`ENABLE_TOOL_SEARCH=false`\n\ndisables dynamic tool search on the non-Anthropic gateway.\n\nBecause all variables are attached to the alias invocation, they do not change the normal `claude`\n\nor `codex`\n\nenvironment.\n\n```\nclaudex\nclaudex --continue\nclaudex --resume\nclaudex -p \"Explain this repository\"\n```\n\nModel availability depends on the authenticated Codex account and the CLIProxyAPI version. Do not rename or silently substitute the requested model if it is missing from `/v1/models`\n\n.\n\nCLIProxyAPI changes quickly, so check the linked quick-start page before copying a command.\n\n```\nbrew install cliproxyapi\n```\n\nWhen managed by `brew services`\n\n, Homebrew reads `$(brew --prefix)/etc/cliproxyapi.conf`\n\n. The official docs show how to symlink that path to `~/.cli-proxy-api/config.yaml`\n\nif you want the same layout used in this guide.\n\n```\nyay -S cli-proxy-api-bin\n# or\nparu -S cli-proxy-api-bin\n```\n\nThe AUR package includes `/usr/share/doc/cli-proxy-api-bin/config.example.yaml`\n\nand a systemd user unit. Create the config before enabling the service.\n\nThe official quick start currently provides this installer:\n\n```\ncurl -fsSL https://raw.githubusercontent.com/router-for-me/cliproxyapi-installer/refs/heads/master/cliproxyapi-installer | bash\n```\n\nFor a safer agent workflow, download the installer to a temporary file, inspect it, and then execute it instead of piping it directly to a shell.\n\nDownload the appropriate binary from the project's official GitHub releases. Native Windows needs a PowerShell equivalent of the zsh alias; WSL can follow the Linux/zsh flow.\n\n[CLIProxyAPI repository](https://github.com/router-for-me/CLIProxyAPI)[CLIProxyAPI official quick start and installation](https://help.router-for.me/introduction/quick-start)[CLIProxyAPI basic configuration](https://help.router-for.me/configuration/basic)[CLIProxyAPI example configuration](https://github.com/router-for-me/CLIProxyAPI/blob/main/config.example.yaml)[CLIProxyAPI Codex OAuth](https://help.router-for.me/configuration/provider/codex)[CLIProxyAPI Claude OAuth](https://help.router-for.me/configuration/provider/claude-code)[CLIProxyAPI Claude Code client configuration](https://help.router-for.me/agent-client/claude-code)[Claude Code environment variables](https://code.claude.com/docs/en/env-vars)[Claude Code authentication and credential precedence](https://code.claude.com/docs/en/team)[Claude Code model configuration](https://code.claude.com/docs/en/model-config)[Original](https://x.com/theo/status/2076114415368482854)`claudex`\n\ninspiration from Theo", "url": "https://wpnews.pro/news/claudex-use-claude-code-s-interface-with-gpt-codex-models-through-cliproxyapi", "canonical_source": "https://gist.github.com/krankos/9925f7e29e3980f8525e67445ae453f2", "published_at": "2026-07-12 16:23:26+00:00", "updated_at": "2026-07-12 16:39:25.557639+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "large-language-models", "ai-agents"], "entities": ["Claude Code", "Codex CLI", "CLIProxyAPI", "GPT", "Codex OAuth", "Theo"], "alternates": {"html": "https://wpnews.pro/news/claudex-use-claude-code-s-interface-with-gpt-codex-models-through-cliproxyapi", "markdown": "https://wpnews.pro/news/claudex-use-claude-code-s-interface-with-gpt-codex-models-through-cliproxyapi.md", "text": "https://wpnews.pro/news/claudex-use-claude-code-s-interface-with-gpt-codex-models-through-cliproxyapi.txt", "jsonld": "https://wpnews.pro/news/claudex-use-claude-code-s-interface-with-gpt-codex-models-through-cliproxyapi.jsonld"}}