Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

fix(fallback): classify 400 'No model found' as model_not_found (#1143)

Edson Fernandes Cunhab714ac40a1d7
diff --git a/server/src/__tests__/routes/proxy-retry.test.ts b/server/src/__tests__/routes/proxy-retry.test.ts
index d8f18614..49ecf0a4 100644
--- a/server/src/__tests__/routes/proxy-retry.test.ts
+++ b/server/src/__tests__/routes/proxy-retry.test.ts
@@ -82,6 +82,17 @@ describe('isModelNotFoundError (drives whole-model skip within a request)', () =
expect(isModelNotFoundError(new Error('No endpoints found for openrouter/minimax/minimax-m2.5:free'))).toBe(true);
});
+ it('flags a stale/removed model reported as a 400 "No model found" (Routeway) — MODEL-level, not request shape', () => {
+ // "No model found" does NOT contain the substring "not found" (words are
+ // no/model/found), so before the phrase list it slipped through to
+ // isProviderBadRequestError and surfaced as a request-blaming 400.
+ expect(isModelNotFoundError(Object.assign(new Error('Routeway API error 400: No model found: llama-3.3-70b-instruct:free'), { status: 400 }))).toBe(true);
+ expect(isModelNotFoundError(new Error('Groq API error 400: model not found'))).toBe(true);
+ expect(isModelNotFoundError(new Error('Provider API error 400: unknown model'))).toBe(true);
+ expect(isModelNotFoundError(new Error('API error 400: model does not exist'))).toBe(true);
+ expect(isModelNotFoundError(new Error('API error 404: no such model'))).toBe(true);
+ });
+
it('flags 410 Gone (model pulled upstream) by message or attached status — #339', () => {
expect(isModelNotFoundError(new Error('Ollama Cloud API error 410: Gone'))).toBe(true);
expect(isModelNotFoundError(Object.assign(new Error('Gone'), { status: 410 }))).toBe(true);
diff --git a/server/src/lib/error-classify.ts b/server/src/lib/error-classify.ts
index ffbef44f..8fdf928d 100644
--- a/server/src/lib/error-classify.ts
+++ b/server/src/lib/error-classify.ts
@@ -505,7 +505,18 @@ export function isModelNotFoundError(err: any): boolean {
if (err?.status === 404 || err?.status === 410) return true;
const msg = (err?.message ?? '').toLowerCase();
return msg.includes('404') || msg.includes('not found') || msg.includes('no endpoints found')
- || msg.includes('410') || msg.includes('gone');
+ || msg.includes('410') || msg.includes('gone')
+ // Some aggregators report a removed/stale model with a 400 (not a 404) whose
+ // body reads "No model found: <id>", "model not found", "unknown model" or
+ // "model does not exist" (#: Routeway 400 "No model found: llama-3.3-70b-instruct:free").
+ // Note "No model found" does NOT contain the substring "not found" (words are
+ // no/model/found), so it slipped past the checks above and fell through to
+ // isProviderBadRequestError — surfacing as a request-blaming 400 instead of a
+ // stale-catalog 404. These phrasings are MODEL-level (every sibling key fails
+ // identically), so they belong here for the whole-model skip.
+ || msg.includes('no model found') || msg.includes('model not found')
+ || msg.includes('unknown model') || msg.includes('model does not exist')
+ || msg.includes('no such model');
}
// A 403 that suspends the ACCOUNT, not one model: NavyAI answers every model