ANTHROPIC_BASE_URL
Updated by Alex Sorokoletov
ANTHROPIC_BASE_URL sends Claude Code's API requests to a different endpoint, such as an LLM gateway or proxy, instead of https://api.anthropic.com. Default: https://api.anthropic.com. Values: A full URL (scheme and host, optional path). Only host api.anthropic.com counts as first-party. Its release history is not tracked here. It is listed in the official reference.
| Status | Present in v2.1.332 |
|---|---|
| Default | https://api.anthropic.com |
| Values | A full URL (scheme and host, optional path). Only host api.anthropic.com counts as first-party |
| Category | Network and proxy |
| Official docs | Listed |
| Checked against | v2.1.330 |
How to set it
For one session, export it in the shell that starts Claude Code:
export ANTHROPIC_BASE_URL=https://llm-gateway.internal.example.com
claudeHttps://llm-gateway.internal.example.com route all traffic through a company LiteLLM or audit proxy.
To apply it to every session, add it to the env object of a settings file:
// ~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://llm-gateway.internal.example.com"
}
}Known issues
- Since v2.1.196, Remote Control is disabled when the URL's host is anything other than api.anthropic.com. Source: docs: env vars.
- If the gateway exposes a model ID Claude Code does not recognize, Claude Code assumes a context window for it and warns; set the window yourself so compaction runs at the right size. Source: docs: model config.
- Sessions started from the desktop app's Code tab ignore ANTHROPIC_BASE_URL in ~/.claude/settings.json and still call api.anthropic.com; the terminal CLI and VS Code extension honor it. Source: issue #97574.
Release notes that mention it
- /plugin enable cc-plugin-you-should-know@builtin: What Claude Code's You Should Know Mod Does
- How Much Does Claude Code Cost? Plans, API, OpenRouter and Bedrock Prices
- Claude Code Code Mode: How to Turn It On, What It Changes, and Why It Won't Start
- What Is ip_reminder in Claude Code? The Hidden Copyright Reminder, Explained
- Claude Code apiKeyHelper Not Re-run on 401 with Vertex: "Google Cloud credentials expired or invalid"
- Claude Code --client-data-url: Signed Model Configuration and --allow-other-models
- Claude Code v2.1.126 — `project purge`, Gateway Model Picker, and What's Actually New
- CLAUDE_CODE_ATTRIBUTION_HEADER: Fix Bedrock 400 Errors & Prompt Caching Issues
Related variables
CLAUDE_CODE_API_BASE_URL: Custom Claude Code API base URL for proxies.CLAUDE_CODE_ARTIFACT_VIEWER_BASE_URL: Sets the base URL for the artifact viewer.CLAUDE_CODE_GB_BASE_URL: An internal base URL override, possibly for a "gradebook" or grading service used during internal testing.CLAUDE_CODE_MEMORY_API_BASE_URL: Base URL for the memory API instead of the default.CLAUDE_RUNNER_API_BASE_URL: Provides the API base URL for code-signing when ANTHROPIC_BASE_URL and SESSION_INGRESS_URL are unset; trailing slashes are stripped.CLAUDE_BRIDGE_BASE_URLCLAUDE_CODE_ARTIFACT_ASSET_BASE_URLCLAUDE_CODE_ARTIFACT_LIVE_BASE_URL
Frequently asked questions
What does ANTHROPIC_BASE_URL do?
Sends Claude Code's API requests to a different endpoint, such as an LLM gateway or proxy, instead of https://api.anthropic.com.
What is the default value of ANTHROPIC_BASE_URL?
Https://api.anthropic.com.
What values does ANTHROPIC_BASE_URL accept?
A full URL (scheme and host, optional path). Only host api.anthropic.com counts as first-party.
Which Claude Code version has ANTHROPIC_BASE_URL?
Its release history is not tracked here.
How do I set ANTHROPIC_BASE_URL?
Export it before starting Claude Code (export ANTHROPIC_BASE_URL=https://llm-gateway.internal.example.com), or add it to the "env" object in ~/.claude/settings.json to apply it to every session. Https://llm-gateway.internal.example.com route all traffic through a company LiteLLM or audit proxy.
All variables, searchable: Claude Code environment variables.