{"record":{"id":"c9475694b4c67cd5","repo":"Mintplex-Labs/anything-llm","slug":"litellm-must-have-a-valid-base-path-to-use-for-the","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/AiProviders/liteLLM/index.js","lineNumber":14,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst {\n  handleDefaultStreamResponseV2,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\n\nclass LiteLLM {\n  constructor(embedder = null, modelPreference = null) {\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\n    this.className = \"LiteLLM\";\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 = modelPreference ?? process.env.LITE_LLM_MODEL_PREF ?? null;\n\n    if (!this.model) throw new Error(\"LiteLLM must have a valid model set.\");\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/liteLLM/index.js#L1-L32","documentation":"Thrown by the LiteLLM provider constructor when LITE_LLM_BASE_PATH is not set. LiteLLM is a proxy that routes requests to various backends, so the base path points to the LiteLLM proxy server. Without it, the OpenAI-compatible client has no endpoint to connect to. There is no constructor-parameter fallback for the base path.","triggerScenarios":"Instantiating `new LiteLLM(embedder, model)` (via getLLMProvider('litellm')) when process.env.LITE_LLM_BASE_PATH is undefined or empty. The check `if (!process.env.LITE_LLM_BASE_PATH)` fires before any client initialization.","commonSituations":"The LiteLLM proxy was selected as the LLM provider but the .env was not updated. A Docker deployment where the .env.example was copied but the LITE_LLM_BASE_PATH line was never uncommented. The proxy URL changed (e.g. from localhost to a remote host) and .env was not updated.","solutions":["Set LITE_LLM_BASE_PATH in .env to your LiteLLM proxy URL (e.g. 'http://127.0.0.1:4000') and restart.","Verify the LiteLLM proxy is running and responding at that URL.","If using Docker, ensure host.docker.internal is used instead of localhost if the proxy runs on the host."],"exampleFix":"// before: .env\n# LITE_LLM_BASE_PATH='http://127.0.0.1:4000'\n\n// after\nLITE_LLM_BASE_PATH='http://127.0.0.1:4000'","handlingStrategy":"validation","validationCode":"function validateLiteLLMBasePath() {\n  if (!process.env.LITE_LLM_BASE_PATH) {\n    throw new Error(\n      'LITE_LLM_BASE_PATH is not set. Configure it in .env (e.g. http://127.0.0.1:4000).'\n    );\n  }\n  return process.env.LITE_LLM_BASE_PATH;\n}\n\nvalidateLiteLLMBasePath();","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new LiteLLM(embedder, model);\n} catch (e) {\n  if (e.message.includes('base path')) {\n    console.error('Set LITE_LLM_BASE_PATH in .env to your LiteLLM proxy URL.');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Add a startup validator that checks LITE_LLM_BASE_PATH before the server accepts chat requests.","Verify the LiteLLM proxy is running before starting AnythingLLM.","Document the expected URL format in .env.example with Docker and bare-metal examples."],"tags":["litellm","configuration","env-var","constructor","base-path"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}