{"record":{"id":"f73c48ae47b4b127","repo":"Mintplex-Labs/anything-llm","slug":"genericopenai-must-have-a-valid-base-path-to-use-f","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/AiProviders/genericOpenAi/index.js","lineNumber":21,"sourceCode":"const {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst {\n  formatChatHistory,\n  writeResponseChunk,\n  clientAbortedHandler,\n  extractReasoningContent,\n} = require(\"../../helpers/chat/responses\");\nconst { v4: uuidv4 } = require(\"uuid\");\nconst { toValidNumber } = require(\"../../http\");\nconst { getAnythingLLMUserAgent } = require(\"../../../endpoints/utils\");\nconst { attachmentToContentBlock } = require(\"../../helpers/attachments\");\n\nclass GenericOpenAiLLM {\n  constructor(embedder = null, modelPreference = null) {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!process.env.GENERIC_OPEN_AI_BASE_PATH)\n      throw new Error(\n        \"GenericOpenAI must have a valid base path to use for the api.\"\n      );\n\n    this.className = \"GenericOpenAiLLM\";\n    this.basePath = process.env.GENERIC_OPEN_AI_BASE_PATH;\n    this.openai = new OpenAIApi({\n      baseURL: this.basePath,\n      apiKey: process.env.GENERIC_OPEN_AI_API_KEY ?? null,\n      defaultHeaders: {\n        \"User-Agent\": getAnythingLLMUserAgent(),\n        ...GenericOpenAiLLM.parseCustomHeaders(),\n      },\n    });\n    this.model =\n      modelPreference ?? process.env.GENERIC_OPEN_AI_MODEL_PREF ?? null;\n    this.maxTokens = process.env.GENERIC_OPEN_AI_MAX_TOKENS\n      ? toValidNumber(process.env.GENERIC_OPEN_AI_MAX_TOKENS, 1024)\n      : 1024;","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/genericOpenAi/index.js#L3-L39","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n// .env: GENERIC_OPEN_AI_MODEL_PREF=local-model   // but no base path\n\n// after\n// .env:\n//   GENERIC_OPEN_AI_BASE_PATH=http://localhost:1234/v1\n//   GENERIC_OPEN_AI_MODEL_PREF=local-model","handlingStrategy":"validation","validationCode":"function hasGenericBasePath() {\n  try {\n    const u = new URL(process.env.GENERIC_OPEN_AI_BASE_PATH);\n    return u.protocol.startsWith('http');\n  } catch { return false; }\n}\nif (!hasGenericBasePath()) {\n  throw new ConfigError('Set GENERIC_OPEN_AI_BASE_PATH (include /v1).');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["generic-openai","configuration","environment-variables","openai-compatible","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}