Configure a model provider for Codex
Connect Flatrouter to Codex CLI with CC Switch, and pick models that support the Responses protocol.
The easiest route is CC Switch, an open-source provider manager with a visual UI. No hand-edited JSON, no environment variables.
1. Install CC Switch
macOS
brew install --cask cc-switchOr download the .dmg from Releases and install it manually.
Windows
Download the .msi installer from Releases.
Linux
# Debian / Ubuntu
sudo dpkg -i CC-Switch-*.deb
# Fedora / RHEL
sudo rpm -i CC-Switch-*.rpm
# AppImage
chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImageRequires macOS 12+, Windows 10+, or Ubuntu 22.04+ / Debian 11+ / Fedora 34+.
2. Add the provider
Step 1: create a provider
Switch to the Codex tab at the top, then click the + button in the top right.
Step 2: fill in the details
Fill in the fields below, then click + Add.
| Field | Value | Notes |
|---|---|---|
| ❶ Provider name | flatrouter-codex | Anything you like — it is just a label |
| ❷ Website | https://flatrouter.com | The provider's site |
| ❸ API key | Your Flatrouter API key | From Console → API Keys |
| ❹ Base URL | https://api.flatrouter.com/v1 | No trailing slash |
| ❺ API format | OpenAI Compatible | Pick the OpenAI-compatible format |
| ❻ Write to global config | ✅ Ticked | Applies the config to every project |
CC Switch writes the config file for you — no file editing required.
Step 3: activate the provider
Back in the list, select flatrouter-codex and click Use. A "switched successfully" toast means you are done. With Write to global config ticked, the settings land in config.toml automatically.
3. Verify
codex "Hi, tell me about yourself"A normal AI response means the setup worked.
4. Choosing a model
codex --model <model-id> "Refactor this function"Mind the Responses protocol
Codex CLI uses the OpenAI Responses API (wire_api = "responses"), and not every model supports that format. Before picking one, check the Flatrouter model list to confirm the model supports Responses, otherwise the request will fail.
Troubleshooting
Q: "Authentication error"
Check that the API key is filled in correctly and that the base URL has no trailing slash.
Q: Connection timeouts
Make sure the base URL is exactly https://api.flatrouter.com/v1, with no trailing slash.