Content updated: 2026-06-09Codex CLI is OpenAI’s command-line coding agent tool, suitable for making code changes, reviews, batch refactoring, and command collaboration in local repositories. When integrating with Crazyrouter, it is recommended to use the currently officially supported
config.toml custom provider method instead of the old configuration approach.
Overview
By configuring the custom provider with~/.codex/config.toml, Codex CLI can send requests to Crazyrouter:
- Recommended protocol:
OpenAI-compatible API - Interface type used:
Responses API - Base URL:
https://api.crazyrouter.com/v1 - Authentication variable:
OPENAI_API_KEY - Recommended default model:
gpt-5.5
View the Codex one-click configuration repository
Who is this for?
- People who want to connect Crazyrouter to a terminal agent-style coding workflow
- People who want to perform batch modification, code review, and automation in local repositories
- People who want to split billing for Codex, Cursor, Claude Code traffic
- People who want to prioritize using the latest verified OpenAI models for terminal agent coding
Usage Protocol
Recommended protocol:OpenAI-compatible API
Codex CLI currently recommends using the OpenAI-compatible provider via custom model_provider, and specifying:
base_url = "https://api.crazyrouter.com/v1"wire_api = "responses"
/v1/responses, so Codex CLI can directly use the Responses API in this integration. However, this path only supports GPT models for now; Claude does not support POST /v1/responses.System Requirements and Prerequisites
gpt-5.5
Complete Installation Steps by Operating System
Recommended Path for Windows
The simplest path for Codex on Windows is:Git + Node.js + Globally install Codex using npm + Configure environment variables in PowerShell.
Recommended sequence:
- Install Git
- Install Node.js LTS
- Use npm to install Codex CLI
- Use PowerShell to write
OPENAI_API_KEY - Use PowerShell to write
$HOME/.codex/config.toml
codex --version reports command not found, close and reopen PowerShell, then try again.
Recommended Path for macOS
On macOS, the most convenient path is usually:Homebrew + Git + Node.js + brew or install Codex CLI via npm + persist environment variables with ~/.zshrc.
Recommended sequence:
- Install Xcode Command Line Tools
- Install Homebrew (if you don’t have it yet)
- Install Git, Node.js
- Install Codex CLI
- Write
~/.zshrc - Write
~/.codex/config.toml
Alternative Codex CLI Installation Paths
In addition to package managers, the official Codex repository also offers GitHub Releases binary packages. For most users, it is still recommended to prioritize:- Windows:
npm install -g @openai/codex - macOS:
brew install --cask codexornpm install -g @openai/codex
Complete Installation from Scratch
Step 1: Install Git
- Windows PowerShell
- macOS
- Ubuntu / Debian
Step 2: Install Node.js 20+
- Windows PowerShell
- macOS
- Ubuntu / Debian
Step 3: Install Codex CLI
- Windows PowerShell
- macOS
Step 4: Create a dedicated Codex token in Crazyrouter
codex, and for the first time only allow:gpt-5.5
Step 5: First, set a temporary environment variable
OPENAI_API_KEY from the provider configuration. First set in the current terminal:- Linux / macOS
- Windows PowerShell
Step 6: Save the API Key into a persistent environment variable
- Linux Bash
- macOS / Zsh
- Windows PowerShell
Step 7: Write the Codex configuration file to ~/.codex/config.toml
~/.codex/config.toml.- macOS
- Windows PowerShell
- macOS
- Windows PowerShell
Step 8: Prepare the Git repository and make the first snapshot
Step 9: Start Codex and complete the first verification
Reply only OKRead the repository structure only. Do not edit files.Find the highest-risk file in this repo and explain why, but do not change anything.
Recommended Model Configuration
POST /v1/messages or OpenAI-compatible POST /v1/chat/completions; do not configure Claude for this Codex wire_api = "responses" route.
Native Support for Domestic Models
Based on2026-05-15 production retesting, the domestic models on Crazyrouter that support native POST /v1/responses and can be properly consumed by Codex CLI, are currently only recommended as follows:
gpt-5.5kimi-k2.5kimi-k2.6
MiniMax-M2.7, deepseek-v4-pro, glm-5.1 directly to Codex’s default whitelist unless you clearly accept experimental behavior and stream reconnection attempts.
Switching to Domestic Models
Keepbase_url = "https://api.crazyrouter.com/v1" and wire_api = "responses" unchanged, only replace the model field. For example:
Reply only OKRead the repository structure only. Do not edit files.Read agent.md and reply with exactly the first Markdown heading text.
Token Best Practices
Verification Checklist
-
git --versionis working -
node -vis working -
codex --versionis working -
OPENAI_API_KEYis correctly set -
~/.codex/config.tomlis written tomodel_provider = "crazyrouter" -
base_urlis set ashttps://api.crazyrouter.com/v1 -
wire_apiis set asresponses - First request returned successfully
- Crazyrouter backend logs show corresponding request
- Token quota and model allowlist match expectations
Common Errors and Fixes
Performance and Cost Recommendations
- Initially verify with a small repository, do not start by running full tasks in a huge repository
- Main recommendation:
gpt-5.5, run the GPT / Responses main path first - Separate accounting for Codex and IDE tools to identify sources of high consumption
- Set stricter token quota for high-risk repositories or CI scenarios
- On encountering unusually high usage, first check Crazyrouter logs to see if it was caused by multi-turn proxy actions
FAQ
What Base URL should Codex CLI use?
Usehttps://api.crazyrouter.com/v1.
On Windows, is PowerShell or Git Bash recommended?
For initial setup, prioritize the PowerShell approach in the documentation, as it easiest keeps user environment variables and$HOME/.codex/config.toml consistent.
Why configure wire_api = "responses" here?
Because Codex CLI’s custom provider is currently recommended to work through the Responses API, which Crazyrouter supports /v1/responses.
Why is Claude no longer recommended here?
Because Claude currently only supportsPOST /v1/messages and POST /v1/chat/completions, not POST /v1/responses. This Codex integration goes through wire_api = "responses" by default, so Claude should not be used as the recommended model for this route.
Why is it recommended to take a Git snapshot first?
Because Codex, as a proxy, can modify files and run commands. Taking a snapshot first makes review and rollback much easier.If I have already done codex login, do I still need to set up an API Key?
Yes. When connecting to Crazyrouter, you should still use OPENAI_API_KEY and custom provider settings.
What is the first recommended model?
Start withgpt-5.5.