Codex: Codex Installation & Setup
Last updated: 2026-08-31
Codex offers multiple installation methods. Choose the one that best fits your operating system and workflow.
📋 Prerequisites: Basic command-line knowledge, Node.js installed (required for CLI method)
1. Installation Methods Overview
| Method | Use Case | Recommendation |
|---|---|---|
| Codex App | Desktop users, full-feature experience | ⭐⭐⭐⭐ |
| Codex CLI | Developer daily use, terminal workflow | ⭐⭐⭐⭐⭐ |
| Homebrew | Mac users | ⭐⭐⭐⭐ |
| Binary Package | No Node.js environment | ⭐⭐⭐ |
| IDE Plugin | VS Code / Cursor users | ⭐⭐⭐⭐ |
2. Codex App (Desktop Application)
The simplest method — download the desktop client directly.
Visit https://chatgpt.com/codex and download the app for your platform.
(1) Installation Steps
1. Visit chatgpt.com/codex
2. Click "Download for macOS/Windows"
3. Install the application
4. Log in with your ChatGPT account
5. Start using
(2) First Run
After logging in, you'll see a three-panel interface: task list on the left, conversation window in the center, and multi-function area on the right.
Codex App uses a classic three-panel layout: task list + conversation window + multi-function area.
3. Codex CLI (Command Line)
The most popular method among developers. CLI runs locally — your code is not uploaded to the cloud.
(1) Installation
# Install via npm
sudo npm install -g @openai/codex
# Mirror acceleration (China)
sudo npm install -g @openai/codex --registry=https://registry.npmmirror.com
(2) Login
First run requires authentication. Three options:
Option 1: ChatGPT Login (Recommended)
codex
# Select "Sign in with ChatGPT"
# Browser opens the login page automatically
Option 2: API Key Login
# macOS/Linux temporary
export OPENAI_API_KEY="sk-your-api-key"
# Permanent (add to shell config)
echo 'export OPENAI_API_KEY="sk-your-api-key"' >> ~/.zshrc
source ~/.zshrc
# Windows PowerShell
$env:OPENAI_API_KEY="sk-your-api-key"
# Launch with specific model
codex --model gpt-5-codex
Option 3: auth.json File
mkdir -p ~/.codex
cat > ~/.codex/auth.json << 'EOF'
{
"OPENAI_API_KEY": "sk-your-api-key"
}
EOF
(3) First Run
cd my-project
codex
# Enter: Analyze the current project structure
▶ Example 1: Alice's First Experience
# Alice creates a test project
mkdir codex-test && cd codex-test
# Create a simple file
echo 'print("Hello World")' > test.py
# Launch Codex
codex
# Alice enters:
# "Add command-line argument support to test.py, support --name parameter"
4. Three Runtime Modes
Codex CLI provides three security modes:
| Mode | Function | Security Level |
|---|---|---|
| Suggest | Only suggests changes, requires manual confirmation | High (default) |
| Auto Edit | Auto-modifies files, commands need confirmation | Medium |
| Full Auto | Auto-executes all operations | Low (use with caution) |
# Default mode
codex
# Auto Edit mode
codex --auto-edit
# Full Auto mode
codex --full-auto
▶ Example 2: Mode Selection
def choose_mode(task_risk, task_complexity):
if task_risk == "high":
return "Suggest - confirm each action for safety"
elif task_complexity == "low":
return "Full Auto - simple tasks done quickly"
else:
return "Auto Edit - files auto-edited, commands human-reviewed"
5. Homebrew Installation (Mac Recommended)
# Install
brew install --cask codex
# Run
codex
Ideal for Mac developers who don't want to install Node.js.
6. Binary Package Installation
Download directly from GitHub Release:
# Download URL: https://github.com/openai/codex/releases
# Mac Apple Silicon
tar -xzf codex-aarch64-apple-darwin.tar.gz
# Linux
tar -xzf codex-x86_64-unknown-linux-musl.tar.gz
# Add to PATH
sudo mv codex /usr/local/bin
# Run
codex
7. IDE Plugin Installation
Supports VS Code, Cursor, Windsurf, and other IDEs.
(1) Installation Steps
1. Open your IDE's extension marketplace
2. Search for "Codex"
3. Install the plugin
4. Log in with your ChatGPT account
(2) IDE Features
- Auto-fix code
- Auto-generate functions
- Auto-refactor code
- Right-click selected code to send to Codex
8. Update & Uninstall
# CLI update
npm update -g @openai/codex
# Force reinstall latest
npm install -g @openai/codex@latest
# Uninstall
npm uninstall -g @openai/codex
# Homebrew uninstall
brew uninstall --cask codex
9. System Support
| System | Support Status |
|---|---|
| macOS | Fully supported |
| Linux | Fully supported |
| Windows | Experimental (WSL recommended) |
10. Network Issues
Users in China may encounter network barriers when accessing Codex. Consider:
- Using a network proxy
- Trying similar products like Alibaba Qoder Quest or ByteDance Trae Solo
❓ FAQ
codex --version to see the current version.📖 Summary
- Five installation methods: App / CLI / Homebrew / Binary / IDE Plugin
- CLI is the developer's first choice —
npm install -g @openai/codexdoes it in one line - Three security modes: Suggest / Auto Edit / Full Auto
- First run requires login: ChatGPT login (recommended) / API Key / auth.json
- Windows users should use WSL
📝 Exercises
- Basic (⭐): Install Codex CLI and successfully log in. Take a screenshot of your first run interface.
- Intermediate (⭐⭐): Complete the same task using both Suggest and Auto Edit modes, and compare the experience.
- Advanced (⭐⭐⭐): Install Codex CLI in a WSL environment and write an installation troubleshooting guide.