Skip to content

Codex CLI Installation & Setup Guide

· 3 min read

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:

PlanPriceDaily QuotaDuration
Monthly¥48.99$150/day30 days
Weekly¥16.88$70/day7 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:

ModeDescriptionUse Case
Read OnlyRead code only, no modificationsCode review, understanding
AutoAuto-execute safe ops, confirm dangerous onesDaily development
Full AccessFully autonomous, no confirmationTrusted automation

Select at startup or via flag:

codex --approval-mode auto

Model Selection

# Switch model in session
/model

Claude Code vs Codex CLI

AspectClaude CodeCodex CLI
VendorAnthropicOpenAI
Open Source✅ Apache-2.0
ModelClaude Opus/SonnetGPT-4o/o3
AuthAPI Key or subscriptionChatGPT account or API Key
ApprovalPermission config fileThree-tier selection
StrengthDeep code understandingCommunity 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
  • /help to see all slash commands
  • /model to switch models and reasoning effort
  • Supports image input (paste screenshots of errors)
  • Open-source — customize it, community plugins available