This article will take you through installing OpenAI Codex CLI from scratch, configuring your API Key, setting up sandbox mode, and integrating with ProjectManager.
Prerequisites
Before installing Codex CLI, make sure your environment meets the following requirements:
- Node.js 22+ — Codex CLI requires a relatively recent Node.js version
- OpenAI API Key — Get your API Key from OpenAI Platform
- Git — Used for version control and code rollback
Check Node.js version:
node --version
# Should output v22.x.x or higher
Installation Steps
Global Installation
npm install -g @openai/codex
Verify Installation
codex --version
# Should output codex/x.x.x
First Run
codex
# Will prompt for API Key on first run
Configuration Details
API Key Configuration
Codex CLI supports the following methods to configure your API Key:
- Environment variable —
OPENAI_API_KEY, recommended approach - Interactive input — Prompted on first run
- .env file — Create a
.envfile in your project root
export OPENAI_API_KEY=sk-xxxxx
Model Selection
Codex CLI supports the following models, specified via the --model parameter:
o4-mini— Default model, fast and cost-effectiveo3— Stronger reasoning capabilities, suitable for complex tasks
codex --model o3
Sandbox Mode
Codex CLI has a built-in sandbox mode that restricts AI operation permissions:
- Suggest Mode (default) — AI write operations require user confirmation
- Auto-edit Mode — AI can auto-edit files, but command execution still requires confirmation
- Full Auto Mode — AI can automatically execute all operations (
--full-auto)
codex # Suggest mode (default)
codex --full-auto # Full auto mode
It is recommended to only use full auto mode in trusted environments, and always use Git for easy rollback.
Custom Base URL
If you use a proxy or a third-party service compatible with the OpenAI API:
export OPENAI_BASE_URL=https://your-proxy.example.com/v1
Integrating with Wishmere
Wishmere can automatically detect installed Codex CLI, and you can choose the appropriate agent based on your project type:
- Tasks requiring deep reasoning — Automatically uses Claude Code
- Tasks requiring quick iteration — Automatically uses Codex CLI
In Wishmere’s project settings, you can configure default tools and model switching strategies.
FAQ
1. Node.js Version Does Not Meet Requirements
Codex CLI requires Node.js 22+. If the version is too low:
nvm install 22
nvm use 22
npm install -g @openai/codex
2. Sandbox Permission Denied
If operations are denied in sandbox mode, check if necessary system permissions are missing. macOS users may need to allow terminal operations in “System Preferences → Security & Privacy”.
3. API Rate Limit
OpenAI API has rate limits. If you encounter a 429 error, wait a moment and retry, or upgrade your API plan.
4. Garbled Output
If terminal output is garbled, make sure your terminal supports UTF-8 encoding:
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Next Steps
- Codex CLI Usage Guide: From Beginner to Pro — Deep dive into Codex CLI usage and notes
- Claude Code Installation and Configuration Guide — Learn about another AI coding tool’s installation
- Claude Code: 10 Common Pitfalls and Solutions — Comparative learning to avoid similar issues
← Back to ArticlesUsing Wishmere lets you manage both Claude Code and Codex CLI simultaneously, automatically selecting the most suitable tool based on the task, so you can focus on the work itself.