The Anthropic base URL for a gateway: one value, no /v1
If you are pointing Claude Code, the Anthropic SDK, or an agent harness at an Anthropic-compatible gateway, the anthropic base url question has a one-line answer: set ANTHROPIC_BASE_URL to https://llm.modellix.ai — without /v1. The gateway’s Messages endpoint is POST /v1/messages, and Anthropic-protocol clients append that path themselves. OpenAI-compatible clients are the ones that need the full https://llm.modellix.ai/v1. Mixing the two is the single most common configuration error in this setup, and this article gives you the exact values for both places the same variable appears: Claude Code and a DeepSeek Harness custom provider.
Scope, stated up front: this article covers the Anthropic protocol side — what value to put where. Its OpenAI-protocol counterpart, covered in the OpenAI-compatible API guide, owns the /v1-bearing Chat Completions and Responses endpoints. The harness’s main configuration path (the openai-completions route) is the DeepSeek Harness custom model guide; this page is the anthropic-messages variant of that same file, and that guide is linked in the harness section below. Whether to switch clients at all is a separate decision we do not relitigate here. Modellix operates the gateway used throughout, so we have a commercial interest in this configuration working; every value below was verified against docs.modellix.ai, code.claude.com, and the live Modellix LLM price page on September 2, 2026.
What the value is: https://llm.modellix.ai, and who appends /v1
The default Anthropic base URL — the one you get for free by doing nothing — is https://api.anthropic.com, the REST API documented in the Claude API overview. You only set ANTHROPIC_BASE_URL when you want requests to go somewhere else: a proxy, a gateway, or another provider’s Anthropic-compatible endpoint. When that “somewhere” is the Modellix LLM gateway, the value is:
| Setting | Value |
|---|---|
ANTHROPIC_BASE_URL |
https://llm.modellix.ai — no /v1 |
| Endpoint it reaches | POST /v1/messages (appended by the client) |
| OpenAI-compatible clients | https://llm.modellix.ai/v1 |
The Modellix Claude Code setup guide states the rule and the reason in one line, and it is worth quoting in full:
Do not append
/v1toANTHROPIC_BASE_URL. Claude Code / the Anthropic SDK append/v1/messagesthemselves.
That last clause is the mechanism. The gateway serves the Anthropic Messages protocol at /v1/messages, and the base URL you configure is the host — the client is responsible for the path. A raw check that exercises exactly this, from the API guide’s Messages reference:
1 | curl -sS "https://llm.modellix.ai/v1/messages" \ |
Note that the curl URL does carry /v1/messages — because curl is a raw client that appends nothing. The rule is about configured clients that append for you: Claude Code, the official Anthropic SDKs, and the harness. When a tool asks you for a base URL rather than a full endpoint, it is telling you it will do the appending — so you give it the host, no path.
Where the /v1 mistake comes from
Two conventions collide here, and both look right until they fail. OpenAI-compatible clients (the OpenAI SDK, Cursor, most chat UIs) expect https://llm.modellix.ai/v1 and send POST /v1/chat/completions. Anthropic-protocol clients expect the bare host and append /v1/messages. If you take the OpenAI habit — or a value you copied from an OpenAI-compatible setup — and point an Anthropic client at https://llm.modellix.ai/v1, the client produces a doubled path, https://llm.modellix.ai/v1/v1/messages, and the request dies with a 404 that looks like a gateway outage.
The confusion is not yours alone; the two main Anthropic SDK families genuinely disagree about this variable. The official @anthropic-ai/sdk defaults to the bare https://api.anthropic.com and builds ${baseURL}/v1/messages internally, while Vercel’s @ai-sdk/anthropic defaults to https://api.anthropic.com/v1 and appends the raw /messages — a documented incompatibility tracked in vercel/ai issue #15542. Claude Code follows the official convention and injects the bare-host form into its child processes, which is why the Modellix documentation and this article both use the no-/v1 value: it is the form the official SDK and Claude Code expect. Python users get the same behavior for free — the official Python SDK appends /v1/messages itself, so client = Anthropic(base_url="https://llm.modellix.ai") is the whole anthropic base url python change.
Who appends what: Anthropic-protocol clients take the bare host and reach /v1/messages; OpenAI-compatible clients take the /v1 form. The doubled-path 404 happens when the two are crossed.
Claude Code: two variables, one value, and where it persists
Configure Claude Code the same way you would with any Anthropic-compatible gateway, per the Modellix Claude Code setup docs. First create a key in the Modellix console — the docs are explicit that it must be a Modellix key, “not a vendor platform key,” because a key from Anthropic’s own console authenticates Anthropic’s billing, not the gateway’s. Then:
1 | export ANTHROPIC_API_KEY="mdlx-xxxxxxxx" |
Claude Code maps ANTHROPIC_API_KEY to the Anthropic-style x-api-key header. For tools that expect Bearer auth instead, the docs prescribe the second variable:
If the tool expects Bearer auth, use
ANTHROPIC_AUTH_TOKENinstead ofANTHROPIC_API_KEY. Do not set both to different values.
Sending both headers with different values is not a “first one wins” situation — the gateway returns 401. The API guide states it as an invariant: “Both headers are equivalent. If both are sent, they must be the same key.” If your Claude Code session uses ANTHROPIC_AUTH_TOKEN (some gateway setups do), keep ANTHROPIC_API_KEY unset rather than holding a stale value.
Environment variables work for the shell that launched Claude Code. To make the config stick across restarts, write the same two values into ~/.claude/settings.json, in the env block that Claude Code merges into every session:
1 | { |
Replace mdlx-xxxxxxxx with your real key. Two details from the docs are worth carrying forward. First, the model must be a full Modellix catalog ID — anthropic/claude-sonnet-5, not a bare console name; the Claude Agent SDK docs warn that bare names “are not Modellix catalog IDs,” and the gateway routes on the provider/name form. Second, Claude Code’s own environment variables reference defines ANTHROPIC_BASE_URL as the override “to route requests through a proxy or gateway,” and notes that pointing it at a non-first-party host disables MCP tool search by default — a behavior difference worth knowing before you move a heavy tool-using setup. The Claude Agent SDK takes the same two variables, and the Modellix Claude Agent SDK docs are explicit that this SDK targets Anthropic-compatible endpoints only: do not set OPENAI_BASE_URL or https://llm.modellix.ai/v1 for it.
One more Claude Code nuance, from the official LLM gateway docs: setting ANTHROPIC_BASE_URL alone does not replace your subscription login — requests route through the gateway, but a saved claude.ai login remains the active credential until a gateway credential variable (ANTHROPIC_API_KEY or an apiKeyHelper) is present. If you intend per-token gateway billing, set the key; do not rely on the URL alone.
The same variable in a DeepSeek Harness: api: anthropic-messages
The same value appears a second time in agent harness configuration, and the same no-/v1 rule applies. DeepSeek Harness lets you declare an Anthropic-protocol route against the gateway; the Modellix DeepSeek Harness docs describe the variant in one sentence:
If you prefer the Anthropic wire protocol, set
api: anthropic-messagesandbaseURL: https://llm.modellix.ai(no/v1)—but model discovery (Fetch available models) only reads OpenAI-compatibleGET /modelsendpoints, so enter models by hand in that case.
In $DSH_HOME/settings.yaml, that variant looks like this — note both differences from the main path at once:
1 | llm-pi-ai: |
The api: anthropic-messages field selects the Anthropic wire protocol instead of openai-completions, and baseURL drops the /v1 that the OpenAI route uses. Two consequences follow, and both are traps if missed:
- Leave
/v1inbaseURLand requests double the path. The harness appends/v1/messagesto whatever base URL you give it, sohttps://llm.modellix.ai/v1becomeshttps://llm.modellix.ai/v1/v1/messages— the same 404 you would see in Claude Code. The value ishttps://llm.modellix.ai, full stop. - Model discovery stops working, so the list is yours to fill. “Fetch available models” reads OpenAI-compatible
GET /modelsendpoints only. On theanthropic-messagesroute there is nothing to fetch, and the harness’s troubleshooting table says exactly that: enter models manually. Yourmodels:entries are the route’s whole catalog — an empty list on this protocol means no models at all, and a fullprovider/nameID likeanthropic/claude-sonnet-5is required in each entry.
Everything else about the route — apiKeyEnv resolving the credential, the key being a Modellix console key rather than an Anthropic platform key, the models list replacing rather than extending the catalog — matches the main path documented in the DeepSeek Harness custom model guide. If your client is OpenAI-protocol instead, the endpoint rules for that side live in the OpenAI-compatible API guide linked in the opening section.
Claude Code and Harness Base URL Docs
Point Claude Code, the Claude Agent SDK, or a DeepSeek Harness at the Modellix LLM gateway with the exact ANTHROPIC_BASE_URL value and the anthropic-messages provider block.
View DocsWhat pointing here costs: three Claude models at 3% off the listed price
Pricing matters at this decision point, so here is the dated figure rather than a vague “competitive.” On the Modellix LLM price page, fetched September 2, 2026, the three Anthropic models each carry a discount label rendered verbatim as 3% OFF next to their per-million-token rates:
| Model | Input | Output | Discount label (page verbatim) |
|---|---|---|---|
anthropic/claude-opus-5 |
3% OFF |
||
anthropic/claude-sonnet-5 |
3% OFF |
||
anthropic/claude-haiku-4.5 |
3% OFF |
The struck-through figure is the official list price as shown on the page, and the Modellix rate is what you pay — 3% lower than that listed price, not a claim about being the cheapest option anywhere. Rates are in USD per 1 million tokens, all three models are flat-rate, and prices move, so treat the table as a snapshot and the live page as the source of truth. Two boundaries belong next to the numbers: the LLM gateway is a text gateway — output is text, and image generation stays on the separate media API — and Modellix publishes no RPM guarantees, so plan rate limits from your own usage rather than a promise.
Create Your Modellix API Key
Log in to the Modellix console to generate your API key and check today's live Claude per-million-token rates before you switch your base URL.
LoginWhere this fits in the series
The value in this article is deliberately narrow, and the surrounding decisions have their own pages. If you are weighing whether to leave Claude Code for another client at all, the Claude Code alternatives article compares staying versus switching. If you are configuring a harness and want the OpenAI-protocol main path rather than the Anthropic variant, the DeepSeek Harness custom model guide linked above has the full five-field form and settings.yaml walkthrough. A dedicated per-model pricing breakdown for Claude is planned as a follow-up article; until it publishes, the live price page linked above is the reference. The series hub — the DeepSeek Harness article — ties the whole cluster together: key ownership, model sources, plugins, and error recovery.
Your next three steps: create a key in the Modellix console, set ANTHROPIC_BASE_URL=https://llm.modellix.ai in exactly one of the two places above (Claude Code’s env block or the harness provider), and confirm a POST /v1/messages call succeeds. When you later add OpenAI-protocol models alongside, the /v1-bearing base URL from the sibling guide coexists on the same gateway — just never in the same ANTHROPIC_BASE_URL.
Frequently Asked Questions
What is the default Anthropic base URL?
The default is https://api.anthropic.com, and the Claude API serves POST /v1/messages at that host. You set ANTHROPIC_BASE_URL only to override it — for a proxy, a gateway, or another Anthropic-compatible endpoint. When the endpoint is the Modellix LLM gateway, the override is https://llm.modellix.ai.
Does ANTHROPIC_BASE_URL need /v1 at the end?
No — for Anthropic-protocol clients, appending /v1 is the most common mistake and produces a doubled path (/v1/v1/messages) that fails with a 404. Claude Code, the official Anthropic SDK, and the harness’s anthropic-messages provider append /v1/messages themselves. OpenAI-compatible clients are the ones that need https://llm.modellix.ai/v1.
What is the difference between ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN?
They are two ways to send the same credential: ANTHROPIC_API_KEY is sent as the x-api-key header (what Claude Code uses), and ANTHROPIC_AUTH_TOKEN is sent as a Bearer token for tools that expect that form. The gateway treats both headers as equivalent — but if both are sent with different values, the request fails with 401. Set one, and never the two to different values.
Why does my harness show no models after I set api: anthropic-messages?
Model discovery reads OpenAI-compatible GET /models endpoints only, and an Anthropic-protocol route has none. “Fetch available models” cannot auto-list anything, so enter model IDs by hand in the models: list — full anthropic/claude-sonnet-5-style IDs, which are the route’s entire catalog.
Is there a free Modellix API key for Claude models?
There is no automatic free tier today. Modellix is pay-as-you-go, and the $1 signup credit that new accounts previously received was removed on August 19, 2026; trial credit requires an email request to the team. A free Anthropic console account does not grant gateway access either — the gateway authenticates a Modellix key.
Is Modellix affiliated with Anthropic?
No. Modellix is a distribution and access layer that resells access to models from multiple vendors; it does not speak for Anthropic, and nothing here implies an official partnership. Anthropic’s own gateway documentation is blunt on this point: it does not “endorse, maintain, or audit third-party gateway products.” ANTHROPIC_BASE_URL is simply the supported mechanism for pointing Anthropic-protocol clients at whatever endpoint you choose.
Base URL conventions, auth rules, model IDs, and prices reflect Modellix public documentation and the live Modellix LLM price page as of September 2, 2026, and change as both the gateway and upstream providers evolve; validate against the live price page before committing. Modellix operates the gateway described here and has a commercial interest in it. The Modellix LLM gateway is a text gateway — image and video generation run on the separate media API, all reachable through a single API key at modellix.ai.