Claude Code
Route Claude Code traffic through AIControls to get full audit coverage and policy enforcement. Two modes are supported. Which one you use depends on how your workspace is configured — if only one mode is enabled it is applied automatically, and if both are enabled you choose your authentication method when you create an access token or during onboarding.
Prerequisites
- Claude Code installed —
npm install -g @anthropic-ai/claude-code - Your workspace proxy URL — find it in Settings → Integrations
- A personal access token — create one in Settings → Access Tokens
Proxy vs Passthrough
- Proxy mode
- Passthrough mode
AIControls holds your organization's Anthropic API key. You authenticate with your personal access token — no Anthropic credentials on your machine.
Step 1 — Remove existing Anthropic credentials
If you've previously authenticated with an Anthropic API key, clear it so Claude Code doesn't prefer saved credentials over the proxy:
claude auth logout 2>/dev/null || true
Step 2 — Configure ~/.claude/settings.json
Open or create ~/.claude/settings.json and add:
{
"env": {
"ANTHROPIC_BASE_URL": "https://YOUR_ORG.aicontrols.dev",
"ANTHROPIC_AUTH_TOKEN": "YOUR_ACCESS_TOKEN"
}
}
Replace YOUR_ORG with your workspace subdomain and YOUR_ACCESS_TOKEN with your personal access token.
Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. Claude Code treats these differently — ANTHROPIC_AUTH_TOKEN signals a virtual token and prevents Claude Code from validating the format against Anthropic's key schema.
Your virtual token is scoped to your identity. It cannot be used to extract the organization's API key — you authenticate to AIControls, which then forwards requests to Anthropic using the org credential.
You keep your own Anthropic credentials. AIControls adds a governance layer — all traffic is audited and policy-checked before reaching Anthropic, but billing stays on your account.
Required for Claude Team plan. Claude Team (and Max/Pro subscriptions) don't issue API keys — access is subscription-based. Because there's no API key to configure as an upstream in AIControls, passthrough is the only supported mode. Your subscription credentials are forwarded; AIControls provides governance on top.
Step 1 — Create a passthrough upstream
An administrator must first create an Anthropic upstream in Settings → Upstreams → Add upstream. For passthrough mode, leave the API Key field blank — AIControls uses the developer's own credentials rather than a stored key.
Step 2 — Configure ~/.claude/settings.json
Open or create ~/.claude/settings.json and add:
{
"env": {
"ANTHROPIC_BASE_URL": "https://YOUR_ORG.aicontrols.dev",
"ANTHROPIC_CUSTOM_HEADERS": "X-AIControls-Token: YOUR_ACCESS_TOKEN"
}
}
Replace YOUR_ORG with your workspace subdomain and YOUR_ACCESS_TOKEN with your personal access token. Keep your existing Anthropic credentials — they are still used for billing.
Do not remove or change ANTHROPIC_API_KEY. The X-AIControls-Token header is added alongside it — AIControls uses the header to identify you, then forwards your request to Anthropic with your key.
Claude for Work
If your team uses Claude for Work (the claude.ai web or desktop app on Enterprise or Team plans), an administrator can configure AIControls as the AI Gateway for your whole organization. When set up, all claude.ai traffic from your workspace routes through AIControls automatically — no per-developer configuration required.
Admin configuration
- In your claude.ai Enterprise admin settings, open Workspace settings → AI Gateway.
- Enable the third-party AI gateway option.
- Set the gateway URL to your workspace proxy endpoint:
https://YOUR_ORG.aicontrols.dev - Save. Traffic from all claude.ai users in your organization immediately routes through AIControls.
Claude for Work traffic appears in your Audit Log under Source: Claude for Work. Governance uses the organization token, not personal access tokens — attribution is by claude.ai user identity.
MCP tool governance
If you use Claude Code with MCP servers, AIControls intercepts every tool call — no additional configuration needed. MCP traffic flows through the same proxy endpoint as LLM requests.
To see which MCP tools are being called and what policies apply, go to Audit Log and filter by Type: Tool call.
Verify the connection
Start Claude Code and make any request — ask it to read a file or summarize a function. Then check your workspace Audit Log. Within a few seconds you should see the request with your identity and model details.
Troubleshooting
Requests not appearing in Audit Log
- Confirm
ANTHROPIC_BASE_URLis set in~/.claude/settings.json(no trailing slash) - Restart Claude Code after editing settings — env vars from settings.json take effect on startup
- Check that your access token is valid — try regenerating it in Settings → Access Tokens
Authentication errors (proxy mode)
- Ensure you're using
ANTHROPIC_AUTH_TOKEN, notANTHROPIC_API_KEY - Run
claude auth logoutto clear any cached Anthropic credentials that may take precedence - Confirm your workspace URL matches the one in Settings → Integrations
Authentication errors (passthrough mode)
- Check that
ANTHROPIC_CUSTOM_HEADERSis set to exactlyX-AIControls-Token: YOUR_ACCESS_TOKEN(no extra spaces) - Confirm your personal access token hasn't expired — regenerate it in Settings → Access Tokens if needed
Requests denied by policy
If a request is blocked, Claude Code shows an error. Check Audit Log → Denied for the policy that triggered and the denial reason. Contact your administrator to adjust the policy or get an exemption.