OpenAI Codex CLI is an open-source, lightweight terminal agent for AI-assisted coding. It connects to OpenAI's models to provide code generation, editing, and command execution directly from your terminal.
Installation
```bash npm install -g @openai/codex export OPENAI_API_KEY=your-key-here codex ```
Key Features
- Open-source — MIT licensed, community-driven development
- Lightweight — Minimal dependencies, fast startup
- Sandboxed — Network-disabled, directory-restricted by default
- Multi-model — Works with GPT-4o, o3, o4-mini, and other OpenAI models
- Cross-platform — macOS, Linux, and WSL on Windows
Approval Modes
| Mode | File Edits | Commands | Best For | |---|---|---|---| | Suggest | Requires approval | Requires approval | Learning, sensitive code | | Auto-edit | Automatic | Requires approval | Routine development | | Full-auto | Automatic | Automatic | Trusted automation |
Basic Usage
```bash # Interactive mode codex
# One-shot command codex "add input validation to the signup form"
# With specific model codex --model o3 "refactor this module"
# Quiet mode (less output) codex -q "fix the failing test" ```
Safety Model
Codex CLI applies sandboxing by default: • Network access disabled in sandbox • File access restricted to current directory and children • Commands run in isolated environment • Full-auto mode applies additional restrictions • Review all changes before committing