{"record":{"id":"bce4c2ec3f9221d7","repo":"Mintplex-Labs/anything-llm","slug":"an-error-occurred-while-downloading-the-model-bce4c2","errorCode":null,"errorMessage":"An error occurred while downloading the model","messagePattern":"An error occurred while downloading the model","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/endpoints/utils/lemonadeUtilsEndpoints.js","lineNumber":48,"sourceCode":"          \"Cache-Control\": \"no-cache\",\n          Connection: \"keep-alive\",\n        });\n\n        const lemonadeResponse = await fetch(lemonadeUrl.toString(), {\n          method: \"POST\",\n          headers: {\n            ...(!!process.env.LEMONADE_LLM_API_KEY\n              ? { Authorization: `Bearer ${process.env.LEMONADE_LLM_API_KEY}` }\n              : {}),\n            \"Content-Type\": \"application/json\",\n          },\n          body: JSON.stringify({\n            model_name: String(modelId),\n            stream: true,\n          }),\n        });\n        if (!lemonadeResponse.ok)\n          throw new Error(\n            lemonadeResponse.statusText ||\n              \"An error occurred while downloading the model\"\n          );\n        const reader = lemonadeResponse.body.getReader();\n        let done = false;\n        let currentEvent = null;\n\n        while (!done) {\n          const { value, done: readerDone } = await reader.read();\n          if (readerDone) done = true;\n\n          const chunk = new TextDecoder(\"utf-8\").decode(value);\n          const lines = chunk.split(\"\\n\");\n          for (const line of lines) {\n            if (!line.trim()) continue;\n\n            if (line.startsWith(\"event:\")) {\n              currentEvent = line.replace(\"event:\", \"\").trim();","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/utils/lemonadeUtilsEndpoints.js#L30-L66","documentation":"Thrown by POST /utils/lemonade/download-model when the Lemonade inference server's POST /api/v1/pull returns a non-OK HTTP status. The Error prefers lemonadeResponse.statusText and falls back to this string when statusText is empty. This is the HTTP-level failure counterpart to the streaming error in 132.","triggerScenarios":"LEMONADE_LLM_BASE_PATH is wrong or the Lemonade server is down; LEMONADE_LLM_API_KEY is missing/invalid and the server rejects with 401/403; the modelId is not pullable; the server returned an error status with an empty reason phrase.","commonSituations":"Lemonade server not started; API key env var unset on the AnythingLLM side while the server requires auth; base path typo; Lemonade version that returns bare status codes.","solutions":["Confirm the Lemonade server is running and reachable at LEMONADE_LLM_BASE_PATH.","If the server requires auth, set LEMONADE_LLM_API_KEY to a valid key.","Validate the modelId is supported by the Lemonade instance.","curl the /api/v1/pull endpoint directly to read the real status and body."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await downloadFromLemonade(modelId, basePath);\n} catch (e) {\n  logger.error('Lemonade pull HTTP error', { modelId, message: e.message });\n  res.write(`data: ${JSON.stringify({ type: 'error', message: 'Lemonade server rejected the pull request.' })}\\n\\n`);\n}","preventionTips":["Confirm LEMONADE_LLM_BASE_PATH and the server is up before pulling.","Set LEMONADE_LLM_API_KEY when the server enforces auth.","curl /api/v1/pull manually to read the real status/body."],"tags":["lemonade","model-download","network","authentication"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}