Codex Setup Guide
Install Codex CLI
Installation
All three systems use the same npm command:
npm install -g @openai/codexVerify:
codex --versionA version number means the install succeeded.
Common Issues
Q: permission denied / EACCES error (Mac / Linux)
Do not use sudo. Move npm's global directory to your user space:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc # zsh users: ~/.zshrc
source ~/.bashrcQ: permission denied error (Windows)
Run PowerShell as administrator:
npm config set prefix "$env:APPDATA\npm"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserQ: command not found: codex
The npm global bin directory isn't in PATH. Run npm config get prefix, then add the corresponding /bin directory to your system PATH.
Configure the API
cc-switch (recommended)
Supports one-click switching across providers for both Claude Code and Codex. Note: the Codex Base URL must end with /v1.
Manual config files
Codex reads two config files:
| System | config.toml | auth.json |
|---|---|---|
| Windows | C:\Users\<name>\.codex\config.toml | C:\Users\<name>\.codex\auth.json |
| Mac / Linux | ~/.codex/config.toml | ~/.codex/auth.json |
Edit config.toml
model_provider = "custom"
model = "gpt-5.4"
model_reasoning_effort = "high"
disable_response_storage = true
[model_providers.custom]
name = "custom"
base_url = "https://your-request-address/v1"
wire_api = "responses"
requires_openai_auth = true
model_context_window = 1000000
model_auto_compact_token_limit = 900000Edit auth.json
{
"OPENAI_API_KEY": "sk-***"
}Config Parameter Reference
| Parameter | Description | Options |
|---|---|---|
model_provider | Provider identifier matching the section below | Custom name |
model | Model in use | See model list |
model_reasoning_effort | Reasoning depth | low / medium / high |
disable_response_storage | Disable server-side storage | true recommended |
wire_api | API protocol | responses |
model_context_window | Context window (use 1000000 for 1M) | Integer |
model_auto_compact_token_limit | Auto-compact near the limit | Integer (typically 900000) |
Start Using It
Open a terminal in any project directory and run codex:
cd your-project-directory
codexOnce you see the input prompt, just describe what you want in English or Chinese, e.g.:
Implement a binary search tree in Python with insert, delete, and search methods