Prerequisite: install Node.js#
Codex CLI can be installed through npm. Install Node.js first, then verify that both commands are available:1. Install Codex CLI#
Run the following command on Windows, macOS, or Linux:If a version number is displayed, the installation succeeded.2. Create an AnyRoute API key#
3.
Enter a key name and choose a Codex group with the model and billing multiplier you need.
4.
Optionally configure IP restrictions, a spending limit, a rate limit, and an expiration date. New users can start with the defaults.
Treat an API key like a password. Never commit it to a repository, paste it into public content, or share it with another person.
CC Switch is the recommended setup method. Manual configuration is also available.Option A: CC Switch (recommended)#
2.
In AnyRoute, select Import to CCS.
3.
In CC Switch, enable the imported AnyRoute configuration.
The current screenshots may show Chinese labels. “导入到 CCS” means Import to CCS, and “启用” means Enable.
Create the configuration directory#
This step preserves any existing Codex configuration.New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex" | Out-Null
Do not delete the .codex directory. It can contain existing configuration, authentication data, command history, logs, and caches.
Create or update config.toml#
Create config.toml inside ~/.codex/ on macOS or Linux, or %USERPROFILE%\.codex\ on Windows. If the file already exists, merge the following settings with your current configuration instead of overwriting unrelated settings:model_provider = "anyroute"
model = "gpt-5.6-sol"
model_reasoning_effort = "high"
[model_providers.anyroute]
name = "AnyRoute"
base_url = "https://cc.anyroute.io"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
This configuration tells Codex to read the AnyRoute key from the OPENAI_API_KEY environment variable. It does not place the key in config.toml.Provide the API key#
Copy the key from the AnyRoute console:Set it for the current terminal session. Replace YOUR_API_KEY with your actual key.$env:OPENAI_API_KEY = "YOUR_API_KEY"
For regular use, prefer CC Switch or your operating system's secure credential-management method. Do not store API keys in a repository or shared shell script.4. Start Codex#
Open a terminal in your project directory and run:Codex starts with the current directory as its workspace. For Codex CLI behavior and configuration options, see the official Codex documentation.Troubleshooting#
npm reports a permissions error#
Avoid using sudo npm install --global. Configure a user-owned npm global prefix, use a Node.js version manager, or use an official Codex installation method supported by your platform.codex is not recognized#
Make sure the corresponding global executable directory is on PATH, then open a new terminal and run codex --version again.The connection fails or returns HTTP 401#
base_url is https://cc.anyroute.io.
OPENAI_API_KEY is set in the same terminal session that starts Codex.
The AnyRoute key is active, unexpired, and assigned to a Codex-compatible group.
How do I switch models or billing groups?#
Create a key for the required group in the AnyRoute console, then switch configurations in CC Switch or update OPENAI_API_KEY in your current terminal session.
Join AnyRoute WeChat Group
To get support for AnyRoute

scan QR codeModified at 2026-07-24 19:01:47