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 LiteLLMEmbedder constructor when process.env.LITE_LLM_BASE_PATH is falsy (undefined/empty). LiteLLM proxies many providers behind a single OpenAI-compatible endpoint, so this library refuses to instantiate without that base URL because the openai SDK would have nowhere to route requests. It fails fast at construction rather than silently building a broken client.

Source

Thrown at server/utils/EmbeddingEngines/liteLLM/index.js:11

const {
  toChunks,
  maximumChunkLength,
  reportEmbeddingProgress,
} = require("../../helpers");

class LiteLLMEmbedder {
  constructor() {
    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.basePath = process.env.LITE_LLM_BASE_PATH;
    this.openai = new OpenAIApi({
      baseURL: this.basePath,
      apiKey: process.env.LITE_LLM_API_KEY ?? null,
    });
    this.model = process.env.EMBEDDING_MODEL_PREF || "text-embedding-ada-002";

    // Limit of how many strings we can process in a single pass to stay with resource or network limits
    this.maxConcurrentChunks = 500;
    this.embeddingMaxChunkLength = maximumChunkLength();
  }

  async embedTextInput(textInput) {
    const result = await this.embedChunks(
      Array.isArray(textInput) ? textInput : [textInput]
    );

View on GitHub (pinned to 526360e320)

Solutions

  1. Set LITE_LLM_BASE_PATH in .env to the LiteLLM proxy URL, e.g. LITE_LLM_BASE_PATH=http://localhost:4000/v1
  2. Restart the AnythingLLM process/container so the constructor re-reads .env
  3. Confirm the env file actually loaded (print process.env.LITE_LLM_BASE_PATH in a scratch script) to rule out a typo or wrong file

Example fix

// before
// .env has no LITE_LLM_BASE_PATH

// after
// .env
LITE_LLM_BASE_PATH=http://localhost:4000/v1
LITE_LLM_API_KEY=sk-...
Defensive patterns

Strategy: validation

Validate before calling

// run before selecting/instantiating the LiteLLM embedder
function canUseLiteLLM(env = process.env) {
  return typeof env.LITE_LLM_BASE_PATH === 'string' &&
         env.LITE_LLM_BASE_PATH.trim().length > 0;
}
if (!canUseLiteLLM()) {
  throw new Error('Missing LITE_LLM_BASE_PATH — set it before enabling LiteLLM embeddings.');
}

Type guard

// narrowing for a configured LiteLLM env
function isLiteLLMConfigured(env) {
  return typeof env.LITE_LLM_BASE_PATH === 'string' &&
    env.LITE_LLM_BASE_PATH.trim().startsWith('http');
}

Prevention

When it happens

Trigger: Instantiating `new LiteLLMEmbedder()` (typically when AnythingLLM boots an embedding job or the embedder is selected in system settings) with LITE_LLM_BASE_PATH unset or empty in .env. The check is a plain truthiness test on line 10, so an empty string or a value consisting only of whitespace after trimming would still pass, but undefined/'' will not.

Common situations: Switching the embedding engine to LiteLLM without updating .env; copying an .env.example that omits LITE_LLM_BASE_PATH; running in a fresh container/CI environment that did not receive the secret; a typo in the variable name (e.g. LITELLM_BASE_PATH).

Related errors


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