Mintplex-Labs/anything-llm · error · Error

An error occurred while downloading the model

Error message

An error occurred while downloading the model

What it means

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.

Source

Thrown at server/endpoints/utils/lemonadeUtilsEndpoints.js:48

          "Cache-Control": "no-cache",
          Connection: "keep-alive",
        });

        const lemonadeResponse = await fetch(lemonadeUrl.toString(), {
          method: "POST",
          headers: {
            ...(!!process.env.LEMONADE_LLM_API_KEY
              ? { Authorization: `Bearer ${process.env.LEMONADE_LLM_API_KEY}` }
              : {}),
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            model_name: String(modelId),
            stream: true,
          }),
        });
        if (!lemonadeResponse.ok)
          throw new Error(
            lemonadeResponse.statusText ||
              "An error occurred while downloading the model"
          );
        const reader = lemonadeResponse.body.getReader();
        let done = false;
        let currentEvent = null;

        while (!done) {
          const { value, done: readerDone } = await reader.read();
          if (readerDone) done = true;

          const chunk = new TextDecoder("utf-8").decode(value);
          const lines = chunk.split("\n");
          for (const line of lines) {
            if (!line.trim()) continue;

            if (line.startsWith("event:")) {
              currentEvent = line.replace("event:", "").trim();

View on GitHub (pinned to 526360e320)

Solutions

  1. Confirm the Lemonade server is running and reachable at LEMONADE_LLM_BASE_PATH.
  2. If the server requires auth, set LEMONADE_LLM_API_KEY to a valid key.
  3. Validate the modelId is supported by the Lemonade instance.
  4. curl the /api/v1/pull endpoint directly to read the real status and body.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await downloadFromLemonade(modelId, basePath);
} catch (e) {
  logger.error('Lemonade pull HTTP error', { modelId, message: e.message });
  res.write(`data: ${JSON.stringify({ type: 'error', message: 'Lemonade server rejected the pull request.' })}\n\n`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/bce4c2ec3f9221d7. Report an issue: GitHub.