Environment Setup: Install Node.js
claude requires Node.js runtime (v18 or higher).
Method 1: Using Homebrew (recommended)
# 更新 Homebrew
brew update
# 安装 Node.js
brew install nodeMethod 2: Download from official website
- Visit https://nodejs.org/
- Download the LTS version for macOS (v18 or higher required)
- Open the downloaded .pkg file and follow the installation wizard
Verify Node.js Installation
After installation, open terminal/command line and run the following commands to verify:
node --version
npm --versionIf version numbers are displayed, the installation was successful!
Install codex codex
Execute:
npm i -g @openai/codex --registry=https://registry.npmmirror.comVerify installation:
codex --versionConnect to Codex API Hub service
Configuration file setup
- Open file explorer, find the ~/.codex folder (create if it doesn't exist)
- Create a config.toml file
- Open with text editor and add the following content:
Create config.toml file (when using auth.json to store the key, env_key field is not required):
model_provider = "cch"
model = "gpt-5.2"
model_reasoning_effort = "xhigh"
disable_response_storage = true
sandbox_mode = "workspace-write"
[features]
plan_tool = true
apply_patch_freeform = true
view_image_tool = true
web_search_request = true
unified_exec = false
streamable_shell = false
rmcp_client = true
[model_providers.cch]
name = "cch"
base_url = "Current site address/v1"
wire_api = "responses"
requires_openai_auth = true
[sandbox_workspace_write]
network_access = trueCreate an auth.json file and add:
{
"OPENAI_API_KEY": "your-api-key-here"
}NoteThis method stores the API key in auth.json file, no need to configure env_key field in config.toml.
Important note
- Replace your-api-key-here with your Codex API Hub API key
- Note: Codex uses OpenAI-compatible format, endpoint includes the /v1 path
VS Code Extension Configuration
- Search for and install Codex – OpenAI's coding agent in VS Code extensions
- Make sure you have configured config.toml and auth.json according to the steps above
- Set the CCH_API_KEY environment variable
Important
env_key can only be an environment variable name (such as CCH_API_KEY), not the complete key. If you directly fill in the key, it will report an error that the token is not found or the token configuration is incorrect.
Start codex
Run the following command in your project directory:
cd /path/to/your/project
codexDuring the first startup, codex will perform initial configuration.
Common questions
1. Command not found
# Check the npm global installation path and add it to PATH (if not already there)
npm config get prefix
# # Add to PATH (if missing)
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc2. API connection failed
# # Check environment variable
echo $CCH_API_KEY
# # Test network connection
curl -I Current site address3. Update codex
npm i -g @openai/codex --registry=https://registry.npmmirror.com