Claude Code with nRouter
Route supported Claude Code traffic through nRouter with governed OpenAI or Anthropic endpoints, keeping budgets and guardrails in the request path.
Last updated
Claude Code can be configured for an LLM gateway when your organization needs one place for provider credentials, routing policy, spend limits, and request safety. nRouter exposes OpenAI-compatible and Anthropic Messages API surfaces; verify the wire format required by your Claude Code release before moving a production workload.
Before you start
- Create an nRouter virtual key with a small budget for testing.
- Confirm the model and API wire you intend to use in the live model catalog.
- Read Anthropic's current Claude Code gateway documentation for supported environment variables and provider requirements.
Configure the gateway
Use the endpoint and credential format supported by your installed Claude Code version. Keep the key in your shell environment or secret manager; never commit it.
export ANTHROPIC_API_KEY="sk-nrouter-your-virtual-key"
export ANTHROPIC_BASE_URL="https://api.nrouter.ai"The exact base URL and model mapping can change with Claude Code releases. Start with a non-production key, run a short prompt, verify the request appears in nRouter observability, and then test tool calls and streaming before rollout.
Production checklist
- Set a per-key budget before enabling autonomous workflows.
- Add a fallback model only after confirming the fallback supports the same wire and tool behavior.
- Review guardrail decisions and request-cost headers in the dashboard.
- Record the Claude Code version, model IDs, region, and routing policy in your runbook.
See budget controls, guardrails, and observability for the operational checks.