更新日: 2026-06-06Codex CLI is OpenAI’s terminal coding agent for repo edits, code review, large refactors, and command-driven development. For Crazyrouter, the recommended path is the current
config.toml custom-provider setup, not the older configuration style.
Overview
With a custom provider in~/.codex/config.toml, Codex CLI can send its requests to Crazyrouter:
- recommended protocol:
OpenAI-compatible API - API style used by Codex:
Responses API - base URL:
https://api.crazyrouter.com/v1 - auth variable:
OPENAI_API_KEY - recommended default model:
gpt-5.5
View the Codex one-click setup repository
If you want a script to write the environment variables and Codex config for you, review the crazyrouter-codex-cli repository.
Best For
- users who want Crazyrouter in a terminal agent workflow
- repo-scale edits, reviews, and automated coding tasks
- teams that want Codex traffic billed separately from Cursor or Claude Code
- coding-first workflows built around currently verified latest OpenAI models
Protocol Used
Recommended protocol:OpenAI-compatible API
Codex CLI currently works best with a custom model_provider configured like this:
base_url = "https://api.crazyrouter.com/v1"wire_api = "responses"
Crazyrouter supports
/v1/responses, so this Codex CLI integration can use the Responses API directly. But this path should currently be treated as GPT-only guidance because Claude does not support POST /v1/responses.System Requirements And Prerequisites
Suggested starter allowlist:
gpt-5.5
Full Install Paths By OS
Recommended Windows path
On Windows, the simplest path is:Git + Node.js + npm global install for Codex + PowerShell for environment variables and config.
Recommended order:
- Install Git
- Install Node.js LTS
- Install Codex CLI with npm
- Write
OPENAI_API_KEYthrough PowerShell - Write
$HOME/.codex/config.tomlthrough PowerShell
codex --version is still not found, close and reopen PowerShell before retrying.
Recommended macOS path
On macOS, the smoothest path is usually:Homebrew + Git + Node.js + brew or npm install for Codex + ~/.zshrc for persistent environment variables.
Recommended order:
- Install Xcode Command Line Tools
- Install Homebrew if needed
- Install Git and Node.js
- Install Codex CLI
- Persist
OPENAI_API_KEYin~/.zshrc - Write
~/.codex/config.toml
Alternative Codex install paths
Besides package managers, the official Codex GitHub repository also publishes binary releases. For most users, the recommended defaults are still:- Windows:
npm install -g @openai/codex - macOS:
brew install --cask codexornpm install -g @openai/codex
Full Setup From Scratch
1
Step 1: Install Git
If Git is not installed yet, install it first and add a global identity.Then run:
- Windows PowerShell
- macOS
- Ubuntu / Debian
2
Step 2: Install Node.js 20+
Codex CLI is a Node.js tool. Make sure Node and npm are ready first.If your distro installs an older Node version, upgrade before continuing.
- Windows PowerShell
- macOS
- Ubuntu / Debian
3
Step 3: Install Codex CLI
- Windows PowerShell
- macOS
Recommended: use npm global install directly.
4
Step 4: Create a dedicated Crazyrouter token for Codex
In Crazyrouter, create a token named something like
codex. For the first pass, allow only:gpt-5.5
5
Step 5: Set the temporary environment variable
Codex reads
OPENAI_API_KEY through the provider config. Start with the current terminal only:- Linux / macOS
- Windows PowerShell
6
Step 6: Persist the API key
For regular use, write the API key into your shell profile or user environment variables.
- Linux Bash
- macOS / Zsh
- Windows PowerShell
7
Step 7: Write ~/.codex/config.toml
Codex CLI reads After writing the file, verify it:
~/.codex/config.toml at startup.- macOS
- Windows PowerShell
- macOS
- Windows PowerShell
8
Step 8: Prepare the Git repo and create a first snapshot
If the current folder is not a repo yet:If it is already an existing repo, at least inspect the current state first:
9
Step 9: Launch Codex and run the first validation
In the repo, start with a minimal validation first:After that, start interactive mode:Recommended validation order:
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 Setup
If you need Claude, use the native Claude
POST /v1/messages path or OpenAI-compatible POST /v1/chat/completions instead of putting Claude onto the Codex wire_api = "responses" route.
Token Setup Best Practices
Verification Checklist
-
git --versionworks -
node -vworks -
codex --versionworks -
OPENAI_API_KEYis set correctly -
~/.codex/config.tomlcontainsmodel_provider = "crazyrouter" -
base_urlishttps://api.crazyrouter.com/v1 -
wire_apiisresponses - the first request succeeds
- Crazyrouter logs show the matching request
- token quota and allowlist match your intended setup
Common Errors And Fixes
Performance And Cost Tips
- validate first in a small repo, not a huge production repo
- keep
gpt-5.5as the main driver and get the GPT / Responses baseline working first - separate Codex from IDE tools for cleaner cost attribution
- use stricter quota caps for higher-risk repos or CI jobs
- when spend spikes, inspect Crazyrouter logs first to see whether agent loops are the cause
FAQ
Which base URL should I use in Codex CLI?
Usehttps://api.crazyrouter.com/v1.
On Windows, should I use PowerShell or Git Bash?
For first-time setup, prefer the PowerShell path in this guide. It is the easiest way to keep user-level environment variables and$HOME/.codex/config.toml consistent.
Why do I need wire_api = "responses"?
Because Codex CLI’s custom-provider path is designed around the Responses API, and Crazyrouter supports /v1/responses.
Why is Claude no longer recommended here?
Because Claude currently supports onlyPOST /v1/messages and POST /v1/chat/completions, not POST /v1/responses. The Codex path here is fixed to wire_api = "responses", so Claude should not be presented as a recommended model for this route.
Why should I make a Git snapshot before the first real task?
Because Codex can edit files and run commands. A clean snapshot makes review and rollback much easier.If I already used codex login, do I still need an API key?
Yes. For Crazyrouter, you should still use OPENAI_API_KEY plus the custom provider configuration.
Which model should I try first?
Start withgpt-5.5.
If you want the smoothest terminal agent workflow on the OpenAI / Responses API path, configure Codex around the GPT / Responses route. If you want Claude first, switch to Claude Code or the native Claude API docs instead.
View the crazyrouter-codex-cli repository
Review the one-click setup scripts, README, and latest usage notes.