Why an LLM API fallback can still return model_not_found
Reproduce a 404 with a working backup model, identify the routing failure, and verify the backup before you depend on it.
A fallback can be configured correctly and still return 404 model_not_found. On Ofox, the gateway has to resolve the primary model to a route before it can try a backup after an upstream error. When the primary model ID is unavailable, the request ends during routing. Start by checking the primary ID, then call the backup directly with the same input. Ofox fallback rules
What happened when we tested the same request twice?
On December 3, 2026, we used one Ofox API key and one non-streaming Chat Completions endpoint. Both requests used the same short text input, a 128-token output limit and an exact JSON acceptance check. GLM-5.4 was unavailable on the Ofox route we tested that day.
| Request | HTTP result | What we observed |
|---|---|---|
z-ai/glm-5.4 with z-ai/glm-5.3-flash configured as a backup | 404 | model_not_found, with no assistant response |
z-ai/glm-5.3-flash as the requested model | 200 | The response reported z-ai/glm-5.3-flash and returned {"route_check":"ready"} |
The second row establishes that the backup was callable directly with this key. The two requests did not simulate an outage after the gateway picked an upstream route. The test recorded HTTP results and API usage fields. Billing was outside its scope. See the separate GLM-5.4 API access guide for the distinction between direct Z.ai access and Ofox availability.
How to run the two checks
Set OFOX_API_KEY using your usual secret manager or shell. Keep the key out of the script and any logs. Use a staging key that can call your intended backup model, and confirm that the model ID is listed for it. The PRIMARY below reproduces the December 3 fixture while that route remains unavailable. For your own test, set it to the primary ID your application sends. Choose a short prompt with no tools or production data. Key setup · Chat Completions reference
import json
import os
from urllib.error import HTTPError
from urllib.request import Request, urlopen
PRIMARY = "z-ai/glm-5.4"
BACKUP = "z-ai/glm-5.3-flash"
URL = "https://api.ofox.ai/v1/chat/completions"
EXPECTED = {"route_check": "ready"}
def probe(model, fallback=()):
body = {
"model": model,
"messages": [{
"role": "user",
"content": 'Return exactly this JSON object, with no Markdown: '
'{"route_check":"ready"}.',
}],
"max_tokens": 128,
"stream": False,
}
if fallback:
body["extra_body"] = {"provider": {"fallback": list(fallback)}}
req = Request(URL, data=json.dumps(body).encode(), headers={
"Authorization": "Bearer " + os.environ["OFOX_API_KEY"],
"Content-Type": "application/json",
})
try:
with urlopen(req, timeout=20) as response:
status, payload = response.status, json.load(response)
except HTTPError as response:
status, payload = response.code, json.load(response)
choices = payload.get("choices") or []
content = choices[0].get("message", {}).get("content") if choices else None
try:
accepted = status == 200 and json.loads(content) == EXPECTED
except (TypeError, ValueError):
accepted = False
error = payload.get("error") or {}
print({
"requested": model, "http": status,
"error": error.get("type") or error.get("code"),
"reported_model": payload.get("model"),
"accepted": accepted,
})
probe(PRIMARY, [BACKUP])
probe(BACKUP)
Read the rows in order. With the same dated fixture, the first row should show 404 and model_not_found, while the second should show 200 with accepted: True. If the first row now succeeds, inspect reported_model and Activity to see which model answered. Model availability can change. If direct backup access fails, fix that route before running an automatic switching test. For a transport timeout or a non-JSON error page, keep the raw status or exception and inspect the request before retrying.
What should you test before enabling automatic switching?
| Signal | Next check |
|---|---|
404 model_not_found | Check the exact model ID, endpoint and what the key can access. Repeating the same unavailable ID leaves the routing problem in place. |
400 provider_type_unavailable | Check whether the pinned provider serves the requested model. Verify the model and provider together before adding backups. |
200 and rejected output | Check your application’s acceptance rules. If another attempt is appropriate, count it as a separate decision and keep any state-changing tools out of this probe. |
| Upstream error after routing | Use an authorized staging fault or a recorded incident to verify automatic fallback. Check the returned model, application acceptance and Activity together. |
An HTTP 200 is the beginning of the result check. In the example above, the response must parse as JSON and equal the expected object. A successful direct backup check supports deploying a test of switching. For a production rollout, keep a separate record of an actual upstream failure, which backup answered, and whether the result met the same acceptance rules. Match requests to the Ofox Activity troubleshooting fields before attributing cost or latency to a route. For a broader diagnostic, use the model-not-found checklist or the OpenAI-compatible API readiness test.


