Mintplex-Labs/anything-llm · error · Error
TextGenWebUI must have a valid base path to use for the api.
Error message
TextGenWebUI must have a valid base path to use for the api.
What it means
Thrown by the TextGenWebUILLM constructor when process.env.TEXT_GEN_WEB_UI_BASE_PATH is falsy. TextGenWebUI is a self-hosted OpenAI-compatible server (text-generation-webui with the openai extension), so its base URL is mandatory and there is no default. Note the constructor takes only (embedder) — there is no model arg; this.model is set to null.
Source
Thrown at server/utils/AiProviders/textGenWebUI/index.js:14
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
handleDefaultStreamResponseV2,
formatChatHistory,
} = require("../../helpers/chat/responses");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
class TextGenWebUILLM {
constructor(embedder = null) {
const { OpenAI: OpenAIApi } = require("openai");
if (!process.env.TEXT_GEN_WEB_UI_BASE_PATH)
throw new Error(
"TextGenWebUI must have a valid base path to use for the api."
);
this.className = "TextGenWebUILLM";
this.basePath = process.env.TEXT_GEN_WEB_UI_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
apiKey: process.env.TEXT_GEN_WEB_UI_API_KEY ?? null,
});
this.model = null;
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,
};
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;View on GitHub (pinned to 526360e320)
Solutions
- Start the text-generation-webui OpenAI extension and set TEXT_GEN_WEB_UI_BASE_PATH to its base (e.g. http://127.0.0.1:5001/v1) in server/.env.
- Confirm reachability: `curl -s http://127.0.0.1:5001/v1/models`.
- If AnythingLLM is containerised, point at the host IP / docker service name, not 127.0.0.1.
- Restart AnythingLLM after saving .env.
Example fix
// before // TEXT_GEN_WEB_UI_BASE_PATH unset -> throws const llm = new TextGenWebUILLM(embedder); // after // server/.env // TEXT_GEN_WEB_UI_BASE_PATH=http://127.0.0.1:5001/v1 // TEXT_GEN_WEB_UI_MODEL_TOKEN_LIMIT=4096 const llm = new TextGenWebUILLM(embedder);
Defensive patterns
Strategy: validation
Validate before calling
function assertTextGenBasePath() {
const p = process.env.TEXT_GEN_WEB_UI_BASE_PATH;
if (!p || !p.trim()) {
throw new Error("TEXT_GEN_WEB_UI_BASE_PATH missing — start the text-generation-webui openai extension and set this (e.g. http://127.0.0.1:5001/v1)");
}
try { new URL(p); } catch { throw new Error(`TEXT_GEN_WEB_UI_BASE_PATH is not a valid URL: ${p}`); }
}
assertTextGenBasePath();
const llm = new TextGenWebUILLM(embedder); Type guard
function hasTextGenBasePath(env = process.env) {
if (typeof env.TEXT_GEN_WEB_UI_BASE_PATH !== "string" || !env.TEXT_GEN_WEB_UI_BASE_PATH.trim()) return false;
try { new URL(env.TEXT_GEN_WEB_UI_BASE_PATH); return true; } catch { return false; }
} Try / catch
let llm;
try {
llm = new TextGenWebUILLM(embedder);
} catch (e) {
if (/valid base path/i.test(e.message)) {
return { ok: false, reason: "missing-textgen-base-path" };
}
throw e;
} Prevention
- Boot-time probe the openai extension (GET <base>/models) and mark the provider unhealthy if unreachable.
- Document the openai-extension requirement; the base webui port alone is not enough.
- Use the docker-reachable host when AnythingLLM is containerised.
- Restart AnythingLLM after changing .env.
When it happens
Trigger: Instantiating `new TextGenWebUILLM(embedder)` with TEXT_GEN_WEB_UI_BASE_PATH unset/empty. The extension's URL (commonly http://127.0.0.1:5001/v1) must be configured before selecting this provider.
Common situations: text-generation-webui openai extension not started or started on a different port; variable named TEXT_GEN_WEB_UI_BASE_URL instead of _BASE_PATH; .env not reloaded; wrong host when AnythingLLM runs in a container separate from the webui host (127.0.0.1 vs the docker gateway).
Related errors
- No Privatemode Base Path was set.
- No NVIDIA NIM API Base Path was set.
- No Perplexity API key was set.
- No PPIO API key was set.
- No SambaNova API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e3bc824115df2cb1.
Report an issue: GitHub.