{"record":{"id":"c1db983ebc051b39","repo":"Mintplex-Labs/anything-llm","slug":"no-localai-base-path-was-set","errorCode":null,"errorMessage":"No LocalAI Base Path was set.","messagePattern":"No LocalAI Base Path was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/localAi/index.js","lineNumber":13,"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 LocalAiLLM {\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.LOCAL_AI_BASE_PATH)\n      throw new Error(\"No LocalAI Base Path was set.\");\n\n    this.className = \"LocalAiLLM\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.openai = new OpenAIApi({\n      baseURL: process.env.LOCAL_AI_BASE_PATH,\n      apiKey: process.env.LOCAL_AI_API_KEY ?? null,\n    });\n    this.model = modelPreference || process.env.LOCAL_AI_MODEL_PREF;\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n  }\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/localAi/index.js#L1-L31","documentation":"Thrown by the LocalAiLLM constructor when LOCAL_AI_BASE_PATH is not set. The base path is the URL of the LocalAI server instance. There is no constructor-parameter fallback — it must come from the environment. The OpenAI-compatible client is initialized with this base path and an optional API key from LOCAL_AI_API_KEY.","triggerScenarios":"Instantiating `new LocalAiLLM(embedder, model)` (via getLLMProvider('localai')) when process.env.LOCAL_AI_BASE_PATH is undefined or empty. The check fires before any client initialization.","commonSituations":"LocalAI provider was selected in settings but .env was never updated. Docker deployment where .env.example was copied without uncommenting LOCAL_AI_BASE_PATH. The LocalAI server moved to a different host/port and .env wasn't updated.","solutions":["Set LOCAL_AI_BASE_PATH in .env to your LocalAI server URL (e.g. 'http://localhost:8080/v1') and restart.","Verify the LocalAI server is running and serving models at that endpoint.","If using Docker, use host.docker.internal instead of localhost."],"exampleFix":"// before: .env\n# LOCAL_AI_BASE_PATH='http://localhost:8080/v1'\n\n// after\nLOCAL_AI_BASE_PATH='http://localhost:8080/v1'","handlingStrategy":"validation","validationCode":"function validateLocalAIConfig() {\n  if (!process.env.LOCAL_AI_BASE_PATH) {\n    throw new Error(\n      'LOCAL_AI_BASE_PATH is not set. Configure it in .env (e.g. http://localhost:8080/v1).'\n    );\n  }\n  return process.env.LOCAL_AI_BASE_PATH;\n}\n\nvalidateLocalAIConfig();","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new LocalAiLLM(embedder, model);\n} catch (e) {\n  if (e.message.includes('Base Path')) {\n    console.error('Set LOCAL_AI_BASE_PATH in .env to your LocalAI server URL.');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Verify the LocalAI server is running and serving models before starting AnythingLLM.","Use host.docker.internal in Docker deployments.","Add a startup validator that checks LOCAL_AI_BASE_PATH for the selected provider."],"tags":["localai","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"}