Mintplex-Labs/anything-llm · critical · Error

No LocalAI Base Path was set.

Error message

No LocalAI Base Path was set.

What it means

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.

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 526360e320)

Solutions

  1. Set LOCAL_AI_BASE_PATH in .env to your LocalAI server URL (e.g. 'http://localhost:8080/v1') and restart.
  2. Verify the LocalAI server is running and serving models at that endpoint.
  3. If using Docker, use host.docker.internal instead of localhost.

Example fix

// before: .env
# LOCAL_AI_BASE_PATH='http://localhost:8080/v1'

// after
LOCAL_AI_BASE_PATH='http://localhost:8080/v1'
Defensive patterns

Strategy: validation

Validate before calling

function validateLocalAIConfig() {
  if (!process.env.LOCAL_AI_BASE_PATH) {
    throw new Error(
      'LOCAL_AI_BASE_PATH is not set. Configure it in .env (e.g. http://localhost:8080/v1).'
    );
  }
  return process.env.LOCAL_AI_BASE_PATH;
}

validateLocalAIConfig();

Try / catch

try {
  const llm = new LocalAiLLM(embedder, model);
} catch (e) {
  if (e.message.includes('Base Path')) {
    console.error('Set LOCAL_AI_BASE_PATH in .env to your LocalAI server URL.');
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/c1db983ebc051b39. Report an issue: GitHub.