{"record":{"id":"6c58fd84315a6717","repo":"janhq/jan","slug":"no-model-available-to-load","errorCode":null,"errorMessage":"No model available to load","messagePattern":"No model available to load","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web-app/src/routes/settings/local-api-server.tsx","lineNumber":139,"sourceCode":"\n      // if (!apiKey || apiKey.toString().trim().length === 0) {\n      //   setShowApiKeyError(true)\n      //   return\n      // }\n\n      setShowApiKeyError(false)\n\n      setServerStatus('pending')\n\n      ensureModelForServer({\n        modelsService: serviceHub.models(),\n        modelOverride: defaultModelLocalApiServer,\n        onLoadStart: () => setIsModelLoading(true),\n        onLoadEnd: () => setIsModelLoading(false),\n      })\n        .then(async (result) => {\n          if (result.status === 'no_model_available') {\n            throw new Error('No model available to load')\n          }\n\n          // Remember loaded models for next startup\n          const activeModels = await serviceHub.models().getActiveModels()\n          if (activeModels && activeModels.length > 0) {\n            const allProviders = useModelProvider.getState().providers\n            const serverModels = activeModels.flatMap((id: string) => {\n              const p = allProviders.find((p) =>\n                p?.models?.some((m: { id: string }) => m.id === id)\n              )\n              return p ? [{ model: id, provider: p.provider }] : []\n            })\n            if (serverModels.length > 0) setLastServerModels(serverModels)\n          }\n\n          // Refresh active models in app state\n          const models = await serviceHub.models().getActiveModels()\n          setActiveModels(models || [])","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/web-app/src/routes/settings/local-api-server.tsx#L121-L157","documentation":"Thrown in the local API server start flow (local-api-server.tsx:139) when ensureModelForServer resolves with status 'no_model_available'. The server cannot start without a model to serve, so the promise chain rejects before window.core.api.startServer is called.","triggerScenarios":"No model is installed locally and none is explicitly overridden via defaultModelLocalApiServer; the previously-configured default model was deleted; ensureModelForServer found zero downloadable and zero local candidates to fall back on.","commonSituations":"Fresh install with no models downloaded; user deleted all models then tried to start the local server; the model override in settings points to an uninstalled model id and no fallback exists.","solutions":["Download at least one model from the Hub before starting the local API server.","Set a valid default model for the server in the local-API-server settings (defaultModelLocalApiServer).","If a model was deleted, re-download it or pick another installed model as the default."],"exampleFix":"// before\nif (result.status === 'no_model_available') {\n  throw new Error('No model available to load')\n}\n// after: surface a actionable toast and block server start with guidance\nif (result.status === 'no_model_available') {\n  toast.error('Download a model from the Hub first, then start the server.')\n  setServerStatus('idle')\n  return\n}","handlingStrategy":"validation","validationCode":"async function hasModelToServe(modelsService, override?: string): Promise<boolean> {\n  if (override) {\n    const m = await modelsService.getModel(override)\n    if (m) return true\n  }\n  const installed = await modelsService.fetchModels()\n  return installed.length > 0\n}\n// before ensureModelForServer:\nif (!(await hasModelToServe(serviceHub.models(), defaultModelLocalApiServer))) {\n  toast.error('Download a model from the Hub first.')\n  return\n}","typeGuard":"function hasInstalledModels(list: unknown): boolean {\n  return Array.isArray(list) && list.length > 0\n}","tryCatchPattern":"try {\n  const result = await ensureModelForServer({ ... })\n  if (result.status === 'no_model_available') throw new Error('No model available to load')\n} catch (e) {\n  setServerStatus('idle')\n  toast.error(e instanceof Error ? e.message : 'Server start failed')\n}","preventionTips":["Disable the Start Server button until at least one model is installed.","Validate defaultModelLocalApiServer points to an installed model.","Offer a 'Download a model' shortcut from the server settings when none exist.","Remember the last-served model so re-start is one click."],"tags":["local-api-server","model","configuration","react","typescript"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}