{"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/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/liteLLM/index.js#L1-L29","documentation":"Thrown by the LiteLLMEmbedder constructor when process.env.LITE_LLM_BASE_PATH is falsy (undefined/empty). LiteLLM proxies many providers behind a single OpenAI-compatible endpoint, so this library refuses to instantiate without that base URL because the openai SDK would have nowhere to route requests. It fails fast at construction rather than silently building a broken client.","triggerScenarios":"Instantiating `new LiteLLMEmbedder()` (typically when AnythingLLM boots an embedding job or the embedder is selected in system settings) with LITE_LLM_BASE_PATH unset or empty in .env. The check is a plain truthiness test on line 10, so an empty string or a value consisting only of whitespace after trimming would still pass, but undefined/'' will not.","commonSituations":"Switching the embedding engine to LiteLLM without updating .env; copying an .env.example that omits LITE_LLM_BASE_PATH; running in a fresh container/CI environment that did not receive the secret; a typo in the variable name (e.g. LITELLM_BASE_PATH).","solutions":["Set LITE_LLM_BASE_PATH in .env to the LiteLLM proxy URL, e.g. LITE_LLM_BASE_PATH=http://localhost:4000/v1","Restart the AnythingLLM process/container so the constructor re-reads .env","Confirm the env file actually loaded (print process.env.LITE_LLM_BASE_PATH in a scratch script) to rule out a typo or wrong file"],"exampleFix":"// before\n// .env has no LITE_LLM_BASE_PATH\n\n// after\n// .env\nLITE_LLM_BASE_PATH=http://localhost:4000/v1\nLITE_LLM_API_KEY=sk-...","handlingStrategy":"validation","validationCode":"// run before selecting/instantiating the LiteLLM embedder\nfunction canUseLiteLLM(env = process.env) {\n  return typeof env.LITE_LLM_BASE_PATH === 'string' &&\n         env.LITE_LLM_BASE_PATH.trim().length > 0;\n}\nif (!canUseLiteLLM()) {\n  throw new Error('Missing LITE_LLM_BASE_PATH — set it before enabling LiteLLM embeddings.');\n}","typeGuard":"// narrowing for a configured LiteLLM env\nfunction isLiteLLMConfigured(env) {\n  return typeof env.LITE_LLM_BASE_PATH === 'string' &&\n    env.LITE_LLM_BASE_PATH.trim().startsWith('http');\n}","tryCatchPattern":null,"preventionTips":["Validate required env at app boot and fail with a clear, single message instead of at embedder construction.","Keep a single source of truth for embedding-engine env in system settings so the UI cannot select LiteLLM without persisting LITE_LLM_BASE_PATH.","Add a startup self-check that lists every provider whose required env is present."],"tags":["litellm","embedding","config","env","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}