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

TEXT 📖 Display only
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

BASH
# 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)

BASH
codex
# Select "Sign in with ChatGPT"
# Browser opens the login page automatically

Option 2: API Key Login

BASH
# 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

BASH
mkdir -p ~/.codex
cat > ~/.codex/auth.json << 'EOF'
{
  "OPENAI_API_KEY": "sk-your-api-key"
}
EOF

(3) First Run

BASH
cd my-project
codex
# Enter: Analyze the current project structure

▶ Example 1: Alice's First Experience

BASH
# 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)
BASH
# Default mode
codex

# Auto Edit mode
codex --auto-edit

# Full Auto mode
codex --full-auto

▶ Example 2: Mode Selection

PYTHON
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"

BASH
# 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:

BASH
# 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

TEXT 📖 Display only
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


8. Update & Uninstall

BASH
# 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:


❓ FAQ

Q What do I need before installing CLI?
A Node.js (v18+) is required; npm is included with Node.js. Mac users can install Codex via Homebrew to skip Node.js.
Q Can I use Codex CLI on Windows?
A Experimental support — recommend using via WSL (Windows Subsystem for Linux) for a more stable experience.
Q API Key or ChatGPT login — which is better?
A ChatGPT login is simpler and suits most users; API Key is better for developers who need precise control over models and costs.
Q Is Full Auto mode safe?
A There is some risk. Codex will auto-execute all operations including shell commands. Recommended only for trusted projects, or with sandbox mode enabled.
Q How do I check the Codex version?
A Run codex --version to see the current version.

📖 Summary


📝 Exercises

  1. Basic (⭐): Install Codex CLI and successfully log in. Take a screenshot of your first run interface.
  2. Intermediate (⭐⭐): Complete the same task using both Suggest and Auto Edit modes, and compare the experience.
  3. Advanced (⭐⭐⭐): Install Codex CLI in a WSL environment and write an installation troubleshooting guide.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏