{"record":{"id":"22b4eceb5654accc","repo":"Mintplex-Labs/anything-llm","slug":"no-privatemode-base-path-was-set","errorCode":null,"errorMessage":"No Privatemode Base Path was set.","messagePattern":"No Privatemode Base Path was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/privatemode/index.js","lineNumber":21,"sourceCode":"  handleDefaultStreamResponseV2,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\n\nclass PrivatemodeLLM {\n  static contextWindows = {\n    \"leon-se/gemma-3-27b-it-fp8-dynamic\": 128000,\n    \"gemma-3-27b\": 128000,\n    \"qwen3-coder-30b-a3b\": 128000,\n    \"gpt-oss-120b\": 128000,\n    \"openai/gpt-oss-120b\": 128000,\n  };\n\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.PRIVATEMODE_LLM_BASE_PATH)\n      throw new Error(\"No Privatemode Base Path was set.\");\n\n    this.className = \"PrivatemodeLLM\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.client = new OpenAIApi({\n      baseURL: PrivatemodeLLM.parseBasePath(),\n      apiKey: null,\n    });\n\n    this.model = modelPreference || process.env.PRIVATEMODE_LLM_MODEL_PREF;\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n    this.log(","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/privatemode/index.js#L3-L39","documentation":"Thrown by the PrivatemodeLLM constructor when process.env.PRIVATEMODE_LLM_BASE_PATH is falsy. Privatemode is a self-hosted/local OpenAI-compatible server, so its base URL is mandatory; there is no default endpoint. The constructor then runs the value through parseBasePath() which appends /v1.","triggerScenarios":"Instantiating `new PrivatemodeLLM(...)` with PRIVATEMODE_LLM_BASE_PATH unset, empty, or whitespace-only. The variable must be the origin (and optionally path) of the local Privatemode inference server, e.g. http://127.0.0.1:8000.","commonSituations":"Privatemode container/process not yet started when AnythingLLM boots; the variable was named PRIVATEMODE_BASE_PATH instead of PRIVATEMODE_LLM_BASE_PATH; the env file was not reloaded after adding it; a docker-compose override omitted the mapping.","solutions":["Set PRIVATEMODE_LLM_BASE_PATH to the Privatemode server origin (e.g. http://127.0.0.1:8000) in server/.env and restart.","Confirm the Privatemode process is listening: `curl -s http://127.0.0.1:8000/v1/models`.","If behind Docker networking, use the service name/host reachable from the AnythingLLM container.","Restart AnythingLLM so the new env is loaded."],"exampleFix":"// before\n// PRIVATEMODE_LLM_BASE_PATH unset -> throws\nconst llm = new PrivatemodeLLM(embedder, \"gemma-3-27b\");\n\n// after\n// server/.env\n// PRIVATEMODE_LLM_BASE_PATH=http://127.0.0.1:8000\n// PRIVATEMODE_LLM_MODEL_PREF=gemma-3-27b\nconst llm = new PrivatemodeLLM(embedder, \"gemma-3-27b\");","handlingStrategy":"validation","validationCode":"function assertPrivatemodeBasePath() {\n  if (!process.env.PRIVATEMODE_LLM_BASE_PATH || !process.env.PRIVATEMODE_LLM_BASE_PATH.trim()) {\n    throw new Error(\"PRIVATEMODE_LLM_BASE_PATH missing — set to your Privatemode server origin (e.g. http://127.0.0.1:8000)\");\n  }\n}\nassertPrivatemodeBasePath();\nconst llm = new PrivatemodeLLM(embedder, modelPref);","typeGuard":"function hasPrivatemodeBasePath(env = process.env) {\n  return typeof env.PRIVATEMODE_LLM_BASE_PATH === \"string\" && env.PRIVATEMODE_LLM_BASE_PATH.trim().length > 0;\n}","tryCatchPattern":"let llm;\ntry {\n  llm = new PrivatemodeLLM(embedder, modelPref);\n} catch (e) {\n  if (/No Privatemode Base Path/i.test(e.message)) {\n    return { ok: false, reason: \"missing-base-path\" };\n  }\n  throw e;\n}","preventionTips":["Boot-time check that the Privatemode server is reachable (curl <base>/v1/models) before marking the provider ready.","Document that the value is an origin, not a model id.","When running AnythingLLM in Docker, use the host/docker-service address rather than 127.0.0.1.","Restart AnythingLLM after every .env change."],"tags":["configuration","env","llm-provider","privatemode","constructor","self-hosted"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}