Claude Code
Claude Code is Anthropic's official command-line coding assistant. It calls Anthropic's Messages API directly, so you can use environment variables to redirect requests to the Sakrylle gateway and enjoy the discounted pricing.
Prerequisites
- Claude Code CLI installed (per the official documentation)
- An API Key created in the Sakrylle Console
Configuration
Claude Code uses the following environment variables to decide which API to hit:
| Variable | Meaning |
|---|---|
ANTHROPIC_BASE_URL | API gateway URL — the root domain, no /v1; the CLI appends /v1/messages itself |
ANTHROPIC_AUTH_TOKEN | Gateway authentication token; the CLI prepends Bearer and sends it as the Authorization header |
ANTHROPIC_MODEL | Default model name |
Quick verification
In your terminal:
export ANTHROPIC_BASE_URL="https://api.sakrylle.com"
export ANTHROPIC_AUTH_TOKEN="<your Sakrylle key>"
export ANTHROPIC_MODEL="claude-sonnet-4-6"
claudeOnce in the interactive UI, try a "hello". If the response looks normal, the configuration is correct.
Do not include
/v1inANTHROPIC_BASE_URL. Claude Code appends/v1/messagesinternally; doubling it leads to a 404.
Persistent configuration
Add the export lines above to your shell config:
- bash:
~/.bashrcor~/.bash_profile - zsh:
~/.zshrc - fish:
~/.config/fish/config.fish(use theset -gx ANTHROPIC_BASE_URL ...form)
Or put them into the env block of Claude Code's settings.json (this scopes them to Claude Code only):
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.sakrylle.com",
"ANTHROPIC_AUTH_TOKEN": "<your Sakrylle key>",
"ANTHROPIC_MODEL": "claude-sonnet-4-6"
}
}Settings file location:
- macOS / Linux:
~/.config/claude/settings.json - Windows:
%APPDATA%\Claude\settings.json
Use
ANTHROPIC_AUTH_TOKEN(which producesAuthorization: Bearer ...), notANTHROPIC_API_KEY— the latter switches to theX-Api-Keyheader and the CLI prefers it over Pro/Team subscriptions, which is inconsistent with this gateway's authentication.
FAQ
- 404 not found: most likely
ANTHROPIC_BASE_URLincludes/v1. Change it tohttps://api.sakrylle.com - 401 invalid auth: you used
ANTHROPIC_API_KEYbut Sakrylle expects Bearer. Switch toANTHROPIC_AUTH_TOKEN - MCP tool search disabled notice: when Claude Code detects that the base URL is not an Anthropic first-party domain, it disables
tool_searchby default. To enable it, addexport ENABLE_TOOL_SEARCH=true - 402 insufficient balance: top up in the Console
- Model not found: Sakrylle does not expose old models like
claude-opus-4-1; for the available model list see Models and Pricing
