Set Up Claude Code with MonoRouter in 60 Seconds

A step-by-step guide to routing Claude Code through your Claude Pro or Max subscription using MonoRouter. One command to install, one command to uninstall.

If you have a Claude Pro or Max subscription, you're already paying for Claude. MonoRouter lets you route Claude Code through that subscription instead of paying separately for API credits. This guide gets you set up in under a minute.

What You Need

  • A Claude Pro or Max subscription at claude.ai
  • Claude Code installed on your machine (npm i -g @anthropic-ai/claude-code)
  • A MonoRouter account — sign up at monorouter.dev/signup (no email required)
  • A MonoRouter API key (mrk_*) — get one at monorouter.dev/keys after signing up
  • Your Claude subscription connected to MonoRouter — go to monorouter.dev/tokens, click [ + add token ], and run the auto-connect script it gives you

Once you have your mrk_* key and at least one Claude token connected, you're ready.

Install

One command. Replace mrk_your_key_here with your actual MonoRouter API key:

curl -sSL https://api.monorouter.dev/setup/claude-code.sh | bash -s -- install mrk_your_key_here

That's it. The script does three things:

  1. Adds ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, and CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY to your shell config (~/.zshrc, ~/.bashrc, or ~/.profile)
  2. Pre-approves the key in ~/.claude.json so Claude Code doesn't prompt you about it
  3. Cleans up any existing Anthropic environment variables that might conflict

Open a new terminal, then:

claude

Run /status inside Claude Code — you should see https://api.monorouter.dev/apicompatible as the base URL. If you were previously logged in with an Anthropic account, run /logout first.

Uninstall

curl -sSL https://api.monorouter.dev/setup/claude-code.sh | bash -s -- uninstall

This reverses everything: removes the environment variables from your shell config, revokes the key approval in ~/.claude.json, and cleans up any stray exports. Open a new terminal, run claude, then /login to sign back in with your Anthropic account.

Update Your Key

If your MonoRouter key changes (you rotated it, created a new one, etc.), just run the install command again with the new key:

curl -sSL https://api.monorouter.dev/setup/claude-code.sh | bash -s -- install mrk_new_key_here

The script is idempotent — it replaces the previous config block instead of appending duplicates.

What the Script Adds to Your Shell Config

The install command writes a clearly marked block to your shell rc file:

# >>> claude-code-monorouter >>>
export ANTHROPIC_BASE_URL="https://api.monorouter.dev/apicompatible"
export ANTHROPIC_API_KEY="mrk_..."
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
# <<< claude-code-monorouter <<<
  • ANTHROPIC_BASE_URL — tells Claude Code to route through MonoRouter instead of the Anthropic API directly
  • ANTHROPIC_API_KEY — your MonoRouter API key (sent as x-api-key)
  • CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY — tells Claude Code to probe MonoRouter's /v1/models endpoint so all supported models (including Fable) show up in the /model picker

The block is self-contained. The uninstall command removes exactly this block and nothing else.

Verify It Works

After installing and opening a new terminal:

curl -X POST https://api.monorouter.dev/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: mrk_your_key_here" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 128,
    "messages": [{"role": "user", "content": "hi"}]
  }'

A 200 with a JSON response means everything is working. The call also shows up on your MonoRouter dashboard within a second or two.

Available Models

MonoRouter supports all current Claude models. After setup, run /model inside Claude Code to see the full list:

ModelIDContextMax output
Fable 5claude-fable-51M128k
Opus 4.8claude-opus-4-81M128k
Opus 4.7claude-opus-4-71M128k
Opus 4.6claude-opus-4-61M128k
Sonnet 5claude-sonnet-51M128k
Sonnet 4.6claude-sonnet-4-61M128k
Haiku 4.5claude-haiku-4-5200k64k

Models discovered from MonoRouter appear in the /model picker labeled From gateway.

Multiple Machines

The install command works the same way on every machine. Just run it with your key:

curl -sSL https://api.monorouter.dev/setup/claude-code.sh | bash -s -- install mrk_your_key_here

If you don't want to type the key every time, save the setup script locally and bake the key in. See the advanced setup repo for a version that installs a global monorouter command with the key embedded — then it's just monorouter -i claude on any new machine.

Pricing

MonoRouter is free for life if you sign up before September 8, 2026. After that, it's $99/month for unlimited calls. No per-call charges, no token metering — just a flat rate. You're already paying Anthropic for your Pro or Max subscription; MonoRouter just lets you use it from Claude Code and other tools.

Troubleshooting

Not logged in · Please run /login — This usually means Claude Code rejected the API key at some point. The setup script pre-approves it, but if you ran /login after installing, it can override. Run /logout, open a new terminal, and try again.

Old environment variables overriding — If you previously set ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY by hand, the setup script automatically removes those stray exports. If they're set in a file the script doesn't manage (like ~/.bash_profile on some Linux distros), remove them manually.

Models not showing up in /model — Make sure you're on Claude Code v2.1.129 or later. The CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY variable requires this version. Run claude --version to check.

Rate limit errors — MonoRouter rotates across all your connected Claude tokens automatically. If you hit rate limits with one token, it switches to the next. If you only have one token, MonoRouter keeps it active and retries — it won't lock you out for 5 minutes like a naive cooldown would.