Codex CLI Installation & Setup Guide
What is Codex CLI
Codex CLI is OpenAI’s open-source AI coding assistant. Like Claude Code, it runs in your terminal — reading code, editing files, running commands. It’s fully open-source (Apache-2.0) and works with ChatGPT Plus or any OpenAI-compatible API.
GitHub 85k+ stars, active community.
Installation Demo
Here’s the full installation process recorded (you can scrub the timeline and adjust speed):
Installation Steps
1. Install Codex CLI
# Linux / WSL / macOS (official)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# macOS (Homebrew)
brew install --cask codex
# Or via npm
npm install -g @openai/codex
The official script auto-detects your platform and downloads the correct binary.
2. Configure API Relay (Optional)
If you don’t have a ChatGPT Plus subscription, you can use a third-party API relay service. Register at sbbbbbbbbb.xyz for a 5% first-order discount:
Plans:
| Plan | Price | Daily Quota | Duration |
|---|---|---|---|
| Monthly | ¥48.99 | $150/day | 30 days |
| Weekly | ¥16.88 | $70/day | 7 days |
💡 One key works for both Codex CLI and Claude Code.
After registration, edit ~/.codex/config.toml:
model = "gpt-5.4"
model_provider = "necodex"
model_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "danger-full-access"
disable_response_storage = true
[model_providers.necodex]
name = "NeCodeX API"
base_url = "https://fast.sbbbbbbbbb.xyz/v1"
experimental_bearer_token = "sk-paste-your-key-here"
wire_api = "responses"
supports_websockets = false
3. Verify Installation
codex --version
You should see something like codex-cli 0.133.0.
4. Authentication
Two options:
Option A: API Relay (recommended, configured above)
Just run codex "hello" to verify it works.
Option B: ChatGPT Account
If you have ChatGPT Plus/Pro/Enterprise:
codex
Select “Sign in with ChatGPT” on first run. No relay config needed.
Basic Usage
Interactive Mode
# Start interactive session
codex
# Start in a project directory
cd my-project
codex
One-shot Commands
# Ask a question
codex "explain the architecture of this project"
# Edit code
codex "add unit tests for this function"
# Execute tasks
codex "find all TODO comments and fix them"
Configuration
Approval Modes
Codex has three safety modes:
| Mode | Description | Use Case |
|---|---|---|
| Read Only | Read code only, no modifications | Code review, understanding |
| Auto | Auto-execute safe ops, confirm dangerous ones | Daily development |
| Full Access | Fully autonomous, no confirmation | Trusted automation |
Select at startup or via flag:
codex --approval-mode auto
Model Selection
# Switch model in session
/model
Claude Code vs Codex CLI
| Aspect | Claude Code | Codex CLI |
|---|---|---|
| Vendor | Anthropic | OpenAI |
| Open Source | ❌ | ✅ Apache-2.0 |
| Model | Claude Opus/Sonnet | GPT-4o/o3 |
| Auth | API Key or subscription | ChatGPT account or API Key |
| Approval | Permission config file | Three-tier selection |
| Strength | Deep code understanding | Community ecosystem, plugins |
Install both. Switch based on the task. Complex refactoring → Claude Code. Quick Q&A → Codex.
Tips
- Start in your project root for best results
/helpto see all slash commands/modelto switch models and reasoning effort- Supports image input (paste screenshots of errors)
- Open-source — customize it, community plugins available
Links
- API Relay (5% off first order): https://api.sbbbbbbbbb.xyz/register?aff=4HAA
- Codex CLI GitHub: https://github.com/openai/codex
- Codex Official Docs: https://developers.openai.com/codex