ANTHROPIC_BASE_URL

Updated by

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.

StatusPresent in v2.1.332
Defaulthttps://api.anthropic.com
ValuesA full URL (scheme and host, optional path). Only host api.anthropic.com counts as first-party
CategoryNetwork and proxy
Official docsListed
Checked againstv2.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
claude

Https://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

Related variables

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.