Mintplex-Labs/anything-llm · critical · Error

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

Error message

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

What it means

Thrown in the GenericOpenAiEmbedder constructor when process.env.EMBEDDING_BASE_PATH is falsy. The base path is the OpenAI-compatible URL the generic provider will call. Note the key (GENERIC_OPEN_AI_EMBEDDING_API_KEY) is optional (defaulting to null), so only the base path is required to construct the embedder.

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

Solutions

  1. Set EMBEDDING_BASE_PATH to the OpenAI-compatible base URL (e.g. http://localhost:11434/v1 for Ollama, http://localhost:1234/v1 for LM Studio).
  2. If the upstream requires auth, also set GENERIC_OPEN_AI_EMBEDDING_API_KEY.
  3. Set EMBEDDING_MODEL_PREF to a model the upstream exposes, and restart the process.
  4. Verify the URL is reachable and OpenAI-compatible (GET /v1/models returns JSON).
Defensive patterns

Strategy: validation

Validate before calling

function assertGenericBasePath() {
  const u = process.env.EMBEDDING_BASE_PATH;
  if (!u) throw new Error('Missing env EMBEDDING_BASE_PATH');
  try { new URL(u); } catch { throw new Error(`EMBEDDING_BASE_PATH is not a valid URL: ${u}`); }
}
assertGenericBasePath();

Type guard

/** @param {string} url */
function isOpenAiCompatibleUrl(url) {
  try { return new URL(url).pathname.toLowerCase().includes('/v1'); }
  catch { return false; }
}

Try / catch

try {
  new GenericOpenAiEmbedder();
} catch (e) {
  if (/base path/i.test(e.message)) { /* prompt for EMBEDDING_BASE_PATH */ }
  throw e;
}

Prevention

When it happens

Trigger: Constructing the generic OpenAI embedder while EMBEDDING_BASE_PATH is unset; pointing it at a non-OpenAI-compatible URL; selecting the Generic OpenAI engine before configuring the upstream server URL.

Common situations: Self-hosted/local server (vLLM, Ollama OpenAI compat, LM Studio, LocalAI) whose URL was not saved; using EMBEDDING_BASE_PATH for the chat path but not embeddings; URL typed without scheme/host; reverse proxy URL changed.

Related errors


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