Mintplex-Labs/anything-llm · critical · Error

GenericOpenAI must have a valid base path to use for the…

Error message

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

What it means

Thrown by the GenericOpenAiEmbedder constructor when EMBEDDING_BASE_PATH is unset. The 'Generic OpenAI' embedding engine points the OpenAI SDK at an arbitrary URL, so a base path is mandatory — without it there is no endpoint to call. Unlike the OpenAI engine, an API key is optional (GENERIC_OPEN_AI_EMBEDDING_API_KEY defaults to null); only the URL is required.

Solutions

  1. Set EMBEDDING_BASE_PATH to the full URL of the OpenAI-compatible endpoint (e.g. http://localhost:8080/v1)
  2. Make sure the URL points at the embeddings-capable root (usually includes /v1) — the SDK appends /embeddings
  3. Restart the server or re-save the embedding settings so the env var is re-read
  4. Confirm the target actually implements POST /embeddings before relying on it

Example fix

# before
EMBEDDING_ENGINE=generic-openai
EMBEDDING_MODEL_PREF=nomic-embed-text

# after
EMBEDDING_ENGINE=generic-openai
EMBEDDING_BASE_PATH=http://localhost:8080/v1
EMBEDDING_MODEL_PREF=nomic-embed-text
Defensive patterns

Strategy: validation

Validate before calling

function assertGenericOpenAiEmbedderConfigured() {
  if (!process.env.EMBEDDING_BASE_PATH) {
    throw new Error("Missing EMBEDDING_BASE_PATH for the Generic OpenAI embedding engine");
  }
  try {
    new URL(process.env.EMBEDDING_BASE_PATH); // catches typos like 'localhost:8080/v1'
  } catch {
    throw new Error("EMBEDDING_BASE_PATH is not a valid URL");
  }
}
assertGenericOpenAiEmbedderConfigured();

Try / catch

try {
  const embedder = new GenericOpenAiEmbedder();
} catch (e) {
  if (e.message.includes("valid base path")) {
    // surface a settings-form error guiding the user to the embedding config screen
  }
  throw e;
}

Prevention

When it happens

Trigger: Choosing the Generic OpenAI embedding provider in settings without entering a Base URL; setting EMBEDDING_ENGINE=generic-openai in env without EMBEDDING_BASE_PATH; clearing the base path field and saving; .env not reloaded after adding the variable.

Common situations: Pointing AnythingLLM at a self-hosted OpenAI-compatible server (LocalAI, LiteLLM, Ollama's /v1, vLLM, text-generation-webui) and forgetting the URL; pasting only the model name in the settings form; trailing into a fresh deploy where the embedding config was never completed.

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/c027bc4bea51688c. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/EmbeddingEngines/genericOpenAi/index.js:10

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

class GenericOpenAiEmbedder {
  constructor() {
    if (!process.env.EMBEDDING_BASE_PATH)
      throw new Error(
        "GenericOpenAI must have a valid base path to use for the api."
      );
    this.className = "GenericOpenAiEmbedder";
    const { OpenAI: OpenAIApi } = require("openai");
    this.basePath = process.env.EMBEDDING_BASE_PATH;
    this.openai = new OpenAIApi({
      baseURL: this.basePath,
      apiKey: process.env.GENERIC_OPEN_AI_EMBEDDING_API_KEY ?? null,
    });
    this.model = process.env.EMBEDDING_MODEL_PREF ?? null;
    this.embeddingMaxChunkLength = maximumChunkLength();

    // this.maxConcurrentChunks is delegated to the getter below.
    // Refer to your specific model and provider you use this class with to determine a valid maxChunkLength
    this.log(`Initialized ${this.model}`, {
      baseURL: this.basePath,
      maxConcurrentChunks: this.maxConcurrentChunks,
      embeddingMaxChunkLength: this.embeddingMaxChunkLength,

View on GitHub (pinned to 3aec848f28)