Claude Code speaks the Anthropic Messages API. Point it at ModRouter’s /anthropic integration.

Endpoint

Set MODROUTER_BASE_URL in the environment used to launch Claude Code.

Basic Setup

Set the Anthropic-compatible base URL and provide either a ModRouter virtual key or a placeholder key if your deployment does not enforce virtual-key auth:
Some Claude Code versions use ANTHROPIC_API_KEY instead of ANTHROPIC_AUTH_TOKEN. Use the variable your installed version documents.

Model Routing

Claude Code sends Anthropic-style model names. In ModRouter, you can either:
  • create routing rules that map Claude Code’s requested model names to the provider/model you want, or
  • pin Claude Code’s model variables to ModRouter model IDs if your Claude Code version supports model overrides.
Example:
You can route to non-Anthropic providers through ModRouter, but the selected model must handle tool calls well. Claude Code depends on tool calling for file edits, shell commands, and structured agent work.

MCP Gateway

Claude Code can also connect to ModRouter’s MCP server:
Use x-bf-vk or X-Api-Key instead of Authorization only if another part of your setup owns the bearer token.
If the same Claude Code session uses ModRouter for LLM traffic and also connects to ModRouter’s /mcp endpoint, avoid double-injecting the same MCP tools through both paths. See MCP Gateway for the recommended tool-injection setup.