All guides

Set Up Claude Code with MonoRouter

One command to install, one command to uninstall. Takes about 60 seconds.


What you need

  • A Claude Pro or Max subscription at claude.ai
  • Claude Code installed locally — npm i -g @anthropic-ai/claude-code (v2.1.129+ recommended for model discovery)
  • A MonoRouter account — sign up at /signup
  • A MonoRouter API key (mrk_*) — get one at /keys
  • Your Claude subscription connected to MonoRouter — go to /tokens, click [ + add token ], and run the auto-connect script

Sign up for MonoRouter

Open /signup, enter your email and set a password. Save the six recovery codes — they're your offline fallback if you lose your password; you can also always reset it by email at /forgot-password.

Connect your Claude subscription

From the dashboard, go to /tokens, click [ + add token ], and pick ANTHROPIC. Use the auto-connect tab — it's the fastest.

The modal shows a one-liner like this:

bash
curl -sSL https://api.monorouter.dev/connect.sh | bash -s -- mrc_xxxxxxxxxxxx

Paste it into a terminal. The script runs claude setup-token, which opens a browser window for authorization and creates a long-lived token (valid for 1 year). When the dashboard flips to connected, you're done.

Install with one command

Replace mrk_your_key_here with your actual MonoRouter API key:

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

The script does three things:

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

Verify it works

Open a new terminal, then run:

bash
claude

Inside Claude Code, run /status — 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.

Or test with curl:

bash
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 you're done. The call also shows up on /dashboard within a second or two.

Model discovery

The setup script enables CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY, which tells Claude Code to probe MonoRouter's /v1/models endpoint at startup. All supported models — including Fable — appear in the /model picker labeled From gateway.

Requires Claude Code v2.1.129+. Run claude --version to check.

Uninstall

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

Removes the environment variables, revokes the key approval in ~/.claude.json, and cleans up 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, just run install again with the new key:

bash
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.

Pricing

  • 1,500 successful calls are free for the lifetime of your account. Failed calls don't count.
  • After that, paid plans start at $9/month (Hobby, 10,000 calls). Pro is $29/month for unlimited personal use; Team is $99/month for 5 pooled seats. See /billing for the payment flow.

Ready to get started?

Sign up in 30 seconds — no credit card required. 1,500 free API calls included.

guide: set up Claude Code with MonoRouter · monorouter