Connect Claude Code
Get Claude Code running through Tetrate Agent Router in a few minutes. Choose managed mode if Agent Router should bill Anthropic traffic, or passthrough mode if you already have a Claude Max (or Pro) subscription and want Anthropic to bill you directly while the gateway routes and observes.
Step 1: Install Claude Code
Install Claude Code with Anthropic's native installer (the recommended method — auto-updates in the background and does not require Node.js).
macOS, Linux, WSL:
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Other supported methods (Homebrew, WinGet, apt/dnf/apk, npm) are documented in the Claude Code setup guide.
Step 2: Choose an auth mode
Agent Router supports two auth modes for Claude Code. Pick the one that matches how you want to pay for traffic.
Option A — Managed mode (Agent Router-managed Anthropic key)
Use this if you don't have a Claude Max subscription, or you want all traffic billed through Agent Router using its managed Anthropic credentials.
How it works:
- Agent Router authenticates the request with its managed Anthropic key.
- Cost = base + Agent Router margin.
- Your Agent Router API key goes in
ANTHROPIC_API_KEY.
Add to your shell profile (for example ~/.zshrc or ~/.bashrc):
# Use the proxy host (not a full /v1/messages URL) — Anthropic clients append /v1/messages automatically
export ANTHROPIC_BASE_URL="https://proxy.internal.tetrate.ai"
export ANTHROPIC_API_KEY="your-tars-api-key"
Replace the base URL with your gateway proxy host from the Console Dashboard if it differs.
Option B — Passthrough mode (your own Claude Max subscription)
Use this if you already have a Claude Max (or Pro) subscription and want Claude Code to bill against it. Agent Router routes the request and observes it, but your Anthropic OAuth token passes through untouched — Anthropic authenticates you the same as a direct connection.
How it works:
- Do not set
ANTHROPIC_API_KEY— Claude Code's stored OAuth token is what authenticates with Anthropic. x-tars-api-keyauthenticates you with Agent Router for routing and observability.- Cost = your Claude Max plan, with no Agent Router margin on tokens. Passthrough requests are labeled
passthroughin the Request Logs.
First, log in to your Anthropic account once via Claude Code's normal flow so it stores the OAuth token locally:
claude /login
Then add to your shell profile:
export ANTHROPIC_BASE_URL="https://proxy.internal.tetrate.ai"
export ANTHROPIC_CUSTOM_HEADERS="x-tars-api-key: your-tars-api-key"
Replace the base URL with your gateway proxy host from the Console Dashboard if it differs.
Step 3: Start your session
Navigate to your project directory and launch Claude Code:
cd your-project
claude
Step 4: Verify
Run the /status command inside your Claude Code session and confirm the base URL points to the gateway:
> /status
Anthropic base URL: https://proxy.internal.tetrate.ai
You can also check the Request Logs to see your requests.
Troubleshooting
| Issue | What to check |
|---|---|
| API key issues | In managed mode, ensure ANTHROPIC_API_KEY is set to your Agent Router API key. In passthrough mode, ensure ANTHROPIC_API_KEY is unset and ANTHROPIC_CUSTOM_HEADERS carries x-tars-api-key. |
| Connection errors | Verify that ANTHROPIC_BASE_URL points to the correct gateway URL (no trailing /v1/messages — Claude Code appends that automatically). |
| Passthrough returns 401 from Anthropic | Your Claude Max OAuth token is missing or expired. Re-run claude /login and try again. |
| Permission denied | Claude Code needs read/write access to your project files. |
| Context limits | For very large repos, use .claudeignore to exclude irrelevant directories. |
Where to go next