{"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":null,"httpStatus":null,"severity":"error","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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/localAi/index.js#L1-L31","documentation":"LocalAiLLM's constructor throws when LOCAL_AI_BASE_PATH is unset. LocalAI is a self-hosted, OpenAI-compatible drop-in server; this URL is the OpenAI SDK baseURL (LOCAL_AI_API_KEY is optional, defaulting to null). The check is eager at provider construction, and — unlike some siblings — no default model throw follows: LOCAL_AI_MODEL_PREF is read with || and may stay undefined, deferring failure to the HTTP call.","triggerScenarios":"Selecting LocalAI as the LLM provider while LOCAL_AI_BASE_PATH is missing from the server env: LocalAI not running or installed yet, wrong port for the installation (common ports vary: 8080 for the binary/docker), or Docker localhost-vs-host networking confusion.","commonSituations":"Fresh LocalAI deployments where the user configured only the model name; reverse-proxy setups where the public URL was never copied into .env; mixed-up variable names after migrating from LiteLLM/Ollama configs; containerized AnythingLLM pointing at 127.0.0.1 which refers to the container itself.","solutions":["Confirm LocalAI answers: curl http://127.0.0.1:8080/v1/models.","Set LOCAL_AI_BASE_PATH to that base (e.g., http://127.0.0.1:8080/v1) in the backend .env.","Docker: use http://host.docker.internal:8080/v1 or the compose service name.","Also set LOCAL_AI_MODEL_PREF (required for requests even though the constructor won't complain) and LOCAL_AI_API_KEY if enabled; then restart."],"exampleFix":"# before (.env)\nLOCAL_AI_MODEL_PREF=luna-ai-llama2\n\n# after (.env)\nLOCAL_AI_BASE_PATH=http://127.0.0.1:8080/v1\nLOCAL_AI_MODEL_PREF=luna-ai-llama2","handlingStrategy":"validation","validationCode":"if (!process.env.LOCAL_AI_BASE_PATH) throw new Error(\"LOCAL_AI_BASE_PATH missing\");\ntry { new URL(process.env.LOCAL_AI_BASE_PATH); } catch { throw new Error(\"LOCAL_AI_BASE_PATH must be a valid URL, e.g. http://127.0.0.1:8080/v1\"); }","typeGuard":null,"tryCatchPattern":"try {\n  new LocalAiLLM(embedder, model);\n} catch (e) {\n  if (/LocalAI Base Path/i.test(e.message)) return promptEnvSetup(\"LOCAL_AI_BASE_PATH\");\n  throw e;\n}","preventionTips":["Verify LocalAI is up (curl /v1/models) before selecting the provider.","Configure LOCAL_AI_BASE_PATH and LOCAL_AI_MODEL_PREF together — the constructor won't flag a missing model, but every request will fail.","Docker: use host.docker.internal or the service name for locally hosted LocalAI."],"tags":["localai","anythingllm","local-llm","env-var","base-url","configuration"],"backgroundTag":"missing-base-url","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"}