---
title: Connect Codex CLI to RouterHub
description: Connect OpenAI’s Codex CLI to RouterHub using a separate provider profile. Get configuration, exact save locations, launch instructions, troubleshooting, and common questions.
canonical: https://routerhub.si/guides/codex
---

# Connect Codex CLI to RouterHub
Connect OpenAI’s Codex CLI to RouterHub using a separate provider profile.
[Try it in web chat](https://routerhub.si/)or choose a tool below
Current models, rates, availability, and limits: [Models & pricing](https://routerhub.si/models)

-
## Step 1: Copy and save the config
routerhub.config.toml

```
model_provider = "routerhub"

[model_providers.routerhub]
name = "RouterHub"
base_url = "https://routerhub.si/v1"
env_key = "ROUTERHUB_API_KEY"
wire_api = "responses"
stream_idle_timeout_ms = 600000
```

### macOS / Linux
Save as `~/.codex/routerhub.config.toml`.

### Windows
Save as `%USERPROFILE%/.codex/routerhub.config.toml`.

Create any missing folders. If the file already exists, merge these settings without replacing your other settings. Keep your key private and out of repositories.
[Download config](https://routerhub.si/docs/downloads/routerhub-codex.config.toml). Your usual Codex config and saved login stay unchanged.

-
## Step 2: Set your API key
Replace the placeholder with your RouterHub key and run:

### macOS / Linux
macOS / Linux

```
export ROUTERHUB_API_KEY='PASTE_ROUTERHUB_KEY_HERE'
```

### Windows (PowerShell)
Windows (PowerShell)

```
$env:ROUTERHUB_API_KEY = 'PASTE_ROUTERHUB_KEY_HERE'
```

This sets the key for this terminal. Keep it and its command history private; close it when finished.

-
## Step 3: Start Codex
Copy a model ID with Responses support from the [models and pricing page](https://routerhub.si/models). Replace `MODEL_ID` below and run in the same terminal:
Run in your terminal

```
codex --profile routerhub --model MODEL_ID
```

Check that Codex shows RouterHub and your chosen model. To switch, quit and launch with another Responses model ID.

**Need to install Codex CLI?**
Install a current Codex CLI with `npm install -g @openai/codex`, or use the [official installer](https://developers.openai.com/codex/cli). This profile format needs Codex 0.134.0+.

**Check the connection (optional)**

  When you’re ready to use credits, open an empty project and send this short test:

  Reply with OK. Do not read files, run commands, or make edits.
  Open [RouterHub usage](https://routerhub.si/dashboard/usage) and check that the request appears under the right model. Keep auto-approval off while testing. A text reply checks the connection, not all coding features.

## Troubleshooting

**A stream stops while the model is thinking**
The provider sets `stream_idle_timeout_ms = 600000`: ten minutes without an SSE event, not a whole-request or tool-execution limit. Codex does not document OpenCode-style header/chunk/total timeout keys in this provider config, so do not add them. This does not disable the client’s built-in retry behavior. Check Usage and the request ID before manually retrying.

**Codex still shows OpenAI or ChatGPT**
Launch with `--profile routerhub`. On Codex 0.134.0 or later, use `routerhub.config.toml` beside your user config, not an old `[profiles.routerhub]` table. Inspect startup/status information before sending a prompt.

**Missing key or 401**
Enter a RouterHub key in the same terminal. The profile reads `ROUTERHUB_API_KEY` with `env_key`; do not replace or delete your saved ChatGPT credentials.

**404 or model unavailable**
Use `https://routerhub.si/v1` and an exact Responses-capable ID. Do not append `/responses` to the base URL or substitute a Chat Completions-only model.

**Streaming, reasoning, or tools fail**
Stop repeated retries. Send support the redacted error, model ID, CLI version, and request ID. This setup has not been tested against RouterHub with authenticated end-to-end requests.

Still stuck? [Contact support](https://routerhub.si/dashboard/support).

## Common questions

**Does this use my ChatGPT subscription?**
No. The RouterHub profile uses your RouterHub API key and prepaid balance. Your saved ChatGPT login is left alone.

**Can Codex use every RouterHub model?**
Not through this setup. It uses wire_api = "responses", so choose a model with Responses support on the models page. That is not a guarantee of every Codex feature.

[Browse setup guides](https://routerhub.si/guides) · [API reference](https://routerhub.si/docs#api-reference)
