{"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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/genericOpenAi/index.js#L1-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set EMBEDDING_BASE_PATH to the full URL of the OpenAI-compatible endpoint (e.g. http://localhost:8080/v1)","Make sure the URL points at the embeddings-capable root (usually includes /v1) — the SDK appends /embeddings","Restart the server or re-save the embedding settings so the env var is re-read","Confirm the target actually implements POST /embeddings before relying on it"],"exampleFix":"# before\nEMBEDDING_ENGINE=generic-openai\nEMBEDDING_MODEL_PREF=nomic-embed-text\n\n# after\nEMBEDDING_ENGINE=generic-openai\nEMBEDDING_BASE_PATH=http://localhost:8080/v1\nEMBEDDING_MODEL_PREF=nomic-embed-text","handlingStrategy":"validation","validationCode":"function assertGenericOpenAiEmbedderConfigured() {\n  if (!process.env.EMBEDDING_BASE_PATH) {\n    throw new Error(\"Missing EMBEDDING_BASE_PATH for the Generic OpenAI embedding engine\");\n  }\n  try {\n    new URL(process.env.EMBEDDING_BASE_PATH); // catches typos like 'localhost:8080/v1'\n  } catch {\n    throw new Error(\"EMBEDDING_BASE_PATH is not a valid URL\");\n  }\n}\nassertGenericOpenAiEmbedderConfigured();","typeGuard":null,"tryCatchPattern":"try {\n  const embedder = new GenericOpenAiEmbedder();\n} catch (e) {\n  if (e.message.includes(\"valid base path\")) {\n    // surface a settings-form error guiding the user to the embedding config screen\n  }\n  throw e;\n}","preventionTips":["Validate that EMBEDDING_BASE_PATH parses as a URL before saving embedding settings","Health-check the endpoint (GET /models) when the user saves the form, not at first embed","Document for your team which env vars each embedding engine requires — they differ per engine"],"tags":["generic-openai","env-var","configuration","base-url","constructor"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}