Fix "Model Not Found" & Base URL Errors in Claude Code, Cursor & Cline
Pointing Claude Code, Cursor, or Cline at a third-party endpoint with a custom base URL should take two minutes — but when it goes wrong, the errors are frustratingly vague. You paste a base URL, launch the client, and get hit with "model not found", a bare 401 unauthorized, a 404 on the endpoint, or the sinking feeling that ANTHROPIC_BASE_URL is being ignored entirely. This guide is a fast, practical reference for every one of those failures. It is built around a single big troubleshooting table — symptom, likely cause, and fix — plus a curl sanity check to tell a client bug apart from an endpoint bug.
All the examples target ApiTopMix, which exposes an OpenAI-compatible endpoint at https://apitopmix.com/v1 and a native Anthropic endpoint at /v1/messages. That dual surface is exactly why base-URL mistakes happen: OpenAI-style clients (Cursor, Cline) want the /v1 base, while Claude Code speaks the Anthropic protocol and wants the host root. Get the pairing right and the "custom api model not found fix" you have been hunting for is usually one line.
ANTHROPIC_BASE_URL=https://apitopmix.com (no /v1). For Cursor and Cline set the OpenAI base URL to https://apitopmix.com/v1. Use an exact model id such as claude-sonnet-4-6, send the key in the right header, restart the client, and confirm with curl.
The one-minute mental model
Almost every custom base URL error falls into one of five buckets. Fix them in this order and you rarely need to guess:
- Model id — the exact
modelstring must be one the endpoint serves. Wrong or unsupported name → model not found. - Base URL shape — right host, right
/v1(or no/v1),https, no trailing slash. Wrong shape → 404 or connection error. - Environment — the variable is actually exported in the shell that launched the client, and the client was restarted. Not applied → ANTHROPIC_BASE_URL not working.
- Auth — a valid key in the header the client expects. Bad or misplaced key → 401 / 403.
- Client state — the client re-read config instead of caching the old one. Stale cache → "works in curl but not in the client".
The big troubleshooting table
Find your symptom in the left column, read the likely cause, apply the fix. This is the core of the page — bookmark it.
| Symptom | Likely cause | Fix |
|---|---|---|
"model not found" / model_not_found (Claude Code, Cursor, Cline) |
The model string does not match any id the endpoint serves — a typo, an old snapshot name, or the client's built-in default that the gateway does not expose. |
Use an exact supported id, e.g. claude-sonnet-4-6 or claude-opus-4-6. In Claude Code set ANTHROPIC_MODEL and ANTHROPIC_SMALL_FAST_MODEL so nothing falls back to an unknown default. Confirm the list at https://apitopmix.com/v1/models. |
| Cursor: "model not found" with a custom API | The model was never added under custom models, or the selected name has a typo, so Cursor sends a name the endpoint rejects. | In Settings → Models, add claude-sonnet-4-6 as a custom model, set the base URL override to https://apitopmix.com/v1, then pick that exact model in the picker. |
| Cline: base url error / requests never reach the provider | Cline is set to the wrong API provider type, or the base URL is missing the /v1 segment it expects for an OpenAI-compatible endpoint. |
Choose the OpenAI Compatible provider in Cline, set base URL to https://apitopmix.com/v1, paste your sk- key, and enter a supported model id. |
Base URL wrong — missing or extra /v1 |
OpenAI-style clients need the /v1 base; Claude Code (Anthropic protocol) needs the host root. Doubling up (/v1/v1) or dropping /v1 breaks routing. |
Cursor / Cline → https://apitopmix.com/v1. Claude Code → https://apitopmix.com (no suffix). Never append /chat/completions yourself. |
| Trailing slash / http vs https quirks | A trailing / produces a double slash in the path, or http:// triggers a redirect that drops the auth header. |
Remove the trailing slash and always use https://. Copy the base URL verbatim with no surrounding spaces or newlines. |
ANTHROPIC_BASE_URL not working / ignored |
The variable was set in a different shell, never exported, or Claude Code was already running when you changed it. |
export it in the same shell that runs claude, then restart the client. Verify with echo $ANTHROPIC_BASE_URL. On Windows use setx or the PowerShell profile — set only affects the current window. |
| Env var reverts after restart | It was exported only for the current session and never written to a profile. | Add the export lines to ~/.zshrc or ~/.bashrc (macOS/Linux), or set a persistent user variable with setx (Windows). Open a fresh terminal to confirm. |
| 401 unauthorized | Missing key, malformed key (extra space or newline), or key sent in the wrong variable/header. | Confirm the key starts with sk- and is clean. Claude Code → ANTHROPIC_AUTH_TOKEN. OpenAI-style clients → Authorization: Bearer sk-your-key. Set only one auth source, then retry. |
| 403 forbidden | Key is valid but lacks access to the requested model, or the request carries an unexpected extra header. | Switch to a model your key can call, remove any hardcoded org/project headers left over from another provider, and check your account status in the console. |
404 on the endpoint (base url 404 claude) |
The path is wrong for the protocol: an OpenAI client is hitting a non-/v1 path, or the client appended an extra path segment. |
OpenAI-style base must end in /v1 (client appends /chat/completions). Anthropic clients reach /v1/messages from the root. Verify the exact route with the curl test below. |
| Timeouts / connection reset | A local corporate proxy or firewall is intercepting HTTPS, or an HTTP(S)_PROXY variable is silently rerouting traffic. |
Retry off the intercepting network, or unset stray HTTP_PROXY / HTTPS_PROXY variables. Confirm reachability with curl -v https://apitopmix.com/v1/chat/completions. |
| Streaming breaks / partial output | A proxy buffers the response, or the client expects Server-Sent Events but something downstream strips them. | Bypass the buffering proxy, keep stream enabled in the client, and test streaming directly with curl -N. If curl streams cleanly, the fault is the proxy, not the endpoint. |
| High latency / slow first token | Network path or an overloaded local proxy — not the model itself. | Compare curl timing against the client. If curl is fast and the client is slow, inspect the client's proxy and networking settings rather than the endpoint. |
| "Works in curl but not in the client" | The client cached an old base URL, key, or model, or a settings file overrides your environment variables. | Fully restart the editor/CLI, clear the cached base URL and key, re-select the model, and check for a second config source (settings file) that shadows the environment. |
| Invalid API key even after pasting a fresh one | The client kept the previous value in memory or read it from a different profile. | Remove the old key everywhere, paste the new sk- key once, restart, and re-verify. A successful curl with the same key proves the key is valid. |
Isolate it: the curl sanity check
Before you spend an hour tweaking client settings, spend thirty seconds proving whether the endpoint works at all. This single request talks straight to the OpenAI-compatible route and skips every client entirely:
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"}]}'
Read the result like a decision tree:
- Normal chat completion JSON → the endpoint, key, and model id are all correct. Any remaining failure is client-side config or cache. Restart the client and re-check its base URL, key, and selected model.
- 401 / 403 → the key or its permissions are the problem, not the client. Regenerate the key in the console and paste it cleanly.
- 404 → the path is wrong. Confirm you are hitting
/v1/chat/completionsand that the base ishttps://apitopmix.com/v1. - model not found → the
modelvalue is unsupported. Swap in an id returned byhttps://apitopmix.com/v1/models. - Timeout / no response → a network or proxy issue sits between you and the endpoint. Retry off the intercepting network.
For Claude Code specifically, you can also test the native Anthropic surface by exporting the two variables and launching claude — a reply confirms ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are wired up. The curl above stays the fastest way to separate a Claude Code third party api error from a genuine endpoint problem.
curl succeeds, stop editing the endpoint. Every remaining fix lives in the client — its cached base URL, its stored key, or the exact model name in its picker.
Client-by-client quick fixes
Claude Code
Claude Code is driven by environment variables, so its failures are almost always environment failures. Set the base URL to the host root (no /v1), export in the launching shell, and restart:
export ANTHROPIC_BASE_URL=https://apitopmix.com
export ANTHROPIC_AUTH_TOKEN=sk-your-apitopmix-key
export ANTHROPIC_MODEL=claude-sonnet-4-6
claude
If you still see Claude Code model not found, pin ANTHROPIC_MODEL (and ANTHROPIC_SMALL_FAST_MODEL) to supported ids so the CLI never falls back to a default name the gateway does not serve. If the base URL still looks ignored, you are almost certainly in a different shell than the one you exported in — echo $ANTHROPIC_BASE_URL to prove it.
Cursor
Cursor talks the OpenAI protocol, so it needs the /v1 base and an explicitly added model. In Settings → Models: enable the OpenAI API key, turn on Override OpenAI Base URL and set it to https://apitopmix.com/v1, paste your sk- key, then add claude-sonnet-4-6 under custom models and select it. A Cursor model not found custom api error means the name in the picker does not match a served id — retype it exactly.
Cline
In Cline, choose the OpenAI Compatible provider, set base URL to https://apitopmix.com/v1, paste your key, and enter a supported model id. A Cline base url error usually means the wrong provider type was selected or the /v1 segment is missing — both send the request to a path that returns 404.
Still stuck? Run this checklist
- Model id is exact. Copy it from
https://apitopmix.com/v1/models— no snapshot suffix you invented. - Base URL matches the protocol.
/v1for Cursor/Cline, host root for Claude Code.https, no trailing slash. - Key is clean and in the right place. Starts with
sk-, no whitespace, one auth source only. - Environment is exported and the client restarted.
echothe variable in the launching shell. - curl succeeds. If it does, the endpoint is fine — chase the client cache.
- No stray proxy. Check
HTTP_PROXY/HTTPS_PROXYand any corporate HTTPS interception. - One config source. A settings file must not silently override your environment variables.
Work top to bottom and the failure almost always surfaces by step 5. For endpoint details, headers, and the live model list, see the ApiTopMix API documentation; for what each model costs, see the ApiTopMix pricing page.
Frequently asked questions
Why does Claude Code say model not found with a third-party API?
Because the model string you sent does not match a model id the endpoint actually serves. Coding clients often default to an internal Anthropic model name that a custom gateway does not expose, which surfaces as Claude Code model not found. Use an exact id such as claude-sonnet-4-6, and set ANTHROPIC_MODEL and ANTHROPIC_SMALL_FAST_MODEL so no request falls back to an unknown default. With ApiTopMix you can list the exact ids at https://apitopmix.com/v1/models.
Why is my Claude Code base url not working?
Usually a wrong path suffix or protocol. Claude Code expects ANTHROPIC_BASE_URL to be the host root that serves the Anthropic protocol, so use https://apitopmix.com with no /v1. OpenAI-style clients want the /v1 base, so they use https://apitopmix.com/v1. Always https, no trailing slash, no stray whitespace.
Why is ANTHROPIC_BASE_URL not working even though I set it?
ANTHROPIC_BASE_URL not working almost always means it was set in a different shell, never exported, or the client was already running. Export it in the same shell that launches claude, restart the client so it re-reads the environment, and echo $ANTHROPIC_BASE_URL to confirm. On Windows, set only affects the current window — use setx or your PowerShell profile.
How do I fix a Claude Code 401 unauthorized error?
A Claude Code 401 unauthorized means the key is missing, malformed, or in the wrong header. Confirm it starts with sk- with no trailing spaces or line breaks. Claude Code reads ANTHROPIC_AUTH_TOKEN; OpenAI-style clients send Authorization: Bearer sk-your-key. Keep only one auth source. If the same key succeeds in curl, the client is caching an old invalid api key.
Why does Cursor show model not found with a custom api?
Cursor only sends model names you added under custom models, and the name must match a served id exactly. Add claude-sonnet-4-6 in the Models panel, set the base URL override to https://apitopmix.com/v1, and pick that model. A typo, a stale default, or a missing custom-model entry all produce Cursor model not found custom api.
How do I fix a base url 404 in Claude Code or Cline?
A base url 404 means the path is wrong for the protocol. OpenAI-style clients must reach /v1/chat/completions, so the base URL ends in /v1 and nothing more — never append the path yourself. Anthropic-protocol clients reach /v1/messages from the host root. Test the exact route with curl against https://apitopmix.com/v1/chat/completions. This resolves most Cline base url error cases too.
It works in curl but not in the client — what now?
A successful curl proves the endpoint, key, and model are fine, so the fault is client-side. Fully restart the editor or CLI, clear any cached base URL or key, re-select the model, and check for a settings file that overrides your environment variables. This is the fastest resolution for a stubborn custom api model not found fix where the endpoint clearly works.
Get a clean key and a working endpoint
Grab an ApiTopMix key, set the right base URL for your client, and get past "model not found" for good.
Further reading
- Use Claude Code & Cursor with ApiTopMix — the full setup guide these fixes build on.
- Use Claude in Cursor — custom base URL and model setup, step by step.
- ApiTopMix Pricing — the current price table for every model.
- ApiTopMix API Documentation — endpoints, headers, and the live model list.
Conclusion
A custom base URL should never cost you an afternoon. Nearly every Claude Code third party api error reduces to one of five things: an exact model id, the right base-URL shape, an exported environment variable, a clean key in the correct header, or a client that was restarted so it stops caching stale config. Run the curl sanity check first — it draws a hard line between an endpoint problem and a client problem — then walk the checklist from the top.
Get those basics right against https://apitopmix.com/v1 (or the Anthropic host root for Claude Code) and "model not found", 401, and 404 all disappear together. Point your client at ApiTopMix, confirm with one request, and get back to shipping code.
ApiTopMix