Skip to content

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.toml for provider auth. Codex ignores project-local model_provider and model_providers keys 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 CodexTemporary command for the current terminal
macOS, Linux, WSL, Git Bashexport ROUTMY_API_KEY="sk_your_key_here"
Windows PowerShell$env:ROUTMY_API_KEY="sk_your_key_here"
Windows cmd.exeset ROUTMY_API_KEY=sk_your_key_here

Check that the terminal can see the key:

bash
echo "$ROUTMY_API_KEY"

In PowerShell, use:

powershell
echo $env:ROUTMY_API_KEY

In cmd.exe, use:

bat
echo %ROUTMY_API_KEY%

If this prints nothing, Codex will not see the key either.

For a persistent setup, use one of these:

bash
# macOS/Linux/WSL with zsh
echo 'export ROUTMY_API_KEY="sk_your_key_here"' >> ~/.zshrc
source ~/.zshrc
bash
# macOS/Linux/WSL with bash
echo 'export ROUTMY_API_KEY="sk_your_key_here"' >> ~/.bashrc
source ~/.bashrc
powershell
# Windows PowerShell
[Environment]::SetEnvironmentVariable("ROUTMY_API_KEY", "sk_your_key_here", "User")
bat
:: 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:

bash
curl https://api.rout.my/v1/models \
  -H "Authorization: Bearer $ROUTMY_API_KEY"

Windows PowerShell:

powershell
curl.exe https://api.rout.my/v1/models -H "Authorization: Bearer $env:ROUTMY_API_KEY"

Windows cmd.exe:

bat
curl.exe https://api.rout.my/v1/models -H "Authorization: Bearer %ROUTMY_API_KEY%"

The ready-to-use default for this guide is:

text
openai/gpt-5.4

You do not need to choose a model manually. Use openai/gpt-5.4 unless you intentionally want another option:

Use caseModel
Default Codex setupopenai/gpt-5.4
Cheaper/faster Codex setupopenai/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:

bash
# macOS/Linux/WSL
mkdir -p ~/.codex
nano ~/.codex/config.toml
powershell
# Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.codex" | Out-Null
notepad "$HOME\.codex\config.toml"
bat
:: Windows cmd.exe
mkdir "%USERPROFILE%\.codex"
notepad "%USERPROFILE%\.codex\config.toml"

Add this block:

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"

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:

bash
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:

powershell
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:

bash
codex

For a one-off non-interactive check:

bash
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:

bash
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:

toml
# ~/.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:

bash
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:

  1. Open a fresh terminal.
  2. Set ROUTMY_API_KEY using the command for that terminal.
  3. Run echo "$ROUTMY_API_KEY" or echo $env:ROUTMY_API_KEY in PowerShell.
  4. Run curl https://api.rout.my/v1/models -H "Authorization: Bearer $ROUTMY_API_KEY".
  5. Paste the ready openai/gpt-5.4 config block into ~/.codex/config.toml.
  6. Only change the model if you intentionally want openai/gpt-5.4-mini or another exact ID from /v1/models.
  7. Start codex from 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

SymptomWhat to check
ROUTMY_API_KEY is ignoredenv_key = "ROUTMY_API_KEY" points to an environment variable. Export it in the same shell before running codex.
PowerShell curl behaves oddlyUse curl.exe so PowerShell does not invoke its old curl alias.
echo $ROUTMY_API_KEY prints nothingYou 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 notEnvironment 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 WindowsWSL is a separate Linux environment. Run the macOS/Linux/WSL export command inside WSL.
Codex still uses OpenAI directlyCheck model_provider = "routmy" in user-level ~/.codex/config.toml, not only in project .codex/config.toml.
Request hits /v1/chat/completionsSet wire_api = "responses". Codex's Chat Completions provider path is deprecated for custom providers.
404 or doubled pathbase_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 availableRun GET /v1/models with the same rout.my key and copy the exact returned model ID.
401Re-run the curl /v1/models check. If it fails, the key is missing, expired, or exported in a different shell.
Config seems ignored in CISet 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.

Sources

API documentation for rout.my.