Site logoGPT-5 Thinking

OpenAI Codex CLI

The OpenAI Codex CLI is an AI-powered terminal coding assistant that runs locally on your computer. Codex CLI helps developers build faster with interactive coding assistance, combining the power of AI with human oversight through approvals and sandboxing.

Open sourceAI-poweredLocal executionMCP support

Interactive Coding

OpenAI Codex CLI provides real-time coding assistance with AI-powered suggestions and completions.

Human-in-the-Loop

Every command requires your approval. Codex CLI shows plans and lets you review before execution.

Platform Sandboxing

Run safely with configurable sandbox modes, protecting your system while using Codex CLI.

Installation

Install via npm (Recommended)

The easiest way to install OpenAI Codex CLI is through npm:

npm i -g @openai/codex

Alternative: Homebrew (macOS)

Mac users can also install Codex CLI using Homebrew:

brew install codex

System Requirements

  • • macOS 12+ or Ubuntu 20.04+/Debian 10+
  • • Windows via WSL2
  • • 4-8 GB RAM recommended
  • • Node.js 18+ for npm installation

Authentication

Option 1: Sign in with ChatGPT (Recommended)

Best for ChatGPT Plus, Pro, or Team accounts. OpenAI Codex CLI seamlessly integrates with your existing ChatGPT subscription:

codex auth login

Option 2: Use OpenAI API Key

For developers with OpenAI API access, Codex CLI supports direct API key authentication:

export OPENAI_API_KEY="your-api-key-here"

Sandbox Modes

OpenAI Codex CLI offers flexible sandbox modes to balance productivity and safety:

Read/Write Mode

Full access to run commands and modify files within your workspace. Codex CLI can execute tasks with your approval.

Read-Only Mode

Limited to reading files and suggesting changes. Perfect for code reviews and analysis with Codex CLI.

💡 Tip: OpenAI Codex CLI's sandbox modes ensure your system remains protected while leveraging AI assistance.

Key Capabilities

Model Context Protocol (MCP) Support

Codex CLI supports the Model Context Protocol, enabling seamless integration with various AI models and tools.

Non-Interactive CLI Mode

Run OpenAI Codex CLI in automation scripts with the codex exec command for CI/CD pipelines.

Open-Source Model Support

Besides OpenAI models, Codex CLI can work with open-source alternatives, giving you flexibility in model selection.

Configurable via config.toml

Customize OpenAI Codex CLI behavior, model preferences, and sandbox settings through a simple configuration file.

Zero Data Retention

Your code and prompts stay private. Codex CLI ensures no data retention for enhanced security and privacy.

Usage Examples

Interactive Mode

Start an interactive session with OpenAI Codex CLI:

# Start interactive Codex CLI session
codex

# With specific model
codex --model gpt-4

# With verbose logging
codex --verbose

Direct Task Execution

Execute specific tasks directly with Codex CLI:

# Create a REST API
codex "Build a REST API with Express.js for user management"

# Refactor code
codex "Refactor this function to use async/await"

# Add tests
codex "Write comprehensive tests for the auth module"

# Fix bugs
codex "Debug and fix the memory leak in the data processor"

Non-Interactive Automation

Use OpenAI Codex CLI in scripts and CI/CD:

# Run without interaction
codex exec "Update all dependencies to latest versions"

# Use in shell scripts
#!/bin/bash
codex exec "Generate API documentation" --output docs/api.md

Configuration

Customize OpenAI Codex CLI through the config.toml file:

# ~/.codex/config.toml

[model]
default = "gpt-4"
temperature = 0.7
max_tokens = 2000

[sandbox]
mode = "read-write"  # or "read-only"
timeout = 300  # seconds

[logging]
level = "info"  # debug, info, warn, error
verbose = false

[mcp]
enabled = true
servers = ["default", "custom"]

Community & Support

Open Source Initiative

OpenAI Codex CLI is open source and welcomes contributions. Join the community to improve and extend Codex CLI.

Active Development

Codex CLI is under active development with regular updates, new features, and community-driven improvements.

⚠️ Note: OpenAI Codex CLI is experimental software. Always review generated code and maintain backups of your work.

Resources & Documentation

Get Started with OpenAI Codex CLI Today

Transform your development workflow with OpenAI Codex CLI. Experience the power of AI-assisted coding with full control and safety. Join thousands of developers using Codex CLI to build better software faster.