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 by the GenericOpenAiLLM constructor when process.env.GENERIC_OPEN_AI_BASE_PATH is unset. This provider targets any OpenAI-compatible endpoint (LiteLLM, vLLM, Ollama's OpenAI shim, etc.), and the base path is the one piece of configuration it cannot guess — without it the OpenAI client has no baseURL.
Source
Thrown at server/utils/AiProviders/genericOpenAi/index.js:21
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
formatChatHistory,
writeResponseChunk,
clientAbortedHandler,
extractReasoningContent,
} = require("../../helpers/chat/responses");
const { v4: uuidv4 } = require("uuid");
const { toValidNumber } = require("../../http");
const { getAnythingLLMUserAgent } = require("../../../endpoints/utils");
const { attachmentToContentBlock } = require("../../helpers/attachments");
class GenericOpenAiLLM {
constructor(embedder = null, modelPreference = null) {
const { OpenAI: OpenAIApi } = require("openai");
if (!process.env.GENERIC_OPEN_AI_BASE_PATH)
throw new Error(
"GenericOpenAI must have a valid base path to use for the api."
);
this.className = "GenericOpenAiLLM";
this.basePath = process.env.GENERIC_OPEN_AI_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
apiKey: process.env.GENERIC_OPEN_AI_API_KEY ?? null,
defaultHeaders: {
"User-Agent": getAnythingLLMUserAgent(),
...GenericOpenAiLLM.parseCustomHeaders(),
},
});
this.model =
modelPreference ?? process.env.GENERIC_OPEN_AI_MODEL_PREF ?? null;
this.maxTokens = process.env.GENERIC_OPEN_AI_MAX_TOKENS
? toValidNumber(process.env.GENERIC_OPEN_AI_MAX_TOKENS, 1024)
: 1024;View on GitHub (pinned to 526360e320)
Solutions
- Set GENERIC_OPEN_AI_BASE_PATH to the OpenAI-compatible base URL including the version, e.g. http://localhost:1234/v1
- Confirm the endpoint is up and answers /models
- Restart AnythingLLM after editing .env
- If using a proxy (LiteLLM/vLLM), start it first and verify the path
Example fix
// before // .env: GENERIC_OPEN_AI_MODEL_PREF=local-model // but no base path // after // .env: // GENERIC_OPEN_AI_BASE_PATH=http://localhost:1234/v1 // GENERIC_OPEN_AI_MODEL_PREF=local-model
Defensive patterns
Strategy: validation
Validate before calling
function hasGenericBasePath() {
try {
const u = new URL(process.env.GENERIC_OPEN_AI_BASE_PATH);
return u.protocol.startsWith('http');
} catch { return false; }
}
if (!hasGenericBasePath()) {
throw new ConfigError('Set GENERIC_OPEN_AI_BASE_PATH (include /v1).');
} Prevention
- Validate the base path parses as an http(s) URL at startup
- Ping GET $BASE_PATH/models during provider setup to confirm reachability
- Require the /v1 (or equivalent) version segment
When it happens
Trigger: Constructing `new GenericOpenAiLLM(embedder, modelPreference)` while GENERIC_OPEN_AI_BASE_PATH is absent. Fires when the user selected the 'Generic OpenAI' provider but did not fill in the endpoint URL.
Common situations: Misunderstanding that Generic OpenAI needs the full base URL (e.g. http://host:8000/v1) not just a host; .env line missing; pointing to an endpoint that omits the /v1 suffix; proxy/LiteLLM not started.
Related errors
- No Foundry Base Path was set.
- No Gemini API key was set.
- GenericOpenAI must have a valid model set.
- No Gitee AI API key was set.
- No Groq API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/f73c48ae47b4b127.
Report an issue: GitHub.