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

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"
FieldValue
modelCatalog id
base_urlOpenAI-compatible root with /v1
wire_apiRouterBrain supports OpenAI Responses API (/v1/responses)—Codex's default wire
experimental_bearer_tokenConsole 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_name must match model in config.toml and the API model name.
  • Enable reasoning fields only if the catalog model supports it; otherwise keep none and supports_reasoning_summaries: false.
  • Set input_modalities to ["text", "image"] when vision is supported.
  • supports_parallel_tool_calls declares parallel tool support.

Restart Codex after edits.

Verify

  1. Run /model in Codex CLI and confirm your model appears.
  2. Send a simple coding prompt; 401 / 403 → Errors.
  3. Optional: validate with curl first (First request).

Quick reference

FieldValue
Config file~/.codex/config.toml
Providerrouterbrain
Base URLhttps://51kik.com/v1
API KeyConsole inference key
ModelCatalog id

Related