Connect Codex to Routescope
Use Codex with your Routescope API Key and quota through CC Switch or config.toml / auth.json.
Point Codex to Routescope and run it with your Routescope API Key and quota.
This guide keeps only the most reliable setup paths. First-time users do not need to understand API protocols. Follow the steps and fill in the listed values.
Choose a Setup Method
Choose one of the two methods below. New users should use method 1.
| Method | Best for | Difficulty | Manual config required |
|---|---|---|---|
| 1. CC Switch (recommended) | New users, users unfamiliar with terminals | Easiest | No |
| 2. Manual config.toml setup | Users comfortable copying commands and editing config files | Medium | Yes |
If you are not comfortable with the command line, use CC Switch graphical setup.
Codex is an OpenAI coding tool. You can run it from a terminal with codex; since July 2026, it is also included in the ChatGPT desktop app. This page explains how to connect Codex to Routescope. It is not the same as normal ChatGPT web chat.
Before You Start
Both setup methods require the following items.
In Token Management, the record you create is the token: a key with permission settings. The sk- string inside it is the secret, or API Key. That is the value you copy into configuration.
1. Routescope Secret (API Key)
- Sign in to the Routescope console.
- Open Token Management.
- Click Add Token.
- Use a token name such as
Codex. - Configure quota, allowed models, IP restrictions, and expiration if needed.
- After saving, click Copy Access Code in the token list.
You will get a string that starts with sk-, for example:
sk-xxxxxxxxxxxxxxxxKeep the entire string, including the sk- prefix.
2. An Available Model ID
- Open Routescope Model Plaza.
- Find a model that your token is allowed to use.
- Copy the full model ID.
Do not copy only the display name, and do not blindly reuse model examples from other guides.
3. Install Codex
CC Switch and manual setup only change configuration. Codex itself must already be installed. Check it from a terminal first:
- Windows: search for and open PowerShell.
- macOS: open Applications -> Utilities -> Terminal.
- Linux: open your system terminal.
Run:
codex --versionIf you see a version number, continue. If the command is not found, install Codex using either option below.
Option A: Install Codex CLI
The examples in this guide are based on the CLI.
Windows PowerShell:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"macOS, Linux, or WSL:
curl -fsSL https://chatgpt.com/codex/install.sh | shIf Node.js is already installed, this also works on any system:
npm install -g @openai/codexOption B: Install the ChatGPT Desktop App
Since July 9, 2026, OpenAI has merged Codex into the unified ChatGPT desktop app, with Chat, Work, and Codex in one app for Mac and Windows. If you already have the new ChatGPT desktop app, Codex is included and you do not need a separate CLI install.
After installing the CLI, close and reopen the terminal, then run codex --version. For desktop, open the app directly. If installation still fails, see the official Codex CLI setup guide.
Desktop and CLI share configuration
No matter how Codex is installed, connecting it to Routescope is done through the ~/.codex configuration in your user directory. Desktop Codex and Codex CLI share the same configuration. CC Switch and manual config.toml edits both write that same setup.
Two reminders:
- Chat and Work in the ChatGPT desktop app use the official OpenAI account path, not Routescope. Only Codex uses the Routescope setup described here.
- The desktop app currently does not provide a UI to switch custom provider models. It uses the
modelline inconfig.toml, so set that line to your Routescope model ID.
Fixed Values You Will Use
| Name | Value | Plain explanation |
|---|---|---|
| Secret (API Key) | Your full sk-... | The passcode for Routescope |
| Model ID | A model allowed by your token, such as gpt-5.4; use the model actually enabled for your account | The model Codex will call |
| Base URL | https://api.routescope.ai/v1 | Routescope endpoint |
Codex Base URL must include /v1
Codex must use a Base URL ending in /v1. This is the opposite of Claude Code. Do not add an extra trailing /.
Protect your secret
A secret is like a password. Do not send it to others or include it in screenshots, chats, tickets, or public documents.
Method 1: Use CC Switch (Recommended)
CC Switch is a graphical configuration tool. You do not need to create config.toml manually.
For the full flow, see the "Configure Codex" section in Connect CC Switch to Routescope.
Summary:
- Install and open CC Switch.
- Select Codex at the top.
- Click the + button in the upper-right corner.
- Choose Application-specific provider.
- Choose Custom configuration under preset providers.
- Enter the full secret (
sk-...). - Set API endpoint to
https://api.routescope.ai/v1. Codex must include/v1. - Expand Advanced Options and set Upstream format to
Responses (native). - In the
config.tomleditor, replace the model name on themodel =line with your model ID. - Save, then click Enable on the Routescope provider card.
After this, skip to How to Confirm It Works.
Codex itself must still be installed
CC Switch writes configuration, but it does not replace Codex. If your terminal cannot run codex, return to "Before You Start -> Install Codex" and use option A or B.
Method 2: Manual config.toml Setup
This method requires opening a terminal and creating two configuration files. If that feels hard, switch to method 1.
Before starting, confirm codex --version shows a version number. If not, return to "Before You Start -> Install Codex".
Step 1: Open config.toml
Codex configuration lives in the .codex folder in your user directory. The main configuration file is config.toml.
Windows
Run these in PowerShell:
New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex"
notepad "$env:USERPROFILE\.codex\config.toml"If Notepad asks whether to create a new file, choose yes.
macOS
Run these in Terminal:
mkdir -p ~/.codex
touch ~/.codex/config.toml
open -e ~/.codex/config.tomlThe file opens in TextEdit.
Linux
Run:
mkdir -p ~/.codex
nano ~/.codex/config.tomlAfter pasting, press Ctrl + O to save, press Enter to confirm, then press Ctrl + X to exit.
Do not overwrite existing config blindly
If config.toml already contains settings you do not understand, do not replace the whole file. New users should use CC Switch. Users familiar with TOML can merge only the model_provider, model, and [model_providers.OpenAI] entries from the next step.
Step 2: Paste the config.toml Configuration
If this is a new file, paste the full content below:
model_provider = "OpenAI"
model = "gpt-5.4"
review_model = "gpt-5.4"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
model_context_window = 1000000
model_auto_compact_token_limit = 900000
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.routescope.ai/v1"
wire_api = "responses"
requires_openai_auth = trueReplace only one kind of value: change gpt-5.4 in both the model and review_model lines to your real model ID. Use the same model in both places for first-time setup.
Do not change these lines:
base_url = "https://api.routescope.ai/v1"
wire_api = "responses"
requires_openai_auth = trueThe OpenAI label is just a configuration name. Copy it as is.
Check:
base_urlishttps://api.routescope.ai/v1, includes/v1, and has no extra trailing/.modelandreview_modelhave both been changed to your real model ID.- Quotes, equals signs, and square brackets are still present.
Save and close the file.
Step 3: Create auth.json for the Secret
The secret does not go into config.toml. It goes into a separate auth.json file in the same .codex folder.
Windows PowerShell:
notepad "$env:USERPROFILE\.codex\auth.json"macOS:
touch ~/.codex/auth.json
open -e ~/.codex/auth.jsonLinux:
nano ~/.codex/auth.jsonPaste this into auth.json:
{
"OPENAI_API_KEY": "sk-your-full-secret"
}Replace sk-your-full-secret with the full secret you copied earlier, keeping the sk- prefix.
Only change the text inside quotes
When replacing the secret, edit only the content inside the double quotes. Keep both quotes. Missing quotes, commas, or braces can make Codex ignore the secret.
The field name must be OPENAI_API_KEY. Do not change it. This is only where Codex reads the secret from; the value inside is your Routescope secret.
Check:
- The file is named
auth.json, notauth.json.txt. - The secret keeps the
sk-prefix. - Quotes and braces are still present.
Save and close the file.
Step 4: Start Codex
Close the previous terminal, open a new one, and run:
codexNormally, this opens the Codex chat interface.
Reopen the terminal after config changes
Codex reads configuration when it starts. After changing configuration, close the terminal and open a new one, otherwise the changes may not apply.
How to Confirm It Works
Asking the AI to say "I am connected to Routescope" is not enough. It may only repeat your words.
Confirm it this way:
-
Send a normal question in Codex, for example:
Describe yourself in one sentence. -
After receiving a response, open the Routescope console.
-
Go to Operation Records or Call Records.
-
Find a new record from the same time.
-
Confirm the call status is successful.
-
Confirm the model, token usage, and billing look normal.
Codex is truly connected only when Codex replies normally and Routescope shows the corresponding successful request.
Optional quick check: if you only want to test whether the endpoint and secret work, run this in a terminal after replacing your-full-sk-secret:
curl https://api.routescope.ai/v1/models -H "Authorization: Bearer your-full-sk-secret"If it returns a model list, the endpoint and secret are valid. This does not prove Codex chat works; the Operation Records check above is still the source of truth.
Troubleshooting
401 or 403
This is usually a secret or token permission issue. Check:
- The secret is complete.
- The
sk-prefix is present. - The token is not disabled, expired, or out of quota.
- The model is allowed by the token.
- IP restrictions are not blocking the request.
OPENAI_API_KEYinauth.jsoncontains the Routescope secret, not an OpenAI key from somewhere else.
After changes, close the terminal and restart Codex.
404
This is usually an endpoint typo. Confirm config.toml contains:
base_url = "https://api.routescope.ai/v1"Do not omit /v1, and do not add an extra trailing /.
model not found or Model Unavailable
The model / review_model value does not exist, or your token is not allowed to use it.
- Return to Routescope Model Plaza.
- Copy the full model ID allowed by your token.
- Replace
modelandreview_modelinconfig.toml. - Save, close the terminal, and restart Codex.
Codex Replies, but Routescope Has No Operation Record
This usually means the current request did not use Routescope, or old local settings pointed it elsewhere.
-
Confirm
base_urlinconfig.tomlishttps://api.routescope.ai/v1. -
Confirm you reopened the terminal after changing configuration.
-
If you previously set Codex environment variables, clear them:
unset OPENAI_BASE_URL OPENAI_API_KEYOn Windows, run this in Git Bash.
-
Send another request and refresh Operation Records.
Authentication Still Fails (Advanced)
In rare cases, you may need to change requires_openai_auth in config.toml to false. This is advanced troubleshooting; contact Routescope support before changing it.
Still Stuck
Do not keep guessing. Send support a screenshot of the step where you are stuck, with the secret masked. You can also switch to CC Switch graphical setup.
Advanced (Optional)
Most users can skip this section after setup succeeds.
Use an Environment Variable Instead of auth.json
If you know how to configure system environment variables, you can add this line under [model_providers.OpenAI]:
env_key = "OPENAI_API_KEY"Then set your secret in a system environment variable named OPENAI_API_KEY. Codex will read it from there, so auth.json is not needed. New users do not need this.
config.toml Field Meanings
| Field | Purpose |
|---|---|
model | Main default chat model |
review_model | Code review / review model; can match the main model |
model_reasoning_effort | Reasoning effort. xhigh is strongest but slower and more expensive; use high or medium for faster, cheaper runs |
wire_api | Protocol used between Codex and the gateway. Routescope uses responses |
base_url | Service endpoint. Codex must include /v1 |
requires_openai_auth | Whether to send the secret with OpenAI-style auth. Default is true; change only in rare cases |
disable_response_storage | Disables response storage |
network_access | Allows Codex network access |
model_context_window / model_auto_compact_token_limit | Context window and auto-compaction threshold |
Only set different model and review_model values after confirming your token can access multiple models.
References
Last updated on