Claude Code
Route Claude Code (CLI and VS Code extension) through Exemplar by setting ANTHROPIC_BASE_URL to the Anthropic passthrough. There is no /gateway/claude or /gateway/claude-code route—Claude clients speak Anthropic Messages, so they use the same passthrough as the Anthropic SDK.
| Setting | Value |
|---|---|
ANTHROPIC_BASE_URL | https://production-api.exemplar.dev/gateway/anthropic |
| Auth | Org platform key eis_… via ANTHROPIC_AUTH_TOKEN (or ANTHROPIC_API_KEY) |
| Provider | Enable anthropic under AI Gateway → Management → Providers + Vault/Connectors credentials |
Create the key under Tokens and API keys.
Claude Code is Anthropic passthrough, not Unified /gateway/v1 and not the Cursor adapter. Comparison: Choose your surface.
Do not point Claude Code at /gateway/v1 or /gateway/cursor. Those are OpenAI-compatible surfaces. Claude Code needs the Anthropic Messages API shape on /gateway/anthropic.
How the path works
- You set the base to
…/gateway/anthropic(no trailing/v1). - Claude Code / the Anthropic client appends
/v1/messages(and related paths). - The gateway serves passthrough under
/gateway/anthropic/v1/*, authenticates the org fromeis_*, resolves upstream Anthropic credentials from Vault (or BYOK), and proxies the native request.
Claude Code
→ POST {ANTHROPIC_BASE_URL}/v1/messages
→ https://…/gateway/anthropic/v1/messages
→ Exemplar Anthropic passthrough → api.anthropic.com (or vaulted upstream)Model path vs action path: Gateway owns LLM requests. For bash, filesystem, MCP, and prompt decisions, install Relay → Connect (or /exemplar-relay via exemplar-skills). You can use either or both.
Setup
Enable Anthropic on the org
AI Gateway → Management → Providers — enable anthropic and attach Connectors/Vault credentials (or plan to send X-Upstream-Authorization for one-off BYOK).
Create an org eis_* key
Tokens and API keys. Use this as ANTHROPIC_AUTH_TOKEN—not an Anthropic sk-ant-… key (unless you intentionally BYOK upstream separately).
Configure Claude Code
Global: ~/.claude/settings.json · Project: .claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://production-api.exemplar.dev/gateway/anthropic",
"ANTHROPIC_AUTH_TOKEN": "eis_…",
"ANTHROPIC_MODEL": "claude-sonnet-4-6",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-6",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}Or in the shell before claude:
export ANTHROPIC_BASE_URL=https://production-api.exemplar.dev/gateway/anthropic
export ANTHROPIC_AUTH_TOKEN=eis_…
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6
claudeSmoke-test the passthrough
curl -sS https://production-api.exemplar.dev/gateway/anthropic/v1/messages \
-H "Authorization: Bearer $EXEMPLAR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 64,
"messages": [{"role": "user", "content": "ping"}]
}'A JSON Messages response means auth, allowlist, and upstream credentials are working before you debug the IDE.
Model aliases
Claude Code’s /model opus, /model sonnet, and /model haiku shortcuts read ANTHROPIC_DEFAULT_*_MODEL. Values must contain a recognizable Anthropic model id (for example claude-sonnet-4-6) so capability detection (thinking, tools) still works.
| Variable | Maps |
|---|---|
ANTHROPIC_DEFAULT_OPUS_MODEL | opus |
ANTHROPIC_DEFAULT_SONNET_MODEL | sonnet |
ANTHROPIC_DEFAULT_HAIKU_MODEL | haiku |
ANTHROPIC_MODEL | Default model for the session |
Use bare Anthropic ids on the passthrough (claude-sonnet-4-6). Do not use anthropic/claude-sonnet-4-6 here—that provider/model form is for the unified OpenAI-compatible API (/gateway/v1).
Prefer CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 until you have verified beta headers against your allowlisted models. Experimental betas can attach parameters the upstream model rejects (400).
Auth notes
- Platform tenant auth expects an
eis_*key (Authorization: Bearer eis_…orX-API-Key/x-api-key). - Claude Code’s
ANTHROPIC_AUTH_TOKENshould be that org key. - Upstream Anthropic credentials normally come from Connectors / Vault after you enable the provider. One-off BYOK:
X-Upstream-Authorization: Bearer sk-ant-…on the request (advanced; not required for normal Claude Code setup). - Passthrough does not use Console failover routes (model-prefix resolve only). Rate limits still apply when a policy is effective — see Rate limits.
VS Code extension
The Claude Code VS Code extension uses the same CLI configuration. Install and configure the CLI first, then launch VS Code from a terminal that inherits those env vars (code .). GUI launches on macOS/Linux often miss shell env.
Claude Agent SDK
The Agent SDK speaks Anthropic Messages on the same passthrough. See Frameworks → Claude Agent SDK. Load project settings with setting_sources=["project"] if you keep gateway env in .claude/settings.json.
What belongs on Relay
| Need | Surface |
|---|---|
| Route Claude model calls through Exemplar | This page (ANTHROPIC_BASE_URL → /gateway/anthropic) |
| Allow / ask / deny shell, paths, MCP, prompts | Relay Connect |
| Org MCP tools for Claude | Tools & MCP → Connect |
Common mistakes
| Mistake | Fix |
|---|---|
Base URL set to /gateway/v1 or /gateway/cursor | Use /gateway/anthropic |
Base URL ends with /v1 (…/anthropic/v1) | Drop /v1—the client adds it |
Model id anthropic/claude-… in Claude Code | Use bare claude-… on passthrough |
Anthropic sk-ant-… as the only key, no eis_* | Platform auth needs eis_*; put upstream key in Vault |
| Expecting shell/MCP deny from the gateway | Install Relay hooks |
Related
- Choose your surface — when Claude vs Unified vs Cursor
- Provider passthrough — Anthropic Messages base, Cursor adapter, OpenAI passthrough
- Cursor IDE — Cursor’s OpenAI override via
/gateway/cursor(different adapter) - Frameworks — Claude Agent SDK snippets
- Relay Connect — IDE hooks for tool governance
- Getting started —
eis_*auth and Management setup