{"record":{"id":"641f4b1f225e646d","repo":"Mintplex-Labs/anything-llm","slug":"lemonade-failed-to-embed-error-type-error","errorCode":null,"errorMessage":"Lemonade Failed to embed: [${error.type}]: ${error.message}","messagePattern":"Lemonade Failed to embed: \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/EmbeddingEngines/lemonade/index.js","lineNumber":81,"sourceCode":"              });\n              return;\n            }\n            resolve({ data: result?.data, error: null });\n          })\n          .catch((e) => {\n            e.type =\n              e?.response?.data?.error?.code ||\n              e?.response?.status ||\n              \"failed_to_embed\";\n            e.message = e?.response?.data?.error?.message || e.message;\n            resolve({ data: [], error: e });\n          });\n      });\n\n      if (error) {\n        const errorMsg = `Lemonade Failed to embed: [${error.type}]: ${error.message}`;\n        this.log(errorMsg);\n        throw new Error(errorMsg);\n      }\n      allResults.push(...(data || []));\n      reportEmbeddingProgress(\n        Math.min(allResults.length, textChunks.length),\n        textChunks.length\n      );\n    }\n\n    return allResults.length > 0 &&\n      allResults.every((embd) => embd.hasOwnProperty(\"embedding\"))\n      ? allResults.map((embd) => embd.embedding)\n      : null;\n  }\n}\n\nmodule.exports = {\n  LemonadeEmbedder,\n};","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/lemonade/index.js#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the [type] segment — an HTTP code points at the server's response, 'failed_to_embed' usually means a transport-level failure","Confirm the model id in EMBEDDING_MODEL_PREF is downloaded and loaded in Lemonade (model must be running, not just listed)","Verify the Lemonade server is up at EMBEDDING_BASE_PATH (open its UI or hit its /models endpoint)","Retry the embedding — if it fails mid-run, restart the Lemonade server first","Update Lemonade to a build that supports the OpenAI embeddings route"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: model must be listed as loaded on the Lemonade server\nasync function lemonadeModelReady(openai, model) {\n  try {\n    const res = await openai.models.list();\n    return res.data.some((m) => m.id === model);\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const vectors = await embedder.embedTextInput(text);\n} catch (e) {\n  if (e.message.startsWith(\"Lemonade Failed to embed:\")) {\n    const m = e.message; // format: [type]: message\n    if (/\\[(404|400)\\]/.test(m)) { /* model not loaded — load it, then retry this document */ }\n    else if (/\\[failed_to_embed\\]/.test(m)) { /* transport/server down — restart Lemonade, retry once */ }\n    else throw e;\n  } else throw e;\n}","preventionTips":["Confirm the model is downloaded AND loaded (not merely listed) before starting a bulk embed","Keep the Lemonade server awake during long jobs — sleep/crash mid-run produces failed_to_embed types","Re-embed failed documents from scratch after fixing; the loop stops at the first failing chunk"],"tags":["lemonade","amd","embeddings","api-error","local-server"],"backgroundTag":"embedding-api-request-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}