{"record":{"id":"c027bc4bea51688c","repo":"Mintplex-Labs/anything-llm","slug":"genericopenai-must-have-a-valid-base-path-to-use-f-c027bc","errorCode":null,"errorMessage":"GenericOpenAI must have a valid base path to use for the api.","messagePattern":"GenericOpenAI must have a valid base path to use for the api\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/genericOpenAi/index.js","lineNumber":10,"sourceCode":"const {\n  toChunks,\n  maximumChunkLength,\n  reportEmbeddingProgress,\n} = require(\"../../helpers\");\n\nclass GenericOpenAiEmbedder {\n  constructor() {\n    if (!process.env.EMBEDDING_BASE_PATH)\n      throw new Error(\n        \"GenericOpenAI must have a valid base path to use for the api.\"\n      );\n    this.className = \"GenericOpenAiEmbedder\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.basePath = process.env.EMBEDDING_BASE_PATH;\n    this.openai = new OpenAIApi({\n      baseURL: this.basePath,\n      apiKey: process.env.GENERIC_OPEN_AI_EMBEDDING_API_KEY ?? null,\n    });\n    this.model = process.env.EMBEDDING_MODEL_PREF ?? null;\n    this.embeddingMaxChunkLength = maximumChunkLength();\n\n    // this.maxConcurrentChunks is delegated to the getter below.\n    // Refer to your specific model and provider you use this class with to determine a valid maxChunkLength\n    this.log(`Initialized ${this.model}`, {\n      baseURL: this.basePath,\n      maxConcurrentChunks: this.maxConcurrentChunks,\n      embeddingMaxChunkLength: this.embeddingMaxChunkLength,","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/genericOpenAi/index.js#L1-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","If the upstream requires auth, also set GENERIC_OPEN_AI_EMBEDDING_API_KEY.","Set EMBEDDING_MODEL_PREF to a model the upstream exposes, and restart the process.","Verify the URL is reachable and OpenAI-compatible (GET /v1/models returns JSON)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertGenericBasePath() {\n  const u = process.env.EMBEDDING_BASE_PATH;\n  if (!u) throw new Error('Missing env EMBEDDING_BASE_PATH');\n  try { new URL(u); } catch { throw new Error(`EMBEDDING_BASE_PATH is not a valid URL: ${u}`); }\n}\nassertGenericBasePath();","typeGuard":"/** @param {string} url */\nfunction isOpenAiCompatibleUrl(url) {\n  try { return new URL(url).pathname.toLowerCase().includes('/v1'); }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  new GenericOpenAiEmbedder();\n} catch (e) {\n  if (/base path/i.test(e.message)) { /* prompt for EMBEDDING_BASE_PATH */ }\n  throw e;\n}","preventionTips":["Point EMBEDDING_BASE_PATH at an OpenAI-compatible /v1 URL.","Verify GET <base>/models returns JSON before embedding.","Set GENERIC_OPEN_AI_EMBEDDING_API_KEY if the upstream requires auth."],"tags":["generic-openai","embeddings","config","env","local-llm","startup"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}