Codex CLI Relay Setup Guide
OpenAI's official AI programming CLI — use it without an OpenAI account. Configure OPENAI_BASE_URL with a relay for China-direct access.
// What is Codex CLI
What is Codex CLI?
Codex CLI is OpenAI's official command-line coding tool, built on GPT-4o and GPT-5 models. Similar to Claude Code, it provides conversational code editing. Unlike Claude Code, it uses OpenAI's model family.
// Key advantage: No OpenAI account needed — use it directly through a relay.
Codex CLI vs Claude Code
Both are CLI coding assistants with similar positioning. Core difference: Codex uses OpenAI GPT series, Claude Code uses Anthropic Claude series. They each have advantages on different tasks — choose based on your actual experience.
| Feature | Codex CLI | Claude Code |
|---|---|---|
| Underlying Model | GPT-4o / GPT-5 | Claude Sonnet / Opus 4 |
| Developer | OpenAI | Anthropic |
| Model Style | Strong at code completion, simple tasks | Strong at architecture design, complex reasoning |
| Context Window | 200K | 200K |
| Relay Support | Most platforms supported | Most platforms supported |
// Recommended
Recommended Platforms
These platforms have strong Codex CLI support
CodeCMD — Four-Tool Support
Claude Code + Codex + OpenCode + ClawdBot universal, $200 Max account pool dynamic scheduling.
SSSAiCode — Lowest Multiplier
0.45x multiplier, credits never expire. Claude Code + Codex + Gemini CLI all supported.
AICoding — Plug and Play
Claude Code + Codex dual support, one-click install, zero config.
// Installation
Install Codex CLI
Official CLI tool, cross-platform support
macOS / Linux
Install via npx or npm
# Install globally via npm
npm install -g @openai/codex
# Or run directly with npx (no install needed)
npx @openai/codexWindows
Install via npm
# Install globally via npm
npm install -g @openai/codex// Codex CLI officially requires an OpenAI API Key, which must be purchased from OpenAI (requires an overseas credit card). With a relay, you only need the relay-provided Key and endpoint URL to bypass this restriction.
// Configure Relay
Configure Your Relay
Set environment variables to replace official endpoints
Get Relay API Key
Register on your chosen relay platform and get your API key. Note: Codex CLI uses an interface format compatible with standard OpenAI API.
Set Environment Variables
Configure OPENAI_API_KEY and OPENAI_BASE_URL environment variables.
# Bash / Zsh / Linux
# Temporary (current session)
export OPENAI_API_KEY="your-relay-api-key"
export OPENAI_BASE_URL="https://your-relay.com/v1"
# Permanent (add to config file)
echo 'export OPENAI_API_KEY="your-relay-api-key"' >> ~/.bashrc
echo 'export OPENAI_BASE_URL="https://your-relay.com/v1"' >> ~/.bashrc
source ~/.bashrcLaunch Codex
Run codex, enter your API key when prompted.
// Verification
Verification
Confirm your setup and start using Codex CLI
Launch Codex CLI
Run the codex command. On first launch it will prompt for your API Key.
# Run directly
codex
# Or verify version
codex --versionCommon Parameters
Codex CLI supports various parameters for specifying models and run modes.
# Specify model
codex --model gpt-4o
# Specify working directory
codex --directory ./my-project
# Preview mode (no execution)
codex --no-execute// FAQ