Claude API Base URL: How to Set the Custom Endpoint in Every Client
Almost every AI client — a CLI, an editor, a desktop chat app, an orchestration framework — lets you point it at a custom base URL instead of the default vendor endpoint. Set that one field correctly and the exact same tool sends its requests to ApiTopMix instead. Get it slightly wrong — a stray /v1, a trailing slash, http instead of https — and you stare at a 404 or a 401 with no obvious cause. This page is the reference that removes the guesswork: for each popular client it tells you which base URL to use, where to paste it, and where the API key goes.
A base URL (sometimes called the API endpoint, host, or server address) is simply the root address your client prepends to every API path. When a client ships, that root points at the model vendor. Overriding it — the custom base URL — is the supported hook that lets a gateway like ApiTopMix stand in front of the models. You change the address, not the app: prompts, projects and workflows are untouched, and the override is reversible at any time.
The two ApiTopMix base URLs
ApiTopMix publishes two base URLs, and picking the right one is the whole game. The distinction is which protocol your client speaks:
- OpenAI-compatible base URL —
https://apitopmix.com/v1. Use this for anything built on the OpenAI SDK or anything whose settings ask for an "OpenAI Base URL", "API Base", or "OpenAI compatible endpoint". It serves paths like/v1/chat/completionsand/v1/models. This is the OpenAI base URL override most clients want. - Anthropic-native base URL —
https://apitopmix.com. Use this asANTHROPIC_BASE_URLfor Claude Code and other Anthropic-SDK clients. It speaks the real Anthropic protocol and serves/v1/messages, so tool use, streaming and long context behave exactly as the Anthropic client expects.
Both accept the same ApiTopMix sk- key. The rule of thumb: if the client mentions "OpenAI" anywhere in its API settings, use the /v1 base; if the client is Claude-native and talks about ANTHROPIC_BASE_URL, use the bare host.
/v1 and append the rest of the path (/chat/completions) themselves. Others expect a bare host and add /v1/... for you. If you see /v1/v1/chat/completions in an error, you doubled it — remove the /v1 you typed. If you get a 404 on a plain host, the client did not add /v1 — put it back. When in doubt, the OpenAI-SDK convention is base URL with /v1; the Anthropic convention is base URL without it.
The base URL reference table (per client)
This is the core of the page. Find your client, use the base URL in column two, paste it where column three says, and put the ApiTopMix key where column four says. The OA tag means the OpenAI-compatible base https://apitopmix.com/v1; the AN tag means the Anthropic-native base https://apitopmix.com.
| Client | Base URL to use | Where you paste it | Where the API key goes | How & gotcha |
|---|---|---|---|---|
| OpenAI Python SDK | OA https://apitopmix.com/v1 |
base_url= in OpenAI(...) |
api_key= argument |
Set base_url once at client init. Include /v1; the SDK adds /chat/completions. |
| OpenAI Node SDK | OA https://apitopmix.com/v1 |
baseURL: in new OpenAI({...}) |
apiKey: field |
Same as Python. baseURL must end in /v1; do not append /chat/completions yourself. |
| Claude Code | AN https://apitopmix.com |
ANTHROPIC_BASE_URL env var |
ANTHROPIC_AUTH_TOKEN env var |
No /v1 here — Claude Code adds /v1/messages itself. Export both vars, then run claude. |
| Cursor | OA https://apitopmix.com/v1 |
Settings → Models → Override OpenAI Base URL | OpenAI API Key field | Enable the OpenAI key section, keep the /v1 suffix, and add a custom model name. |
| Cline (VS Code) | OA https://apitopmix.com/v1 |
API Provider → "OpenAI Compatible" → Base URL | API Key field in the same panel | Pick the OpenAI Compatible provider (not "OpenAI"). Base URL keeps /v1; enter the model ID manually. |
| Roo Code (VS Code) | OA https://apitopmix.com/v1 |
Provider → "OpenAI Compatible" → Base URL | API Key field | Same family as Cline. Choose OpenAI Compatible, keep /v1, set the model name explicitly. |
| Continue.dev | OA https://apitopmix.com/v1 |
apiBase in the model block of config.yaml/config.json |
apiKey in the same model block |
Use provider: openai with apiBase ending in /v1. One block per model you want to list. |
| ChatBox | OA https://apitopmix.com/v1 |
Settings → Model Provider "OpenAI API" → API Host | API Key field | Set API Host to the /v1 base. If ChatBox shows /v1 greyed as a suffix, enter only https://apitopmix.com — do not double it. |
| Cherry Studio | OA https://apitopmix.com/v1 |
Settings → Model Providers → API Address / 端点 | API Key field for that provider | Cherry Studio auto-appends /v1 unless the URL ends with /. Enter https://apitopmix.com to let it add /v1, or https://apitopmix.com/v1/ to force it verbatim. |
| Open WebUI | OA https://apitopmix.com/v1 |
Admin → Settings → Connections → OpenAI API Base URL | API Key field next to the URL | Include /v1. After saving, refresh the model list so ApiTopMix models appear in the picker. |
| Dify | OA https://apitopmix.com/v1 |
Settings → Model Provider → "OpenAI-API-compatible" → API endpoint URL | API Key field in the same dialog | Use the OpenAI-API-compatible provider for a Dify custom model base URL, keep /v1, and type the exact model name. |
| LangChain | OA https://apitopmix.com/v1 |
base_url= on ChatOpenAI(...) |
api_key= argument (or OPENAI_API_KEY) |
Pass base_url to ChatOpenAI. It ends in /v1; LangChain appends the path. |
| LlamaIndex | OA https://apitopmix.com/v1 |
api_base= on the OpenAI LLM class |
api_key= argument |
Note the field is api_base (not base_url). Keep the /v1 suffix. |
| curl | OA https://apitopmix.com/v1 |
Full URL in the request line | Authorization: Bearer header |
You type the whole path yourself: .../v1/chat/completions. No SDK magic, so no double-/v1 risk. |
Fourteen clients, one pattern: OpenAI-shaped tools take https://apitopmix.com/v1 and Claude-native tools take https://apitopmix.com as ANTHROPIC_BASE_URL. If your client is not listed but exposes an "OpenAI compatible base URL" field, treat it exactly like the OA rows above.
Copy-paste snippets for the most common clients
OpenAI Python SDK
from openai import OpenAI
client = OpenAI(
base_url="https://apitopmix.com/v1", # note the /v1
api_key="sk-your-apitopmix-key",
)
resp = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Say hi from Claude"}],
)
print(resp.choices[0].message.content)
curl (OpenAI-compatible endpoint)
curl https://apitopmix.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-apitopmix-key" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"ping"}]}'
Claude Code (Anthropic-native env vars)
export ANTHROPIC_BASE_URL=https://apitopmix.com # no /v1
export ANTHROPIC_AUTH_TOKEN=sk-your-apitopmix-key
claude
Cursor (Base URL override)
Settings → Models → enable OpenAI API Key → turn on Override OpenAI Base URL:
# Base URL field:
https://apitopmix.com/v1
# API Key field:
sk-your-apitopmix-key
# Custom model to add:
claude-sonnet-4-6
For the full Claude-Code-and-Cursor walkthrough, see Use Claude Code & Cursor and the dedicated Claude in Cursor guide.
Common mistakes when setting the base URL
- Double
/v1— you typedhttps://apitopmix.com/v1in a client that already appends/v1, producing/v1/v1/.... Fix: enter the bare host, or remove your/v1. - Missing
/v1— an OpenAI-SDK client gothttps://apitopmix.comand returned 404 on/chat/completions. Fix: add/v1. - Trailing slash —
https://apitopmix.com/v1/can turn into/v1//chat/completionsin strict clients. Drop the trailing slash unless the client's own hint asks for it. httpinstead ofhttps— always usehttps. Plainhttpfails or redirects and can drop the auth header.- Wrong header format — OpenAI-style clients need
Authorization: Bearer sk-.... If you hand-roll requests, don't send the key asx-api-keyto the OpenAI-compatible endpoint. - Base URL on the wrong protocol — putting
/v1intoANTHROPIC_BASE_URL, or the bare host into an OpenAI field. Match the base to the protocol the client speaks. - Placeholder key left in place — a 401 with a reachable URL means the routing is right and only the key is wrong. Paste the real ApiTopMix key with no stray whitespace.
/v1 path. If it comes back 401, suspect the key or header. Isolating which of the three you see tells you exactly what to fix.
Frequently asked questions
What is the Claude API base URL for ApiTopMix?
Two values. The OpenAI-compatible base URL is https://apitopmix.com/v1 — use it for OpenAI-SDK-style clients. The Anthropic-native base is https://apitopmix.com — set it as ANTHROPIC_BASE_URL for Claude Code and Anthropic SDKs. Both use the same ApiTopMix key, so which one you pick depends only on the protocol your client speaks.
Should the base URL include /v1 or not?
OpenAI-SDK clients expect the base URL to already end in /v1 and append /chat/completions themselves, so you enter https://apitopmix.com/v1. Anthropic clients like Claude Code expect the bare host https://apitopmix.com and add /v1/messages for you. Seeing /v1/v1 in an error means remove your /v1; a 404 on a bare host means add it.
What is the difference between the OpenAI-compatible base URL and the Anthropic base URL?
The OpenAI-compatible base (https://apitopmix.com/v1) speaks the OpenAI protocol and serves /v1/chat/completions. The Anthropic-native base (https://apitopmix.com) speaks the Anthropic protocol and serves /v1/messages. Cursor, Cline, ChatBox, Cherry Studio, Open WebUI and Dify use the OpenAI-compatible base; Claude Code and Anthropic SDKs use the native one.
How do I set the base URL in Cursor?
Open Cursor Settings → Models, enable the OpenAI API Key section, turn on Override OpenAI Base URL, and set it to https://apitopmix.com/v1 with the /v1 suffix. Paste your ApiTopMix key and add a custom model name such as claude-sonnet-4-6. See the Cursor guide for the full flow.
What base URL does Claude Code use?
Claude Code reads ANTHROPIC_BASE_URL. Set it to https://apitopmix.com (no /v1) and ANTHROPIC_AUTH_TOKEN to your ApiTopMix key, then run claude. Claude Code appends /v1/messages itself, so the native Anthropic protocol runs end to end.
Why do I get a 401 after changing the base URL?
A 401 with a reachable URL almost always means the key or header is wrong, not the base URL. OpenAI-style clients send Authorization: Bearer sk-your-key. Confirm you pasted the full ApiTopMix key with no stray space or newline and no leftover placeholder. The base URL being reachable but returning 401 actually confirms your routing is correct.
Can one base URL serve both Claude and other models?
Yes. The OpenAI-compatible base https://apitopmix.com/v1 serves many model families through one endpoint. You choose the model with the model field in each request, so the same base URL and the same key call different models by changing only that field.
Do I need http or https for the base URL?
Always https. The ApiTopMix bases are https://apitopmix.com/v1 and https://apitopmix.com. Plain http fails or redirects, and some clients refuse it for API keys. Don't add a port, and avoid a trailing slash unless the client explicitly needs one. If Claude Code or another client still errors after you fix the base URL, work through the base URL troubleshooting guide.
One base URL, every client
Grab an ApiTopMix key, paste the base URL into your client, and route the whole Claude family through a single endpoint.
Related guides
- Use Claude Code & Cursor — the full setup walkthrough for both tools.
- Claude in Cursor — the deep dive on the Cursor Base URL override.
- Claude Code base URL troubleshooting — fixes for 404, 401,
/v1/v1and connection errors. - ApiTopMix Pricing — the current price table for every model.
- ApiTopMix API Documentation — endpoints, headers, and full code samples.
Conclusion
Setting a custom base URL is the single most reusable skill for working with AI clients, because it is the same move everywhere: find the base-URL field, decide whether the client wants the OpenAI-compatible https://apitopmix.com/v1 or the Anthropic-native https://apitopmix.com, mind the /v1 convention, and drop in your key. Once you internalize the OpenAI-vs-Anthropic split and the /v1 gotcha, every new tool — this year's editor, next year's framework — is a two-minute configuration rather than an afternoon of trial and error.
Bookmark this page as your endpoint cheat sheet. When a client isn't listed, match it to the closest row above, apply the same base URL and key placement, and it will route through ApiTopMix the same way. From there, the model name is the only thing you ever change.
ApiTopMix