Integrations

Claude Code

Run Anthropic's terminal coding agent on any model in the MiniRouter catalog.

Claude Code is Anthropic's coding agent for the terminal. MiniRouter serves the Anthropic Messages API, so Claude Code runs on any tool-capable model in the catalog, a preset or a router, with one balance and per-key spend limits.

1. Install Claude Code

Terminal
curl -fsSL https://claude.ai/install.sh | bash

2. Point Claude Code at MiniRouter

Create a key, then set these in the shell that launches Claude Code.

Terminal
export MINIROUTER_KEY=mr-live-YOUR-KEY-HERE
export ANTHROPIC_BASE_URL=https://api.minirouter.sh
export ANTHROPIC_AUTH_TOKEN="$MINIROUTER_KEY"
export ANTHROPIC_MODEL="zai/glm-5.3-flash"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000

claude --model "$ANTHROPIC_MODEL"
ANTHROPIC_BASE_URL
https://api.minirouter.shUse the bare host. Claude Code adds /v1/messages itself.
ANTHROPIC_AUTH_TOKEN
$MINIROUTER_KEYShell only. Settings files keep env values literal, so use apiKeyHelper there.
ANTHROPIC_MODEL
zai/glm-5.3-flashUse the full ID of a tool-capable model from the live catalog, or a preset such as @preset/your-preset.
CLAUDE_CODE_MAX_CONTEXT_TOKENS
1000000Optional. Claude Code assumes a 200K window for any model it does not know and compacts early; set the model's real window.

3. Check the connection

Run /status inside the session. It names the base URL and ANTHROPIC_AUTH_TOKEN as the credential.

4. Send a prompt

Ask for anything, then open Activity. The request lists its model, tokens and exact cost.

Switch models

Behind a custom ANTHROPIC_BASE_URL, Claude Code passes any model ID through unchecked.

/model zai/glm-5.3-flash
Inside a session. Saved as your default.
claude --model zai/glm-5.3-flash
One run.
ANTHROPIC_MODEL
Every run from that shell.
@preset/your-slug
Your saved preset. Change it in Presets without touching the shell.
minirouter/auto:code
A tool-capable model Auto picks.
minirouter/fusion
The model Fusion picks per request.

Map every model slot

Background work and subagents use their own slots. Point each at a MiniRouter model.

ANTHROPIC_DEFAULT_OPUS_MODEL
/model opus.
ANTHROPIC_DEFAULT_SONNET_MODEL
/model sonnet.
ANTHROPIC_DEFAULT_HAIKU_MODEL
/model haiku and background tasks such as session titles.
CLAUDE_CODE_SUBAGENT_MODEL
Subagents.
Terminal
export ANTHROPIC_DEFAULT_OPUS_MODEL="openai/gpt-6-sol"
export ANTHROPIC_DEFAULT_SONNET_MODEL="zai/glm-5.3-flash"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="openai/gpt-6-luna"
export CLAUDE_CODE_SUBAGENT_MODEL="zai/glm-5.3-flash"

Save it in settings

Settings files keep the setup across shells. env values are literal, so apiKeyHelper reads the key from your shell instead.

~/.claude/settings.json
{
  "apiKeyHelper": "echo $MINIROUTER_KEY",
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.minirouter.sh",
    "ANTHROPIC_MODEL": "zai/glm-5.3-flash"
  }
}
~/.claude/settings.json
You, every project.
.claude/settings.json
Everyone in the project. Commit it.
.claude/settings.local.json
You, this project only.
  • A settings-file env value wins over the same shell export.
  • An exported ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY wins over apiKeyHelper. Unset them.

Run headless

claude -p runs one task without the interactive session. Use it in scripts and CI, or see Automatic code review for a pull request workflow.

Terminal
claude -p "Run the tests and fix failures" \
  --model zai/glm-5.3-flash \
  --allowedTools "Bash,Read,Edit" \
  --output-format json
--model
Any MiniRouter model ID.
--allowedTools
Tools that run without a prompt.
--output-format json
Prints the result as JSON.

The cost Claude Code prints is its own estimate. Your charge is in Activity.

Keep spend in check

Restrict models or filter content with Guardrails. Rolling out to a team? See Teams.

Troubleshooting

Claude Code calls api.anthropic.com instead of MiniRouter

ANTHROPIC_BASE_URL was not exported into the shell that launched Claude Code. Set it to the bare MiniRouter host, then start a new Claude Code process from that shell.

The selected model name is rejected

Claude aliases such as sonnet and opus are not MiniRouter model IDs. Pass a full author/name ID from the current catalog with --model.

Error: 404 unknown_model.

"is not a model this version of Claude Code recognizes" at startup

Local metadata only; requests still work. Claude Code assumes a 200K window for unknown models, so set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's real window to stop early compaction.

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.

Next steps

Esc