Mintplex-Labs/anything-llm · error
No LocalAI Base Path was set.
Error message
No LocalAI Base Path was set.
What it means
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.
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.
Example fix
# before (.env) LOCAL_AI_MODEL_PREF=luna-ai-llama2 # after (.env) LOCAL_AI_BASE_PATH=http://127.0.0.1:8080/v1 LOCAL_AI_MODEL_PREF=luna-ai-llama2
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.LOCAL_AI_BASE_PATH) throw new Error("LOCAL_AI_BASE_PATH missing");
try { 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"); } Try / catch
try {
new LocalAiLLM(embedder, model);
} catch (e) {
if (/LocalAI Base Path/i.test(e.message)) return promptEnvSetup("LOCAL_AI_BASE_PATH");
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- KoboldCPP must have a valid base path to use for the api.
- No Lemonade API Base Path was set.
- No LMStudio API Base Path was set.
- LiteLLM must have a valid base path to use for the api.
- No embedding base path was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/c1db983ebc051b39.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/localAi/index.js:13
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
handleDefaultStreamResponseV2,
formatChatHistory,
} = require("../../helpers/chat/responses");
class LocalAiLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.LOCAL_AI_BASE_PATH)
throw new Error("No LocalAI Base Path was set.");
this.className = "LocalAiLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.openai = new OpenAIApi({
baseURL: process.env.LOCAL_AI_BASE_PATH,
apiKey: process.env.LOCAL_AI_API_KEY ?? null,
});
this.model = modelPreference || process.env.LOCAL_AI_MODEL_PREF;
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,
};
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;
}
View on GitHub (pinned to 3aec848f28)