Integrations
Codex
Run OpenAI's coding agent on any model in the MiniRouter catalog.
Codex is OpenAI's coding agent for the terminal and IDE. Point it at MiniRouter's Responses endpoint to run it on any tool-capable model in the catalog, with one balance and per-key spend limits.
1. Install Codex
npm install -g @openai/codexbrew install --cask codex2. Export your key
Create a key, then export it in the shell that launches Codex.
export MINIROUTER_KEY=mr-live-YOUR-KEY-HEREsetx MINIROUTER_KEY mr-live-YOUR-KEY-HERE3. Add the provider
Add MiniRouter to your user-level config.
model = "zai/glm-5.3-flash"
model_provider = "minirouter"
web_search = "disabled"
[model_providers.minirouter]
name = "MiniRouter"
base_url = "https://api.minirouter.sh/v1"
wire_api = "responses"
auth = { command = "sh", args = ["-c", "echo $MINIROUTER_KEY"] }4. Start a session
codexSend one prompt, then open Activity. The request lists its model, tokens and exact cost.
Switch models
/model lists MiniRouter's options in this order:
- Routers:
minirouter/fusion, thenminirouter/autoand its:smart,:cheapand:codeintents. - Your presets, as
@preset/your-slug. - Every tool-capable model, frontier models first.
- /
model - Inside a session.
- codex -m minirouter/
auto: code - One run.
- model = "zai/
glm-5. 3-flash" - The default, in
~/.codex/config.toml.
Pin a model per project
A trusted project can choose its own model. The provider stays in your user config.
model = "@preset/your-slug"A preset lets you change the model from the dashboard without touching the repository.
Run headless
codex exec runs one task without the TUI. Use it in scripts and CI, or see Automatic code review for a pull request workflow.
codex exec -m zai/glm-5.3-flash \
--sandbox workspace-write \
--json "Run the tests and fix failures"- --sandbox workspace-write
- Allows edits. The default is read-only.
- --json
- Prints events as JSON Lines.
- --ephemeral
- Keeps no session files.
Keep spend in check
Restrict models or filter content with Guardrails.
Recommended modelsBrowse every model in the catalog.
zai/glm-5.3-flash- Best current balance of coding ability, agentic performance, context and cost.
openai/gpt-5.6-sol- Higher-intelligence option when task quality matters more than spend.
spacexai/grok-4.6- Strong agentic alternative with a 500K-token window.
google/gemini-3.8-flash- Multimodal coding alternative with a 1M-token window.
Troubleshooting
Codex ignores the MiniRouter provider block
Project .codex/config.toml ignores model_provider, model_providers and profiles, and loads only in trusted projects. Put the provider block in ~/.codex/config.toml.
Codex calls Chat Completions or reports an unsupported wire API
Set wire_api to responses. MiniRouter exposes the Responses route at /v1/responses; Codex appends /responses to the configured base URL.
Error: 400 invalid_request.
Codex prints "provider auth command sh produced an empty token"
MINIROUTER_KEY is not exported in the shell that launched Codex. Run export MINIROUTER_KEY=… in that shell, or add the export to your shell profile, then start Codex again. Without the token Codex also skips the MiniRouter model list, so the fallback-metadata notice follows.
Codex prints "Model metadata … not found. Defaulting to fallback metadata"
Codex 0.153 and later load a third-party model list only through a command-backed auth entry. Replace env_key with the auth line above; with env_key the notice is expected and harmless.
401 on every request
Wrong or rotated key. Keys start with mr-live-; after a rotation the old key keeps working for 24 hours, then dies.
Error: 401 invalid_api_key.
402 before any tokens arrive
Balance below the estimated cost of the request. Top up (from $0.50 with direct Solana payments) — and watch the x-minirouter-balance-usd header, the low-balance signal every response carries.
Error: 402 insufficient_credits.
Every error code, with its fix: Errors.