INTEGRATION GUIDE

Claude Code

Standalone agents

Connect the Claude Code CLI and editor extension to a standalone ZRouter gateway.

On this page

Manage your account with MCP

To inspect usage or manage ZRouter routers, keys, and enabled limits from your assistant, connect the account MCP server. This manages your ZRouter account without changing the assistant's model provider. The instructions below cover routing model requests instead.

Compatibility first

Standalone gateway only for coding agent workflows. Prepaid ZRouter accounts reject tool definitions and tool results. BYOK uses the same restrictions. Claude Code therefore cannot currently run a full coding session with a paid account key.

Use a separate standalone deployment with a dedicated managed gateway key and a configured Anthropic provider. Anthropic supports Claude Code through gateways using Claude models, not arbitrary non-Claude models. Gateway requests use provider API billing, not your Claude subscription. See Anthropic's gateway overview.

Configure the CLI

Install Claude Code using its official installation instructions. Set these variables in the terminal where you will launch it. Replace every placeholder. The base URL is the gateway root, including any deployment path prefix, without /v1.

export ANTHROPIC_BASE_URL="https://STANDALONE_GATEWAY_HOST"
export ANTHROPIC_AUTH_TOKEN="YOUR_MANAGED_GATEWAY_KEY"
claude --model "ANTHROPIC_INSTANCE/CLAUDE_MODEL_ID"

Choose a tool-capable Claude model from the gateway's /v1/models response. If helper models are needed, the operator should configure aliases for the Claude model names that the client requests. Never paste the operator master key into an integration.

ANTHROPIC_AUTH_TOKEN supplies bearer authentication. ZRouter also accepts ANTHROPIC_API_KEY through x-api-key; avoid setting both with different credentials. See Anthropic's connection instructions.

Editor extension

The Claude Code extension in VS Code or Cursor can use user-level editor settings:

{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://STANDALONE_GATEWAY_HOST" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "YOUR_MANAGED_GATEWAY_KEY" }
  ]
}

Keep credentials out of repository settings. Restart the extension, then select the configured Claude model. An editor launched from the desktop may not inherit terminal environment variables. Claude Desktop and cloud sessions have separate configuration; these CLI settings do not configure them.

Check the connection

curl "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"ANTHROPIC_INSTANCE/CLAUDE_MODEL_ID","max_tokens":256,"messages":[{"role":"user","content":"Say hello"}]}'

This is a billable text check, not a full agent verification. Once it succeeds, start a small coding task and inspect the gateway logs for model, streaming, and tool errors.

Troubleshooting

  • A /v1/v1/messages error means the base URL includes /v1 twice.
  • A model error requires an enabled Claude model or correctly configured alias, including any helper models.
  • A prepaid tools is not supported error cannot be fixed with another header or more credit.
  • Token counting at /v1/messages/count_tokens is blocked for prepaid accounts. Claude Code can estimate counts when the endpoint is unavailable, but tool restrictions still prevent agent use. See Anthropic's protocol requirements.

Use the shared troubleshooting guide for authentication and networking checks.

Vendor configuration reviewed September 30, 2026. Model and client capabilities vary. Check the linked official sources when upgrading.