{"record":{"id":"02541a9fc84402d0","repo":"Mintplex-Labs/anything-llm","slug":"litellm-must-have-a-valid-base-path-to-use-for-the-02541a","errorCode":null,"errorMessage":"LiteLLM must have a valid base path to use for the api.","messagePattern":"LiteLLM must have a valid base path to use for the api\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/liteLLM/index.js","lineNumber":11,"sourceCode":"const {\n  toChunks,\n  maximumChunkLength,\n  reportEmbeddingProgress,\n} = require(\"../../helpers\");\n\nclass LiteLLMEmbedder {\n  constructor() {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!process.env.LITE_LLM_BASE_PATH)\n      throw new Error(\n        \"LiteLLM must have a valid base path to use for the api.\"\n      );\n    this.basePath = process.env.LITE_LLM_BASE_PATH;\n    this.openai = new OpenAIApi({\n      baseURL: this.basePath,\n      apiKey: process.env.LITE_LLM_API_KEY ?? null,\n    });\n    this.model = process.env.EMBEDDING_MODEL_PREF || \"text-embedding-ada-002\";\n\n    // Limit of how many strings we can process in a single pass to stay with resource or network limits\n    this.maxConcurrentChunks = 500;\n    this.embeddingMaxChunkLength = maximumChunkLength();\n  }\n\n  async embedTextInput(textInput) {\n    const result = await this.embedChunks(\n      Array.isArray(textInput) ? textInput : [textInput]\n    );","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/liteLLM/index.js#L1-L29","documentation":"Thrown by the LiteLLMEmbedder constructor when LITE_LLM_BASE_PATH is unset. This embedder proxies embeddings through a self-hosted LiteLLM proxy instance using the OpenAI SDK, so the proxy URL is the one hard requirement — the API key (LITE_LLM_API_KEY) may even be null for unauthenticated proxies. Model defaults to text-embedding-ada-002 if EMBEDDING_MODEL_PREF is unset.","triggerScenarios":"Choosing LiteLLM as the embedding engine without entering the proxy base URL; starting with EMBEDDING_ENGINE=liteLLM but no LITE_LLM_BASE_PATH; pointing the setting at the LiteLLM config.yaml instead of the running proxy's http URL; env var set in the wrong scope (container vs host).","commonSituations":"Teams standing up a LiteLLM proxy gateway and configuring only the LLM side in AnythingLLM; port confusion between the proxy (4000 by default) and the config file.","solutions":["Set LITE_LLM_BASE_PATH to your running LiteLLM proxy URL, e.g. http://localhost:4000 (commonly with /v1 as the SDK appends /embeddings)","Set LITE_LLM_API_KEY to a valid virtual key if your proxy enforces auth","Set EMBEDDING_MODEL_PREF to a model name your proxy's config.yaml actually routes (deployment name)","Restart the server after saving the settings"],"exampleFix":"# before\nEMBEDDING_ENGINE=liteLLM\n\n# after\nEMBEDDING_ENGINE=liteLLM\nLITE_LLM_BASE_PATH=http://localhost:4000/v1\nLITE_LLM_API_KEY=sk-...\nEMBEDDING_MODEL_PREF=text-embedding-ada-002","handlingStrategy":"validation","validationCode":"function assertLiteLLMEmbedderConfigured() {\n  if (!process.env.LITE_LLM_BASE_PATH) {\n    throw new Error(\"Missing LITE_LLM_BASE_PATH — start your LiteLLM proxy and set its URL\");\n  }\n  try { new URL(process.env.LITE_LLM_BASE_PATH); }\n  catch { throw new Error(\"LITE_LLM_BASE_PATH must be a valid URL, e.g. http://localhost:4000/v1\"); }\n}\nassertLiteLLMEmbedderConfigured();","typeGuard":null,"tryCatchPattern":"try {\n  const embedder = new LiteLLMEmbedder();\n} catch (e) {\n  if (e.message.includes(\"valid base path\")) {\n    // render proxy-URL input in settings; no retry — deterministic config failure\n  }\n  throw e;\n}","preventionTips":["Boot the LiteLLM proxy before the app and record its URL in the same deploy step","Note this engine reads LITE_LLM_BASE_PATH, not EMBEDDING_BASE_PATH — keep provider-specific vars documented","Add a deploy-time curl of the proxy /models endpoint as a smoke test"],"tags":["litellm","proxy","env-var","configuration","base-url","constructor"],"backgroundTag":"missing-env-var","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"}