{"record":{"id":"e10b7385c7b0288d","repo":"different-ai/openwork","slug":"provider-not-found","errorCode":"provider_not_found","errorMessage":"The selected provider was not found in models.dev.","messagePattern":"The selected provider was not found in models\\.dev\\.","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"ee/apps/den-api/src/routes/org/llm-providers.ts","lineNumber":508,"sourceCode":"  const rows = await db\n    .select()\n    .from(LlmProviderTable)\n    .where(and(\n      eq(LlmProviderTable.organizationId, input.organizationId),\n      eq(LlmProviderTable.id, input.llmProviderId),\n    ))\n    .limit(1)\n  return rows[0] ?? null\n}\n\nasync function normalizeLlmProviderInput(\n  input: z.infer<typeof llmProviderWriteSchema>,\n  existingProvider: Pick<LlmProviderRow, \"apiKey\" | \"providerConfig\"> | null = null,\n) {\n  if (input.source === \"models_dev\") {\n    const provider = await getModelsDevProvider(input.providerId ?? \"\")\n    if (!provider) {\n      throw createFailure(404, \"provider_not_found\", \"The selected provider was not found in models.dev.\")\n    }\n\n    const requestedModelIds = [...new Set(input.modelIds ?? [])]\n    const modelsById = new Map(provider.models.map((model) => [model.id, model]))\n    // Azure model lists come from the resource's *deployments*, which admins\n    // can name anything — accept ids outside the models.dev catalog for\n    // Azure providers instead of rejecting the save.\n    const allowDeploymentIds = provider.npm === \"@ai-sdk/azure\"\n    const models = requestedModelIds.map((modelId) => {\n      const model = modelsById.get(modelId)\n      if (!model) {\n        if (allowDeploymentIds) {\n          return { id: modelId, name: modelId, config: { id: modelId, name: modelId } }\n        }\n        throw createFailure(404, \"model_not_found\", `Model ${modelId} is not available for ${provider.name}.`)\n      }\n      return model\n    })","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/routes/org/llm-providers.ts#L490-L526","documentation":"normalizeLlmProviderInput validates providers with source models_dev by looking up the providerId via getModelsDevProvider. If the catalog lookup returns nothing, it throws 404 provider_not_found with the message 'The selected provider was not found in models.dev.'","triggerScenarios":"Creating/updating an LLM provider with source: \"models_dev\" and a providerId (or empty input.providerId ?? \"\") that is not present in the models.dev catalog snapshot.","commonSituations":"Typo in the provider id (e.g. 'openai-chat' vs 'openai'); provider removed or renamed in models.dev; stale catalog snapshot missing a newly added provider; sending the model id instead of the provider id.","solutions":["Verify the providerId against the models.dev catalog / available providers endpoint.","Fix typos — ids are exact lowercase slugs like \"openai\", \"anthropic\".","If the provider is genuinely new, refresh the models.dev catalog snapshot the server uses.","Ensure you are not sending an empty providerId — the ?? \"\" fallback guarantees failure when omitted."],"exampleFix":"// before\n{ source: \"models_dev\", providerId: \"OpenAI\" }\n// after\n{ source: \"models_dev\", providerId: \"openai\" }","handlingStrategy":"validation","validationCode":"const catalog = await getModelsDevProviders();\nif (!catalog.some(p => p.id === providerId)) throw new Error(`unknown providerId: ${providerId}`);","typeGuard":"function isKnownProviderId(id: string, catalog: {id: string}[]): boolean { return catalog.some(p => p.id === id) }","tryCatchPattern":"try { await upsertProvider(payload) } catch (e) { if (e.code === 'provider_not_found') console.error('check providerId against models.dev'); }","preventionTips":["Always include providerId — omitting it resolves to \"\" and always fails","Use exact lowercase catalog slugs (e.g. \"openai\", \"anthropic\")","Refresh the models.dev snapshot when new providers appear","Never substitute a model id for the provider id"],"tags":["http-404","models-dev","provider-config"],"backgroundTag":"resource-not-found","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}