A 404 not_found_error from the Anthropic SDK after you point ANTHROPIC_BASE_URL at a gateway means the model id is not one the gateway serves, not that the key is wrong, and the Anthropic base here is https://api.uplinkswitch.com/v1. The quickest proof is the status code itself: a bad or revoked key returns 401, a key that may not reach a given model returns 403, and only a name that no model matches returns 404. So the thing to change is the string in your model field, and the rest of this page shows how to read the exact id your key accepts.
Read the status code before you touch the key
Each failure class on this endpoint has its own number, and they do not overlap. A missing, malformed or revoked credential comes back as 401 invalid_api_key. A credential that is valid but whose allowlist leaves out the model you named comes back as 403 scope_denied. A model string that matches nothing in the catalog comes back as 404, where the body's stable code reads model_not_found. Because the key already cleared authentication to reach a 404 at all, rotating it or regenerating it changes nothing. Treat a 404 that carries model_not_found purely as a naming miss. A 404 with route_not_found instead means the request reached a path the gateway does not serve, so check the base URL rather than the model.
What the SDK hands you
The Anthropic Python client raises anthropic.NotFoundError on a 404; that class sits under APIStatusError, which sits under APIError, so a broad except anthropic.APIError still catches it while a narrow except anthropic.NotFoundError lets you handle this one case on its own. The exception carries status_code set to 404 and a type read from the response body's error.type, which for this status is not_found_error. This gateway appends its own code in parentheses on the message, so the text you log ends with (model_not_found), telling you plainly that the id, and nothing else, is the problem.
import anthropic
client = anthropic.Anthropic(
api_key="sk-uplink-live-...",
base_url="https://api.uplinkswitch.com/v1",
)
try:
msg = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=256,
messages=[{"role": "user", "content": "One sentence on idempotency."}],
)
print(msg.content[0].text)
except anthropic.NotFoundError as e:
print(e.status_code, e.type) # 404 not_found_errorThe client reads ANTHROPIC_BASE_URL from the environment when you do not pass base_url, so the two are interchangeable; the live Claude Code guide shows the same base in a shell variable and a settings.json block, keep the trailing /v1 in either place.
List the ids this key can actually call
The id list is not something to guess at. GET /v1/models returns it, and its shape follows the header you authenticate with: send x-api-key and you get Anthropic's list format back, the same one the SDK expects. Every model the key's allowlist admits is there, followed by any aliases your organization defined, each naming its underlying model in an alias_of field.
curl https://api.uplinkswitch.com/v1/models \
-H "x-api-key: sk-uplink-live-..." \
-H "anthropic-version: 2023-06-01"If you want the full roster before you even make a key, the public catalog needs no credential at all:
curl https://api.uplinkswitch.com/v1/catalogThat response enumerates every servable id with its developer and the formats it answers. Copy the id field verbatim into your model argument. One Claude id to start with is claude-sonnet-5-5, which reads ok on the 2026-11-23 catalog; its availability flag tells you whether it is healthy before you wire it in, and an id flagged degraded should be swapped for a healthy sibling.
Claude ids carry no vendor prefix
The most common cause of this 404 is a borrowed prefix. Tools built around multi-provider routers often expect a provider segment in the name, such as anthropic/claude-..., and that composite string matches nothing here. The catalog lists the developer's own bare id, so the value you pass is claude-sonnet-5-5, not a slashed or namespaced form of it. If you moved config across from such a router, strip the leading segment and the 404 clears.
A near neighbour worth knowing: before late October 2026 a non-Claude id sent to the Messages endpoint returned a 400 saying the model was served in another wire format, because only Claude answered there. That is no longer the behaviour; every chat model now answers the Messages format, the request rewritten under the hood. So today a Messages call that fails on the id is a 404, not that older 400. If you do see the 400, it means the body is malformed in some other way, for instance no model named at all, or a model that is not a string.
A checklist that ends the loop
- Confirm the status is 404, not 401 or 403. Only 404 is a naming problem.
- Print the id your code is sending, resolved after any environment or config layer, not the literal you think it is.
- Call
GET /v1/modelswithx-api-keyand copy an id from the response. - Drop any provider prefix; the id is the developer's own.
- Re-run, and catch
anthropic.NotFoundErrorseparately so a future typo is obvious in the logs.
Keep the base URL and key in environment variables so swapping a model or rolling back is a config edit, never a code change. The SDK setup guide covers the same client across OpenAI, Anthropic and Gemini formats if you are pointing more than one library at the gateway.