{"record":{"id":"84d165890e360444","repo":"Mintplex-Labs/anything-llm","slug":"no-ollama-image-generation-base-path-was-set","errorCode":null,"errorMessage":"No Ollama image generation base path was set.","messagePattern":"No Ollama image generation base path was set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/ImageGenerators/ollama/index.js","lineNumber":6,"sourceCode":"const { BaseImageGenerator } = require(\"../base\");\n\nclass OllamaImageGenerator extends BaseImageGenerator {\n  constructor() {\n    if (!process.env.IMAGE_GEN_OLLAMA_BASE_PATH)\n      throw new Error(\"No Ollama image generation base path was set.\");\n    if (!process.env.IMAGE_GEN_MODEL_PREF)\n      throw new Error(\"No Ollama image generation model was set.\");\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    // Ollama serves image generation through its OpenAI-compatible `/v1`\n    // endpoint (experimental, macOS only).\n    const basePath = process.env.IMAGE_GEN_OLLAMA_BASE_PATH.replace(/\\/+$/, \"\");\n    super({\n      client: new OpenAIApi({\n        baseURL: `${basePath}/v1`,\n        apiKey: process.env.IMAGE_GEN_OLLAMA_AUTH_TOKEN || \"ollama\",\n      }),\n      model: process.env.IMAGE_GEN_MODEL_PREF,\n      className: \"OllamaImageGenerator\",\n    });\n  }\n\n  /**\n   * Ollama's OpenAI-compatible image endpoint does not implement image editing","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/ImageGenerators/ollama/index.js#L1-L24","documentation":"The OllamaImageGenerator constructor throws immediately when IMAGE_GEN_OLLAMA_BASE_PATH is unset or empty. The value is normalized (trailing slashes stripped) and suffixed with /v1 to build the OpenAI-compatible client base URL — Ollama serves experimental image generation through that endpoint. Fails fast at instantiation.","triggerScenarios":"Selecting Ollama as the image engine without setting IMAGE_GEN_OLLAMA_BASE_PATH; docker deployments where localhost would point at the container rather than the host; .env updated without a restart; typo in the variable name.","commonSituations":"Trying Ollama's experimental image generation (macOS-only per the code comment) for the first time; reusing the chat OLLAMA basePath variable but not the image-specific one.","solutions":["Set IMAGE_GEN_OLLAMA_BASE_PATH to the Ollama server root, e.g. http://localhost:11434 (the code appends /v1 itself).","From docker, use http://host.docker.internal:11434 instead of localhost.","Restart the server / recreate the container after saving.","Confirm your Ollama build actually exposes the OpenAI-compatible /v1/images endpoint (experimental, macOS)."],"exampleFix":"# .env — before\nIMAGE_GEN_ENGINE=ollama\n\n# .env — after\nIMAGE_GEN_ENGINE=ollama\nIMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434","handlingStrategy":"validation","validationCode":"if (!process.env.IMAGE_GEN_OLLAMA_BASE_PATH) {\n  throw new Error(\n    \"Ollama image engine selected but IMAGE_GEN_OLLAMA_BASE_PATH is missing.\"\n  );\n}\nconst { OllamaImageGenerator } = require(\"server/utils/ImageGenerators/ollama\");\nconst generator = new OllamaImageGenerator();","typeGuard":"function isOllamaImageConfigValid(env = process.env) {\n  return (\n    typeof env.IMAGE_GEN_OLLAMA_BASE_PATH === \"string\" &&\n    env.IMAGE_GEN_OLLAMA_BASE_PATH.length > 0\n  );\n}","tryCatchPattern":"try {\n  new OllamaImageGenerator();\n} catch (err) {\n  if (err.message.includes(\"Ollama image generation base path\")) {\n    // surface a settings error for IMAGE_GEN_OLLAMA_BASE_PATH\n  }\n}","preventionTips":["Point the base path at the Ollama root (the code appends /v1 itself).","In docker, use host.docker.internal rather than localhost for the host's Ollama.","Confirm the Ollama build exposes the experimental /v1 images endpoint before selecting the engine."],"tags":["ollama","image-generation","configuration","environment-variables"],"backgroundTag":"missing-env-var","analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}