Skip to content

Codex Setup Guide

Install Codex CLI

Installation

All three systems use the same npm command:

bash
npm install -g @openai/codex

Verify:

bash
codex --version

A 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:

bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc   # zsh users: ~/.zshrc
source ~/.bashrc

Q: permission denied error (Windows)

Run PowerShell as administrator:

powershell
npm config set prefix "$env:APPDATA\npm"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Q: 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

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:

Systemconfig.tomlauth.json
WindowsC:\Users\<name>\.codex\config.tomlC:\Users\<name>\.codex\auth.json
Mac / Linux~/.codex/config.toml~/.codex/auth.json

Edit config.toml

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 = 900000

Edit auth.json

json
{
  "OPENAI_API_KEY": "sk-***"
}

Config Parameter Reference

ParameterDescriptionOptions
model_providerProvider identifier matching the section belowCustom name
modelModel in useSee model list
model_reasoning_effortReasoning depthlow / medium / high
disable_response_storageDisable server-side storagetrue recommended
wire_apiAPI protocolresponses
model_context_windowContext window (use 1000000 for 1M)Integer
model_auto_compact_token_limitAuto-compact near the limitInteger (typically 900000)

Start Using It

Open a terminal in any project directory and run codex:

bash
cd your-project-directory
codex

Once 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