Codex
Use rout.my as a Codex custom model provider when you want Codex CLI or the Codex IDE extension to send OpenAI Responses-style requests through rout.my.
This guide was checked against the current OpenAI Codex configuration docs and the public Codex Responses migration discussion. The important bits are:
- Use
wire_api = "responses"for Codex. - Put provider credentials in your user-level Codex config, usually
~/.codex/config.toml. - Do not use a project
.codex/config.tomlfor provider auth. Codex ignores project-localmodel_providerandmodel_providerskeys for security. - This guide is pre-filled with rout.my's recommended Codex model:
openai/gpt-5.4.
1. Create a rout.my key
Create or copy an API key in the rout.my dashboard, then set it in the same terminal where you start Codex.
Pick the command for your operating system and shell:
| Where you run Codex | Temporary command for the current terminal |
|---|---|
| macOS, Linux, WSL, Git Bash | export ROUTMY_API_KEY="sk_your_key_here" |
| Windows PowerShell | $env:ROUTMY_API_KEY="sk_your_key_here" |
| Windows cmd.exe | set ROUTMY_API_KEY=sk_your_key_here |
Check that the terminal can see the key:
echo "$ROUTMY_API_KEY"In PowerShell, use:
echo $env:ROUTMY_API_KEYIn cmd.exe, use:
echo %ROUTMY_API_KEY%If this prints nothing, Codex will not see the key either.
For a persistent setup, use one of these:
# macOS/Linux/WSL with zsh
echo 'export ROUTMY_API_KEY="sk_your_key_here"' >> ~/.zshrc
source ~/.zshrc# macOS/Linux/WSL with bash
echo 'export ROUTMY_API_KEY="sk_your_key_here"' >> ~/.bashrc
source ~/.bashrc# Windows PowerShell
[Environment]::SetEnvironmentVariable("ROUTMY_API_KEY", "sk_your_key_here", "User"):: Windows cmd.exe
setx ROUTMY_API_KEY "sk_your_key_here"After setx or [Environment]::SetEnvironmentVariable, close the terminal and open a new one. Existing Windows terminals do not automatically receive the new value.
ROUTMY_API_KEY is not a fixed Codex variable. It is the variable name we will reference from env_key below.
2. Check your key and default model
The snippets below already use openai/gpt-5.4. Before editing Codex config, verify that your key can see the model catalog:
curl https://api.rout.my/v1/models \
-H "Authorization: Bearer $ROUTMY_API_KEY"Windows PowerShell:
curl.exe https://api.rout.my/v1/models -H "Authorization: Bearer $env:ROUTMY_API_KEY"Windows cmd.exe:
curl.exe https://api.rout.my/v1/models -H "Authorization: Bearer %ROUTMY_API_KEY%"The ready-to-use default for this guide is:
openai/gpt-5.4You do not need to choose a model manually. Use openai/gpt-5.4 unless you intentionally want another option:
| Use case | Model |
|---|---|
| Default Codex setup | openai/gpt-5.4 |
| Cheaper/faster Codex setup | openai/gpt-5.4-mini |
If you change the model, copy the exact ID from /v1/models; do not shorten it or remove the provider prefix.
3. Add a Codex provider
Open your user-level Codex config. Pick one:
# macOS/Linux/WSL
mkdir -p ~/.codex
nano ~/.codex/config.toml# Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.codex" | Out-Null
notepad "$HOME\.codex\config.toml":: Windows cmd.exe
mkdir "%USERPROFILE%\.codex"
notepad "%USERPROFILE%\.codex\config.toml"Add this block:
model = "openai/gpt-5.4"
model_provider = "routmy"
[model_providers.routmy]
name = "rout.my"
base_url = "https://api.rout.my/v1"
env_key = "ROUTMY_API_KEY"
wire_api = "responses"This block is ready to paste as-is after you set ROUTMY_API_KEY.
Keep base_url as https://api.rout.my/v1, not https://api.rout.my/v1/responses. Codex appends the endpoint path itself.
4. Run a direct Responses check
This checks the same endpoint family Codex will use:
curl https://api.rout.my/v1/responses \
-H "Authorization: Bearer $ROUTMY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4",
"input": "Return one short deployment checklist."
}'If this fails, fix the API key, model ID, or account access before testing Codex.
Windows PowerShell equivalent:
curl.exe https://api.rout.my/v1/responses `
-H "Authorization: Bearer $env:ROUTMY_API_KEY" `
-H "Content-Type: application/json" `
-d "{\"model\":\"openai/gpt-5.4\",\"input\":\"Return one short deployment checklist.\"}"5. Start Codex
If the config above is your default:
codexFor a one-off non-interactive check:
codex exec "Return one short deployment checklist."If you do not want rout.my to be your default provider, keep the provider block in ~/.codex/config.toml and pass a one-off override:
codex exec \
--config model_provider='"routmy"' \
--model "openai/gpt-5.4" \
"Return one short deployment checklist."Codex --config values are parsed as TOML, so the nested quotes around "routmy" are intentional.
Optional profile
You can keep rout.my in a separate Codex profile:
# ~/.codex/routmy.config.toml
model = "openai/gpt-5.4"
model_provider = "routmy"
[model_providers.routmy]
name = "rout.my"
base_url = "https://api.rout.my/v1"
env_key = "ROUTMY_API_KEY"
wire_api = "responses"Run it with:
codex --profile routmy
codex exec --profile routmy "Return one short deployment checklist."Copy-paste checklist
Use this when you are helping someone who does not understand environment variables:
- Open a fresh terminal.
- Set
ROUTMY_API_KEYusing the command for that terminal. - Run
echo "$ROUTMY_API_KEY"orecho $env:ROUTMY_API_KEYin PowerShell. - Run
curl https://api.rout.my/v1/models -H "Authorization: Bearer $ROUTMY_API_KEY". - Paste the ready
openai/gpt-5.4config block into~/.codex/config.toml. - Only change the model if you intentionally want
openai/gpt-5.4-minior another exact ID from/v1/models. - Start
codexfrom the same terminal.
Do not paste the rout.my key directly into config.toml. Codex has a direct bearer-token config field, but the official sample marks it as dev-only experimental. Use env_key = "ROUTMY_API_KEY" for normal setup.
Common errors
| Symptom | What to check |
|---|---|
ROUTMY_API_KEY is ignored | env_key = "ROUTMY_API_KEY" points to an environment variable. Export it in the same shell before running codex. |
PowerShell curl behaves oddly | Use curl.exe so PowerShell does not invoke its old curl alias. |
echo $ROUTMY_API_KEY prints nothing | You are in the wrong shell, or you used a command for another OS. Use $env:ROUTMY_API_KEY in PowerShell and %ROUTMY_API_KEY% in cmd.exe. |
| PowerShell works, but cmd.exe does not | Environment variables are per shell. Set the variable in the shell where you run codex, or use the persistent Windows command and reopen the terminal. |
| WSL cannot see the key from Windows | WSL is a separate Linux environment. Run the macOS/Linux/WSL export command inside WSL. |
| Codex still uses OpenAI directly | Check model_provider = "routmy" in user-level ~/.codex/config.toml, not only in project .codex/config.toml. |
Request hits /v1/chat/completions | Set wire_api = "responses". Codex's Chat Completions provider path is deprecated for custom providers. |
404 or doubled path | base_url should be https://api.rout.my/v1, not https://api.rout.my, https://api.rout.my/v1/responses, or a full request URL. |
model_not_found or No providers available | Run GET /v1/models with the same rout.my key and copy the exact returned model ID. |
401 | Re-run the curl /v1/models check. If it fails, the key is missing, expired, or exported in a different shell. |
| Config seems ignored in CI | Set CODEX_HOME only if you also created that directory and placed the intended config.toml there. Otherwise Codex uses ~/.codex. |
Why these settings
OpenAI's Codex docs define custom model providers with model_providers.<id>, base_url, env_key, and wire_api. The same docs say provider configuration belongs in user-level config because project-local .codex/config.toml cannot override provider auth or provider selection.
OpenAI also documents CODEX_API_KEY as a single-run variable for codex exec, while custom provider API keys come from the variable named by env_key. For rout.my, the examples use ROUTMY_API_KEY to avoid confusing it with OpenAI's own OPENAI_API_KEY.