{"record":{"id":"4991e0b5634758e4","repo":"ruvnet/ruflo","slug":"model-not-found","errorCode":"MODEL_NOT_FOUND","errorMessage":"Model ${model} not found","messagePattern":"Model (.+?) not found","errorType":"exception","errorClass":"ModelNotFoundError","httpStatus":404,"severity":"error","filePath":"v3/@claude-flow/providers/src/openai-provider.ts","lineNumber":478,"sourceCode":"    } catch {\n      errorData = { error: { message: errorText } };\n    }\n\n    const message = errorData.error?.message || 'Unknown error';\n\n    switch (response.status) {\n      case 401:\n        throw new AuthenticationError(message, 'openai', errorData);\n      case 429:\n        const retryAfter = response.headers.get('retry-after');\n        throw new RateLimitError(\n          message,\n          'openai',\n          retryAfter ? parseInt(retryAfter) : undefined,\n          errorData\n        );\n      case 404:\n        throw new ModelNotFoundError(this.config.model, 'openai', errorData);\n      default:\n        throw new LLMProviderError(\n          message,\n          `OPENAI_${response.status}`,\n          'openai',\n          response.status,\n          response.status >= 500,\n          errorData\n        );\n    }\n  }\n}\n","sourceCodeStart":460,"sourceCodeEnd":491,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/providers/src/openai-provider.ts#L460-L491","documentation":"OpenAIProvider maps HTTP 404 to ModelNotFoundError (code MODEL_NOT_FOUND, non-retryable), reporting this.config.model in the message. It fires when the model id does not exist for your account: a typo, a retired model (OpenAI deprecates older models), or a gated model your key cannot access. Note the handler reads config.model, so if a request overrode the model per-call, the message can name the configured model rather than the one actually requested.","triggerScenarios":"complete() with model 'gpt-4-32k' or 'text-davinci-003' (retired), a typo like 'gpt4o', or a preview/gated model the key has no access to - OpenAI answers 404 and the provider raises this error.","commonSituations":"Code written against a model that was later deprecated; model id from an outdated tutorial; per-request model override while config.model holds a stale id; o1-style gated models without approval.","solutions":["Use a current model id - list what your key can see: curl -H 'Authorization: Bearer $OPENAI_API_KEY' https://api.openai.com/v1/models","Fix exact spelling and dashes: 'gpt-4o', not 'gpt4o' or 'GPT-4O'","If you pass request.model per call, also keep config.model valid - the 404 handler reports config.model, which can mislead","For gated models, request access in the dashboard or switch to an available variant"],"exampleFix":"// before\nconfig: { apiKey, model: 'gpt-4-32k' } // retired model -> Model not found (404)\n\n// after\nconfig: { apiKey, model: 'gpt-4o' } // verify against GET /v1/models for your key","handlingStrategy":"validation","validationCode":"async function modelExistsForKey(model: string, apiKey: string): Promise<boolean> {\n  const r = await fetch('https://api.openai.com/v1/models', {\n    headers: { Authorization: `Bearer ${apiKey}` },\n  });\n  const { data } = await r.json();\n  return Array.isArray(data) && data.some((m: { id: string }) => m.id === model);\n}\n// if (!await modelExistsForKey('gpt-4o', apiKey)) throw new Error('model unavailable for this key');","typeGuard":"import { ModelNotFoundError } from './types.js';\nfunction isModelNotFound(e: unknown): e is ModelNotFoundError {\n  return e instanceof ModelNotFoundError;\n}","tryCatchPattern":"try {\n  return await provider.complete(req);\n} catch (e) {\n  if (isModelNotFound(e)) {\n    // deterministic: pick a known-good fallback model, do not retry the same id\n    return provider.complete({ ...req, model: 'gpt-4o' });\n  }\n  throw e;\n}","preventionTips":["Fetch the model list for your key at startup and validate configured ids against it","Keep model ids in one constant/module so deprecations are a one-line change","Remember the 404 handler reports config.model - keep config.model valid even when overriding per request"],"tags":["model","openai","http-404","deprecation","gated-access"],"backgroundTag":"model-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}