Use RouterBrain as the model backend in the Codex desktop agent.
Codex is OpenAI's official desktop coding agent. Point a custom model provider at RouterBrain's OpenAI-compatible surface (including the Responses API) to use console keys and the shared catalog.
Prerequisites
- An inference API key from the console (API keys)
- A catalog
idfrom List models
Install Codex
Download and install from the OpenAI Codex page.
Configure RouterBrain API
Step 1 — Edit config
Open user-level ~/.codex/config.toml (do not put keys in repo .codex/config.toml; project config cannot override model_providers).
Replace YOUR_MODEL_ID and YOUR_ROUTERBRAIN_KEY:
model = "YOUR_MODEL_ID"
model_provider = "routerbrain"
[model_providers.routerbrain]
name = "RouterBrain"
base_url = "https://51kik.com/v1"
experimental_bearer_token = "YOUR_ROUTERBRAIN_KEY"
wire_api = "responses"
| Field | Value |
|---|---|
model | Catalog id |
base_url | OpenAI-compatible root with /v1 |
wire_api | RouterBrain supports OpenAI Responses API (/v1/responses)—Codex's default wire |
experimental_bearer_token | Console inference key |
Security
Prefer an env var instead of a plaintext key:
export ROUTERBRAIN_API_KEY="YOUR_ROUTERBRAIN_KEY"Provider block:
env_key = "ROUTERBRAIN_API_KEY"Remove
experimental_bearer_token.
If Responses fails but chat works, try wire_api = "chat" (depends on Codex version and gateway—see Chat Completions).
Step 2 — Restart Codex
Save, fully quit, and relaunch Codex to use the new model.
Model capability catalog (optional)
Codex can read a custom catalog for reasoning, modalities, tools, etc. After setup, /model in the CLI lists the model and reasoning options.
Add to ~/.codex/config.toml:
model_catalog_json = "~/.codex/model-catalogs/routerbrain-catalog.json"
Create ~/.codex/model-catalogs/routerbrain-catalog.json (replace YOUR_MODEL_ID; tune fields to your model):
{
"models": [
{
"slug": "YOUR_MODEL_ID",
"display_name": "RouterBrain Model",
"description": "RouterBrain gateway model",
"default_reasoning_level": "none",
"supported_reasoning_levels": [
{ "effort": "none", "description": "Off" },
{ "effort": "high", "description": "On" }
],
"shell_type": "shell_command",
"visibility": "list",
"supported_in_api": true,
"priority": 0,
"base_instructions": "You are Codex, a coding agent routed through RouterBrain.",
"supports_reasoning_summaries": false,
"default_reasoning_summary": "none",
"support_verbosity": false,
"truncation_policy": { "mode": "bytes", "limit": 10000 },
"supports_parallel_tool_calls": true,
"experimental_supported_tools": [],
"input_modalities": ["text"]
}
]
}
Key fields:
slug/display_namemust matchmodelinconfig.tomland the API model name.- Enable reasoning fields only if the catalog model supports it; otherwise keep
noneandsupports_reasoning_summaries: false. - Set
input_modalitiesto["text", "image"]when vision is supported. supports_parallel_tool_callsdeclares parallel tool support.
Restart Codex after edits.
Verify
- Run
/modelin Codex CLI and confirm your model appears. - Send a simple coding prompt; 401 / 403 → Errors.
- Optional: validate with curl first (First request).
Quick reference
| Field | Value |
|---|---|
| Config file | ~/.codex/config.toml |
| Provider | routerbrain |
| Base URL | https://51kik.com/v1 |
| API Key | Console inference key |
| Model | Catalog id |