Mintplex-Labs/anything-llm · critical · Error

LiteLLM must have a valid base path to use for the api.

Error message

LiteLLM must have a valid base path to use for the api.

What it means

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.

Source

Thrown at server/utils/AiProviders/liteLLM/index.js:14

const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
  LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
  handleDefaultStreamResponseV2,
  formatChatHistory,
} = require("../../helpers/chat/responses");

class LiteLLM {
  constructor(embedder = null, modelPreference = null) {
    const { OpenAI: OpenAIApi } = require("openai");
    if (!process.env.LITE_LLM_BASE_PATH)
      throw new Error(
        "LiteLLM must have a valid base path to use for the api."
      );

    this.className = "LiteLLM";
    this.basePath = process.env.LITE_LLM_BASE_PATH;
    this.openai = new OpenAIApi({
      baseURL: this.basePath,
      apiKey: process.env.LITE_LLM_API_KEY ?? null,
    });
    this.model = modelPreference ?? process.env.LITE_LLM_MODEL_PREF ?? null;

    if (!this.model) throw new Error("LiteLLM must have a valid model set.");
    this.limits = {
      history: this.promptWindowLimit() * 0.15,
      system: this.promptWindowLimit() * 0.15,
      user: this.promptWindowLimit() * 0.7,
    };

View on GitHub (pinned to 526360e320)

Solutions

  1. Set LITE_LLM_BASE_PATH in .env to your LiteLLM proxy URL (e.g. 'http://127.0.0.1:4000') and restart.
  2. Verify the LiteLLM proxy is running and responding at that URL.
  3. If using Docker, ensure host.docker.internal is used instead of localhost if the proxy runs on the host.

Example fix

// before: .env
# LITE_LLM_BASE_PATH='http://127.0.0.1:4000'

// after
LITE_LLM_BASE_PATH='http://127.0.0.1:4000'
Defensive patterns

Strategy: validation

Validate before calling

function validateLiteLLMBasePath() {
  if (!process.env.LITE_LLM_BASE_PATH) {
    throw new Error(
      'LITE_LLM_BASE_PATH is not set. Configure it in .env (e.g. http://127.0.0.1:4000).'
    );
  }
  return process.env.LITE_LLM_BASE_PATH;
}

validateLiteLLMBasePath();

Try / catch

try {
  const llm = new LiteLLM(embedder, model);
} catch (e) {
  if (e.message.includes('base path')) {
    console.error('Set LITE_LLM_BASE_PATH in .env to your LiteLLM proxy URL.');
    return null;
  }
  throw e;
}

Prevention

When it happens

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

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

Related errors


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