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 LITE_LLM_BASE_PATH is unset. This embedder proxies embeddings through a self-hosted LiteLLM proxy instance using the OpenAI SDK, so the proxy URL is the one hard requirement — the API key (LITE_LLM_API_KEY) may even be null for unauthenticated proxies. Model defaults to text-embedding-ada-002 if EMBEDDING_MODEL_PREF is unset.

Solutions

  1. Set LITE_LLM_BASE_PATH to your running LiteLLM proxy URL, e.g. http://localhost:4000 (commonly with /v1 as the SDK appends /embeddings)
  2. Set LITE_LLM_API_KEY to a valid virtual key if your proxy enforces auth
  3. Set EMBEDDING_MODEL_PREF to a model name your proxy's config.yaml actually routes (deployment name)
  4. Restart the server after saving the settings

Example fix

# before
EMBEDDING_ENGINE=liteLLM

# after
EMBEDDING_ENGINE=liteLLM
LITE_LLM_BASE_PATH=http://localhost:4000/v1
LITE_LLM_API_KEY=sk-...
EMBEDDING_MODEL_PREF=text-embedding-ada-002
Defensive patterns

Strategy: validation

Validate before calling

function assertLiteLLMEmbedderConfigured() {
  if (!process.env.LITE_LLM_BASE_PATH) {
    throw new Error("Missing LITE_LLM_BASE_PATH — start your LiteLLM proxy and set its URL");
  }
  try { new URL(process.env.LITE_LLM_BASE_PATH); }
  catch { throw new Error("LITE_LLM_BASE_PATH must be a valid URL, e.g. http://localhost:4000/v1"); }
}
assertLiteLLMEmbedderConfigured();

Try / catch

try {
  const embedder = new LiteLLMEmbedder();
} catch (e) {
  if (e.message.includes("valid base path")) {
    // render proxy-URL input in settings; no retry — deterministic config failure
  }
  throw e;
}

Prevention

When it happens

Trigger: Choosing LiteLLM as the embedding engine without entering the proxy base URL; starting with EMBEDDING_ENGINE=liteLLM but no LITE_LLM_BASE_PATH; pointing the setting at the LiteLLM config.yaml instead of the running proxy's http URL; env var set in the wrong scope (container vs host).

Common situations: Teams standing up a LiteLLM proxy gateway and configuring only the LLM side in AnythingLLM; port confusion between the proxy (4000 by default) and the config file.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: 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 3aec848f28)