gpt-4 · gpt-4o

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 CLIInstallationRelay ConfigurationVerificationFAQ

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.

FeatureCodex CLIClaude Code
Underlying ModelGPT-4o / GPT-5Claude Sonnet / Opus 4
DeveloperOpenAIAnthropic
Model StyleStrong at code completion, simple tasksStrong at architecture design, complex reasoning
Context Window200K200K
Relay SupportMost platforms supportedMost platforms supported

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.

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/codex

Windows

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 Your Relay

Set environment variables to replace official endpoints

01

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.

02

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 ~/.bashrc
03

Launch Codex

Run codex, enter your API key when prompted.

Verification

Confirm your setup and start using Codex CLI

01

Launch Codex CLI

Run the codex command. On first launch it will prompt for your API Key.

# Run directly
codex

# Or verify version
codex --version
02

Common 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

Q1.Does Codex CLI need an OpenAI account?
Technically yes, but through a relay you can completely bypass this. The relay provides its own API key for using Codex CLI — no OpenAI account needed. This is the biggest value for China mainland developers.
Q2.What's the difference between Codex CLI and GitHub Copilot?
Codex CLI is a pure command-line tool interacting through conversation. GitHub Copilot is an IDE plugin focused on real-time code completion. Codex CLI is more flexible for complex multi-step tasks; Copilot is better for quick completions in daily coding.
Q3.GPT-4o or GPT-5 Codex — which is better?
GPT-5 Codex is OpenAI's latest and most capable model but also most expensive. GPT-4o is the value choice — more than enough for most coding tasks. Test with GPT-4o first, upgrade to GPT-5 based on your needs.
Q4.Does Codex CLI support Windows?
Yes — Codex CLI is Node.js-based and cross-platform compatible. But some relays have limited Windows support. Choose platforms explicitly marked as Windows-compatible.
Q5.Are there usage limits on Codex CLI?
When using via relay, limits depend on the platform's policy. Budget platforms usually have stricter rate limits; premium platforms are more relaxed. Check the platform's limit documentation before purchasing to avoid hitting walls at critical moments.

Browse All Platforms

View Platform List