📖 Introduction
Codex CLI is OpenAI's coding agent that you can run in your local terminal. It can read, modify, and run code in your selected directory. It's open-source and built in Rust for speed and efficiency.
ChatGPT Plus, Pro, Business, Edu, and Enterprise plans all include Codex access. You can authenticate using your ChatGPT account or an API key.
⚙️ System Requirements
| Component | Requirement | Notes |
|---|---|---|
| Operating System | macOS / Linux / Windows (WSL2) | Windows support is experimental |
| Node.js | v18.0 or higher | Required for npm installation |
| Account | ChatGPT Plus/Pro/Enterprise or API Key | Requires valid access |
🖥️ Choose Your Platform
Install via npm
# Install Codex CLI globally
npm install -g @openai/codex
# Verify installation
codex --versionInstall via Homebrew
brew install openai-codex
# Verify installation
codex --versionConfigure API Key
On first run, Codex will prompt you to log in. You can use your ChatGPT account or an API key for authentication. When using BeeHears service:
# Set API Base URL (using BeeHears service)
export OPENAI_BASE_URL="https://api.beehears.com/v1"
# Set API key
export OPENAI_API_KEY="your-api-key-here"
# Run Codex
codexThrough BeeHears integration, you can access the latest models like GPT-6 Astra, GPT-6 Sol, and enjoy unified billing and multi-model switching capabilities.
Windows support is currently experimental. We recommend using Codex in a WSL2 workspace for the best experience.
Install WSL2
# Install WSL
wsl --install
# After restart, open WSL terminal to continueInstall Node.js in WSL
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify
node --versionInstall Codex CLI
# Install globally
npm install -g @openai/codex
# Run
codexConfigure API Key
export OPENAI_BASE_URL="https://api.beehears.com/v1"
export OPENAI_API_KEY="your-api-key-here"
codexInstall via npm
# Install Node.js (if not installed)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install Codex CLI
npm install -g @openai/codex
# Verify installation
codex --versionConfigure API Key
# Set environment variables
export OPENAI_BASE_URL="https://api.beehears.com/v1"
export OPENAI_API_KEY="your-api-key-here"
# Run
codexAdd environment variables to ~/.bashrc or ~/.zshrc for permanent configuration.
🚀 Basic Usage
Start an Interactive Session
cd /path/to/project
codexCommon Commands
codex- Start an interactive TUI sessioncodex "your prompt"- Send a prompt directly/model- Switch models (GPT-6 Astra, GPT-6 Sol, etc.)/help- View help information
Key Features
- Code Review - Get code reviews before committing or pushing
- Image Input - Attach screenshots or design specifications
- Web Search - Get latest information from the web
- Sub-agents - Handle complex tasks in parallel
- MCP Support - Integrate third-party tools via Model Context Protocol
Approval Modes
Codex offers multiple approval modes to control its behavior before editing files or running commands:
- suggest - Only suggest changes (default)
- auto-edit - Automatically edit files
- full-auto - Fully automatic mode
🔄 Upgrade
# Upgrade to the latest version
npm install -g @openai/codex@latest