Mintplex-Labs/anything-llm · error · Error

Lemonade Failed to embed

Error message

Lemonade Failed to embed: [${error.type}]: ${error.message}

What it means

Thrown from LemonadeEmbedder.embedChunks when a chunk request to the Lemonade server fails. Before throwing, each failure is normalized into type (HTTP error code or status, default 'failed_to_embed') and message (response body message), and the final text is formatted '[type]: message'. It is also written to the log, so the console shows the same string.

Solutions

  1. Check the [type] segment — an HTTP code points at the server's response, 'failed_to_embed' usually means a transport-level failure
  2. Confirm the model id in EMBEDDING_MODEL_PREF is downloaded and loaded in Lemonade (model must be running, not just listed)
  3. Verify the Lemonade server is up at EMBEDDING_BASE_PATH (open its UI or hit its /models endpoint)
  4. Retry the embedding — if it fails mid-run, restart the Lemonade server first
  5. Update Lemonade to a build that supports the OpenAI embeddings route
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: model must be listed as loaded on the Lemonade server
async function lemonadeModelReady(openai, model) {
  try {
    const res = await openai.models.list();
    return res.data.some((m) => m.id === model);
  } catch {
    return false;
  }
}

Try / catch

try {
  const vectors = await embedder.embedTextInput(text);
} catch (e) {
  if (e.message.startsWith("Lemonade Failed to embed:")) {
    const m = e.message; // format: [type]: message
    if (/\[(404|400)\]/.test(m)) { /* model not loaded — load it, then retry this document */ }
    else if (/\[failed_to_embed\]/.test(m)) { /* transport/server down — restart Lemonade, retry once */ }
    else throw e;
  } else throw e;
}

Prevention

When it happens

Trigger: EMBEDDING_MODEL_PREF names a model that is not downloaded/loaded in Lemonade (typically 404/400 from the server); the Lemonade server is stopped or restarted mid-embedding (fetch/ECONNREFUSED normalized to failed_to_embed); NPU/RAM pressure causing the server to error on a chunk; unsupported encoding_format or request shape on older Lemonade builds.

Common situations: Embedding documents right after picking a model id that was never pulled; laptop sleeping or Lemonade crashing during a large workspace embed; version mismatch between the Lemonade server and this OpenAI-compatible client.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/641f4b1f225e646d. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/EmbeddingEngines/lemonade/index.js:81

              });
              return;
            }
            resolve({ data: result?.data, error: null });
          })
          .catch((e) => {
            e.type =
              e?.response?.data?.error?.code ||
              e?.response?.status ||
              "failed_to_embed";
            e.message = e?.response?.data?.error?.message || e.message;
            resolve({ data: [], error: e });
          });
      });

      if (error) {
        const errorMsg = `Lemonade Failed to embed: [${error.type}]: ${error.message}`;
        this.log(errorMsg);
        throw new Error(errorMsg);
      }
      allResults.push(...(data || []));
      reportEmbeddingProgress(
        Math.min(allResults.length, textChunks.length),
        textChunks.length
      );
    }

    return allResults.length > 0 &&
      allResults.every((embd) => embd.hasOwnProperty("embedding"))
      ? allResults.map((embd) => embd.embedding)
      : null;
  }
}

module.exports = {
  LemonadeEmbedder,
};

View on GitHub (pinned to 3aec848f28)