Client setup
Codex Setup Guide
Connect Codex CLI and the desktop app to ZhenAPI using setup scripts or manual configuration, including API keys, models and the Responses API.
Install and configure Codex to connect to ZhenAPI through ~/.codex.
Choose the setup script for your operating system
The script detects Node.js and Codex CLI and helps install them if necessary. It then asks for your API key and writes the configuration to ~/.codex. The copied command does not contain your API key.
1irm https://zhenapi.ai/install/codex.ps1 | iexAfter running the command, wait for PowerShell to prompt for your API key. Right-click to paste the full key, then press Enter. Do not use Ctrl+V or other paste shortcuts.
1curl -fsSL https://zhenapi.ai/install/codex.sh | bash~/.codex is used by both Codex CLI and Codex App. Restart any open CLI sessions to load the new settings. ⚠️ Note:Before installing manually, complete the Node.js installation guide.
Step 1: Install Codex
1npm install -g @openai/codex@latestThese commands install the latest Codex package from the npm registry.
Verify installation
1codex --versionIf a version number appears, Codex is installed successfully.
Step 2: Create configuration files
Codex only needs config.toml. Set experimental_bearer_token to your API key.
1# Create the configuration directory (back up existing files; the following command overwrites them)2New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null3$utf8NoBom = New-Object System.Text.UTF8Encoding($false)4 5# Create config.toml6$config = @'7model_provider = "codex"8model = "gpt-6.1-sol"9model_reasoning_effort = "high"10model_context_window = 27200011sandbox_mode = "workspace-write"12 13[model_providers.codex]14name = "codex"15base_url = "https://api.zhenapi.ai/v1"16wire_api = "responses"17requires_openai_auth = false18supports_websockets = false19experimental_bearer_token = "YOUR_API_KEY"20http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }21 22[desktop]23conversationDetailMode = "STEPS_COMMANDS"24 25[sandbox_workspace_write]26network_access = true27 28[features]29goals = true30'@31[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, $utf8NoBom)1# Create the configuration directory (back up existing files; the following commands overwrite them)2mkdir -p ~/.codex3 4# Create config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOF1# Create the configuration directory (back up existing files; the following commands overwrite them)2mkdir -p ~/.codex3 4# Create config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOFYOUR_API_KEY with an API key copied from the Dashboard page. 1sudo npm install -g @openai/codex@latestThese commands install the latest Codex package from the npm registry.
Verify installation
1codex --versionIf a version number appears, Codex is installed successfully.
Step 2: Create configuration files
Codex only needs config.toml. Set experimental_bearer_token to your API key.
1# Create the configuration directory (back up existing files; the following command overwrites them)2New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null3$utf8NoBom = New-Object System.Text.UTF8Encoding($false)4 5# Create config.toml6$config = @'7model_provider = "codex"8model = "gpt-6.1-sol"9model_reasoning_effort = "high"10model_context_window = 27200011sandbox_mode = "workspace-write"12 13[model_providers.codex]14name = "codex"15base_url = "https://api.zhenapi.ai/v1"16wire_api = "responses"17requires_openai_auth = false18supports_websockets = false19experimental_bearer_token = "YOUR_API_KEY"20http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }21 22[desktop]23conversationDetailMode = "STEPS_COMMANDS"24 25[sandbox_workspace_write]26network_access = true27 28[features]29goals = true30'@31[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, $utf8NoBom)1# Create the configuration directory (back up existing files; the following commands overwrite them)2mkdir -p ~/.codex3 4# Create config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOF1# Create the configuration directory (back up existing files; the following commands overwrite them)2mkdir -p ~/.codex3 4# Create config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOFYOUR_API_KEY with an API key copied from the Dashboard page. 1npm install -g @openai/codex@latestThese commands install the latest Codex package from the npm registry.
Verify installation
1codex --versionIf a version number appears, Codex is installed successfully.
Step 2: Create configuration files
Codex only needs config.toml. Set experimental_bearer_token to your API key.
1# Create the configuration directory (back up existing files; the following command overwrites them)2New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null3$utf8NoBom = New-Object System.Text.UTF8Encoding($false)4 5# Create config.toml6$config = @'7model_provider = "codex"8model = "gpt-6.1-sol"9model_reasoning_effort = "high"10model_context_window = 27200011sandbox_mode = "workspace-write"12 13[model_providers.codex]14name = "codex"15base_url = "https://api.zhenapi.ai/v1"16wire_api = "responses"17requires_openai_auth = false18supports_websockets = false19experimental_bearer_token = "YOUR_API_KEY"20http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }21 22[desktop]23conversationDetailMode = "STEPS_COMMANDS"24 25[sandbox_workspace_write]26network_access = true27 28[features]29goals = true30'@31[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, $utf8NoBom)1# Create the configuration directory (back up existing files; the following commands overwrite them)2mkdir -p ~/.codex3 4# Create config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOF1# Create the configuration directory (back up existing files; the following commands overwrite them)2mkdir -p ~/.codex3 4# Create config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOFYOUR_API_KEY with an API key copied from the Dashboard page. Step 3: Start using the client
Run the following from your project directory:
1codexFor more information, see the OpenAI documentation .