{"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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/liteLLM/index.js#L74-L103","documentation":"Thrown from LiteLLMEmbedder.embedChunks after all chunk requests settle; failures are de-duplicated into a Set and joined with commas, so the text after the colon lists each distinct error the LiteLLM proxy returned. The class pushes up to 500 strings per batch, so a misconfigured proxy fails fast and loudly.","triggerScenarios":"401/403 because LITE_LLM_API_KEY is not a valid virtual key or lacks the embedding model; 404/BadRequest because EMBEDDING_MODEL_PREF is not a model or deployment name in the proxy's config.yaml; 429 because the key's budget, tpm/rpm limits, or upstream provider quota is exceeded; upstream provider auth failure (e.g. proxy's OPENAI_API_KEY invalid); proxy not running at LITE_LLM_BASE_PATH.","commonSituations":"LiteLLM gateway whose config.yaml was changed but the proxy not restarted; virtual keys with tight budgets during bulk re-embedding; routing to an Azure/OpenAI deployment whose deployed name differs from the model name; proxy listening on a different port than configured.","solutions":["Read each comma-separated entry — they are the LiteLLM proxy's error strings and name the exact cause","For 401/403, verify LITE_LLM_API_KEY against /key/info on the proxy and confirm it can call the model","For model errors, make sure EMBEDDING_MODEL_PREF matches a model_name/deployment in config.yaml and the proxy was restarted after edits","For 429s, raise or wait out the key budget/tpm limits, or reduce EMBEDDING_MODEL_MAX_CHUNK_LENGTH to soften request sizes","Confirm the proxy is reachable at LITE_LLM_BASE_PATH (curl the /models endpoint)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: proxy reachable and model routable before a 500-chunk batch\nasync function liteLLMReady(openai, model) {\n  try {\n    const res = await openai.embeddings.create({ model, input: [\"ping\"] });\n    return Array.isArray(res?.data?.[0]?.embedding);\n  } catch (e) {\n    console.error(\"LiteLLM pre-flight failed:\", e.status, e.message);\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const vectors = await embedder.embedTextInput(text);\n} catch (e) {\n  if (e.message.startsWith(\"LiteLLM Failed to embed:\")) {\n    const detail = e.message.slice(\"LiteLLM Failed to embed:\".length);\n    if (/401|403|auth/i.test(detail)) { /* fix LITE_LLM_API_KEY / virtual key budgets; no retry */ }\n    else if (/429|rate|budget/i.test(detail)) { /* wait out budget window or raise limits, then retry */ }\n    else if (/404|model/i.test(detail)) { /* align EMBEDDING_MODEL_PREF with config.yaml, restart proxy, retry */ }\n    else throw e;\n  } else throw e;\n}","preventionTips":["Run a one-input embedding smoke test against the proxy before bulk embedding","Restart the LiteLLM proxy after every config.yaml change — stale configs are a top cause of model-not-found here","Give the virtual key headroom (tpm/rpm/budget) for batch sizes of up to 500 inputs per request"],"tags":["litellm","proxy","embeddings","api-error","rate-limit","quota"],"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"}