{"record":{"id":"c8bd50ff2ed9693e","repo":"Mintplex-Labs/anything-llm","slug":"no-ollama-base-path-was-set","errorCode":null,"errorMessage":"No Ollama Base Path was set.","messagePattern":"No Ollama Base Path was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/ollama/index.js","lineNumber":20,"sourceCode":"  writeResponseChunk,\n  clientAbortedHandler,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\nconst { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { Ollama } = require(\"ollama\");\nconst { v4: uuidv4 } = require(\"uuid\");\n\n// Docs: https://github.com/jmorganca/ollama/blob/main/docs/api.md\nclass OllamaAILLM {\n  /** @see OllamaAILLM.cacheContextWindows */\n  static modelContextWindows = {};\n\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.OLLAMA_BASE_PATH)\n      throw new Error(\"No Ollama Base Path was set.\");\n\n    this.className = \"OllamaAILLM\";\n    this.authToken = process.env.OLLAMA_AUTH_TOKEN;\n    this.basePath = process.env.OLLAMA_BASE_PATH;\n    this.model = modelPreference || process.env.OLLAMA_MODEL_PREF;\n    this.keepAlive = process.env.OLLAMA_KEEP_ALIVE_TIMEOUT\n      ? Number(process.env.OLLAMA_KEEP_ALIVE_TIMEOUT)\n      : 300; // Default 5-minute timeout for Ollama model loading.\n\n    const headers = this.authToken\n      ? { Authorization: `Bearer ${this.authToken}` }\n      : {};\n    this.client = new Ollama({\n      host: this.basePath,\n      headers: headers,\n      fetch: OllamaAILLM.applyOllamaFetch(),\n    });\n    this.embedder = embedder ?? new NativeEmbedder();","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/ollama/index.js#L2-L38","documentation":"Synchronous constructor guard. OllamaAILLM cannot be instantiated unless OLLAMA_BASE_PATH is set; the value is required to build the underlying Ollama client (host) used for every subsequent call. Thrown at 'new OllamaAILLM(...)' before any network activity.","triggerScenarios":"Instantiating OllamaAILLM (typically by the provider factory during a chat request or at boot) when process.env.OLLAMA_BASE_PATH is undefined or empty string.","commonSituations":".env file missing or not loaded; var typo'd as OLLAMA_HOST or OLLAMA_BASE_URL; fresh deployment where the Ollama provider was selected in the UI but the env was never written; docker-compose without the var passed through.","solutions":["Set OLLAMA_BASE_PATH to the Ollama API origin (e.g. http://127.0.0.1:11434) in .env.","Restart the AnythingLLM server so the new env is picked up.","Confirm via the UI: Settings > LLM Provider > Ollama shows a non-empty base path.","If using Docker, verify the env var is passed to the container and the Ollama address is reachable from inside it."],"exampleFix":"# before\n# (OLLAMA_BASE_PATH unset)\n\n# after - .env\nOLLAMA_BASE_PATH=http://127.0.0.1:11434","handlingStrategy":"validation","validationCode":"if (!process.env.OLLAMA_BASE_PATH || !process.env.OLLAMA_BASE_PATH.trim())\n  throw new Error('OLLAMA_BASE_PATH must be set before starting OllamaAILLM.');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate required env vars at boot and fail fast with a clear message.","Use the AnythingLLM UI provider settings to persist OLLAMA_BASE_PATH rather than relying on manual edits.","Include the var in docker-compose / container env so it is always present."],"tags":["ollama","configuration","env"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}