Configuring Codex CLI in CC Switch
This guide explains how to configure OpenAI Codex CLI to route through RKAPI using CC Switch, including the exact config.toml and auth.json settings required by the Responses API.
Prerequisites
- Codex CLI installed locally (see Codex CLI for installation steps).
- CC Switch installed (see CC Switch Overview).
- An RKAPI API key (
sk-...) from https://s2pbxm0xv5y.adtyai-fz.top with access to Codex-compatible models. - No conflicting
OPENAI_API_KEYorOPENAI_BASE_URLvariables in your shell (see Common Configuration).
Step 1: Add an RKAPI Provider in CC Switch
- Open CC Switch and switch to the Codex tab.
- Click Add Provider (
+) and select Custom. - Fill in the provider parameters:
| Field | Value | Notes |
|---|---|---|
| Provider Name | RKAPI | Display name in CC Switch |
API Base URL (base_url) | https://api.zwwbai.com/v1 | Must include /v1 |
API Key (OPENAI_API_KEY) | sk-your-api-key | Paste your RKAPI API key |
Wire API (wire_api) | responses | Required by modern Codex CLI builds |
Model (model) | gpt-5.4 | Or another Codex model listed on https://s2pbxm0xv5y.adtyai-fz.top/pricing |
Keep /v1 and wire_api = "responses"
Unlike Claude Code, Codex CLI expects /v1 in base_url (https://api.zwwbai.com/v1) and communicates via the OpenAI Responses protocol (wire_api = "responses"). Omitting /v1 or setting wire_api = "chat" causes endpoint or schema errors.
Step 2: Preview Generated config.toml and auth.json
CC Switch manages both Codex configuration files together. Before saving, review the generated content in CC Switch's preview pane.
~/.codex/config.toml
model_provider = "gateway"
model = "gpt-5.4"
model_reasoning_effort = "high"
[model_providers.gateway]
name = "RKAPI"
base_url = "https://api.zwwbai.com/v1"
wire_api = "responses"
requires_openai_auth = true~/.codex/auth.json
{
"OPENAI_API_KEY": "sk-your-api-key"
}File locations written by CC Switch:
- macOS / Linux:
~/.codex/config.tomland~/.codex/auth.json - Windows:
%USERPROFILE%\.codex\config.tomland%USERPROFILE%\.codex\auth.json
Choosing a Model
Always verify exact model names available to your API key group on https://s2pbxm0xv5y.adtyai-fz.top/pricing. You can also create multiple CC Switch profiles—for example, one pinned to a flagship reasoning model and another pinned to a faster model—and toggle between them in one click.
Step 3: Activate the Profile
- Click Save in CC Switch.
- Select the
RKAPIprofile under the Codex tab and click Enable / Switch. - Verify the files on disk:
macOS / Linux:
cat ~/.codex/config.tomlWindows PowerShell:
Get-Content "$env:USERPROFILE\.codex\config.toml"Step 4: Verify Codex CLI in Terminal
Open a new terminal in your repository and launch Codex CLI:
codexOr run a quick non-interactive smoke test:
codex exec "Reply with OK and confirm the current directory name."If everything is configured properly:
- Codex CLI starts immediately without asking you to sign in via a browser.
- The response completes cleanly using your selected model.
- The request appears in https://s2pbxm0xv5y.adtyai-fz.top/usage-logs under your API key.
Common Issues
| Symptom | Likely Cause | Fix |
|---|---|---|
401 Unauthorized | Wrong key, expired key, or an old OPENAI_API_KEY env var overriding auth.json | Clear shell OPENAI_API_KEY and re-activate your profile in CC Switch |
403 Forbidden | Entered https://s2pbxm0xv5y.adtyai-fz.top/v1 instead of https://api.zwwbai.com/v1 | Switch base_url to the dedicated API domain https://api.zwwbai.com/v1 |
404 Not Found | Missing /v1 suffix in base_url | Set base_url = "https://api.zwwbai.com/v1" |
| Model not found / group mismatch | Selected model is not enabled in the key's group | Confirm the model ID on https://s2pbxm0xv5y.adtyai-fz.top/pricing |
For deeper troubleshooting—including reasoning-effort tuning and WSL path quirks—see the Codex FAQ. If you also use the graphical Codex client, continue to Codex Desktop App.