Home → Guides → Anthropic base URL for Claude Code: setting ANTHROPIC_BASE_URL correctly

Anthropic base URL for Claude Code: setting ANTHROPIC_BASE_URL correctly

Claude Code talks to whatever address ANTHROPIC_BASE_URL points at. The one rule that trips people up: it wants the bare host, with no /v1 — the opposite of almost every OpenAI-style tool.

The short answer

Set two environment variables before starting Claude Code:

ANTHROPIC_BASE_URL=https://apiclan.us
ANTHROPIC_AUTH_TOKEN=sk-your-key

The official Anthropic address is https://api.anthropic.com; replacing it is all a relay needs. Claude Code appends /v1/messages itself, so the base URL must stop at the host. On this gateway 88% of all Claude traffic in the last 30 days came from Claude Code configured exactly this way.

Where to set it

macOS / Linux — in the shell you launch it from:

export ANTHROPIC_BASE_URL=https://apiclan.us
export ANTHROPIC_AUTH_TOKEN=sk-your-key
claude

Windows PowerShell — for the current window:

$env:ANTHROPIC_BASE_URL = "https://apiclan.us"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-key"
claude

~/.claude/settings.json — so every session picks it up without touching the shell:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://apiclan.us",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-key"
  }
}

The value is read when Claude Code starts. If you change it, quit and start a new session; an open one keeps the old address. ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer; ANTHROPIC_API_KEY is sent as x-api-key. This gateway accepts either, so use one, not both.

Test it in one command

Before blaming Claude Code, check the address and key directly:

curl https://apiclan.us/v1/messages \
  -H "Authorization: Bearer sk-your-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-5","max_tokens":20,"messages":[{"role":"user","content":"hi"}]}'

A JSON reply means both are right. text/html or a 404 means the URL is wrong; a 401 in JSON means the URL is right and the key is not.

When to add /v1 and when not to

Two SDK families split the URL at different points. Anthropic-style clients add /v1/messages themselves; OpenAI-style clients expect /v1 in the base URL and add only /chat/completions:

ClientBase URL
Claude Code, Anthropic SDKhttps://apiclan.us
Codex, OpenAI SDKhttps://apiclan.us/v1
Cursor, Cline, Roo Codehttps://apiclan.us/v1
Cherry Studio, Chatbox, LobeChat, LM Studiohttps://apiclan.us/v1

Put /v1 in Claude Code and requests go to /v1/v1/messages, which returns a 404. Leave it out of Cursor and they go to /chat/completions — also a 404. Neither reaches the API.

URL mistake or key mistake?

Choosing the model

Model names are exact strings with hyphens, never dots — claude-fable-5-1, not claude-fable-5.1. Pick one at launch, or with /model inside a session:

claude --model claude-opus-5-5

The current names and prices are on the price list. Setup for other clients is in the quickstart, and the Claude Desktop app is covered in the desktop apps guide.

Start using it

No subscription, no monthly minimum, no sales call. Top up with USDT and spend what you use — 1 USDT gives you 2 credits of API balance.

Read the 30-second quickstart

Language: English · 简体中文 · 繁體中文 · 日本語 · 한국어 · Deutsch · Français · Español · Türkçe · Português · Italiano · Bahasa Indonesia · Tiếng Việt · Bahasa Melayu · Polski · Čeština · فارسی · Русский

Prices on this page are filled in automatically from live billing data. Third-party terms are quoted from that party's own documentation.