{"record":{"id":"11eb380aa1d2ee31","repo":"Mintplex-Labs/anything-llm","slug":"litellm-failed-to-embed-error","errorCode":null,"errorMessage":"LiteLLM Failed to embed: ${error}","messagePattern":"LiteLLM Failed to embed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/EmbeddingEngines/liteLLM/index.js","lineNumber":92,"sourceCode":"        .flat();\n      if (errors.length > 0) {\n        let uniqueErrors = new Set();\n        errors.map((error) =>\n          uniqueErrors.add(`[${error.type}]: ${error.message}`)\n        );\n\n        return {\n          data: [],\n          error: Array.from(uniqueErrors).join(\", \"),\n        };\n      }\n      return {\n        data: results.map((res) => res?.data || []).flat(),\n        error: null,\n      };\n    });\n\n    if (!!error) throw new Error(`LiteLLM Failed to embed: ${error}`);\n    return data.length > 0 &&\n      data.every((embd) => embd.hasOwnProperty(\"embedding\"))\n      ? data.map((embd) => embd.embedding)\n      : null;\n  }\n}\n\nmodule.exports = {\n  LiteLLMEmbedder,\n};\n","sourceCodeStart":74,"sourceCodeEnd":103,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/liteLLM/index.js#L74-L103","documentation":"Thrown at the end of embedChunks after Promise.all when at least one concurrent batch request to the LiteLLM endpoint rejected. Each batch promise is caught and resolved with {data:[],error:e}, errors are deduplicated into a [type]: message string, and if any exist the whole sequence is aborted because partial embeddings would corrupt the vector store. The error.type is derived from response.data.error.code, the HTTP status, or defaults to 'failed_to_embed'.","triggerScenarios":"Any of the maxConcurrentChunks (500) batched POST /embeddings calls failing: HTTP 4xx from a wrong model name (EMBEDDING_MODEL_PREF not deployed in LiteLLM), 401 auth (missing/wrong LITE_LLM_API_KEY upstream), 5xx from the proxied provider, network timeout, or response payloads missing response.data.error.message so e.message is undefined.","commonSituations":"LiteLLM proxy model alias mistyped; upstream provider outage or rate limit; LiteLLM proxy restarted/under load so the 8MB POST limit is exceeded by a large batch; API key expired on the proxied provider; reverse proxy/gateway returning HTML error pages that break the openai SDK JSON parse.","solutions":["Read the bracketed [type] and message in the thrown string: a 401 means fix LITE_LLM_API_KEY, a 4xx model error means fix EMBEDDING_MODEL_PREF to match a LiteLLM-deployed alias","curl the LiteLLM proxy /v1/embeddings directly with the same model and key to isolate proxy vs provider failure","If batches are too large (near the ~8MB POST ceiling), lower the workload chunk size rather than maxConcurrentChunks","Restart the LiteLLM proxy and retry; check its logs for the upstream error"],"exampleFix":"// before\nEMBEDDING_MODEL_PREF=text-embedding-ada-002   // not deployed in LiteLLM\n\n// after\nEMBEDDING_MODEL_PREF=azure/ada-002            // alias configured in LiteLLM config.yaml","handlingStrategy":"retry","validationCode":"// sanity-check the model is deployed before a large ingest\nasync function litellmModelExists(openai, model) {\n  const res = await openai.models.list();\n  return res.data.some(m => m.id === model);\n}","typeGuard":"function isEmbeddingError(e) {\n  return e instanceof Error && /LiteLLM Failed to embed/.test(e.message);\n}","tryCatchPattern":"try {\n  return await embedder.embedChunks(chunks);\n} catch (e) {\n  if (/401|failed_to_embed/.test(e.message)) throw e;          // not transient\n  // 429/5xx are often transient — one bounded retry with backoff\n  await new Promise(r => setTimeout(r, 1000));\n  return await embedder.embedChunks(chunks);\n}","preventionTips":["Deduplicate model aliases in LiteLLM config.yaml so EMBEDDING_MODEL_PREF always resolves.","Cap batch size well under the LiteLLM ~8MB POST limit to avoid 413s on large chunks.","Log the upstream [type]: message so operators can map it to a provider cause."],"tags":["litellm","embedding","runtime","network","upstream"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}