---
title: "Claude Code integration"
description: "Settings for using Claude Code with minirouter."
canonical_url: "https://minirouter.sh/integrations/claude-code"
markdown_url: "https://minirouter.sh/integrations/claude-code.md"
last_updated: "2026-09-13"
---

# Claude Code + minirouter

Environment variables for using Claude Code with MiniRouter's Anthropic-compatible Messages endpoint.

Base URL: https://api.minirouter.sh/v1
Get a key: https://minirouter.sh/key

## Settings

Shell environment, or env in ~/.claude/settings.json

1. ANTHROPIC_BASE_URL: https://api.minirouter.sh
   Use the bare host. Claude Code adds /v1/messages itself.
2. ANTHROPIC_AUTH_TOKEN: $MINIROUTER_KEY
   Claude Code sends this value as a Bearer token.
3. ANTHROPIC_MODEL: zai/glm-5.3-flash
   Use the full ID of a tool-capable model from the live catalog.

## Configuration

Shell

```
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"

claude --model "$ANTHROPIC_MODEL"
```

## Recommended models

Only use a model after confirming it appears in the live model catalog at https://minirouter.sh/api/v1/models.

- 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

### 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 reference: https://minirouter.sh/docs/errors#unknown_model

### 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 reference: https://minirouter.sh/docs/errors#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 reference: https://minirouter.sh/docs/errors#insufficient_credits
