Connect Claude Code
Get Claude Code running through Tetrate Agent Router in a few minutes. Prefer tare integrate to write the config from your logged-in session. 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: Prefer tare integrate (recommended)
The fastest path is Configure coding tools with the tare CLI. After tare api login, preview then apply:
tare integrate dataplanes
tare integrate claude-code --dry-run --dataplane <dataplane-id>
tare integrate claude-code --dataplane <dataplane-id> --yes
Use --passthrough when you want Claude Max (or Pro) billing with Agent Router attribution only:
tare integrate claude-code --dataplane <dataplane-id> --passthrough --yes
The CLI writes ~/.claude/settings.json (backing up any existing file), sets 0600 permissions, and validates the key against the gateway. --dataplane takes the DATAPLANE column id from tare integrate dataplanes, not the display name.
Connectors trade-off: while managed mode sets ANTHROPIC_API_KEY, Claude Code disables claude.ai connectors, because an explicit API key takes precedence over your claude.ai login. If you use connectors, choose --passthrough, or remove the env block from ~/.claude/settings.json when you need them.
If the CLI path does not fit your environment, use the manual configuration below.
Step 3: Manual configuration (fallback)
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.
While ANTHROPIC_API_KEY is set, Claude Code disables claude.ai connectors. Use passthrough mode (Option B) if you need connectors.
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 4: Start your session
Navigate to your project directory and launch Claude Code:
cd your-project
claude
Step 5: 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 (or the CLI-written settings) 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. |
| claude.ai connectors unavailable | Managed mode's ANTHROPIC_API_KEY disables connectors. Use --passthrough with tare integrate, or unset the API key / remove the env block from ~/.claude/settings.json. |
| 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