{"record":{"id":"bb119c8a2288befb","repo":"Mintplex-Labs/anything-llm","slug":"no-ollama-image-generation-model-was-set","errorCode":null,"errorMessage":"No Ollama image generation model was set.","messagePattern":"No Ollama image generation model was set\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/ImageGenerators/ollama/index.js","lineNumber":8,"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  async editImage({ prompt, images, signal }) {\n    this.log(\n      `Ollama does not support image editing. Dropping ${images.length} reference image(s) and generating from prompt only.`\n    );","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/ImageGenerators/ollama/index.js#L1-L26","documentation":"Thrown synchronously in the OllamaImageGenerator constructor after the base-path check. IMAGE_GEN_MODEL_PREF names the model Ollama will use for image generation via its /v1 endpoint; Ollama has no default here. This variable is shared across image providers.","triggerScenarios":"Instantiating new OllamaImageGenerator() when process.env.IMAGE_GEN_MODEL_PREF is unset or empty.","commonSituations":"Selecting Ollama image generation without specifying which pulled model to use; model not yet pulled into the Ollama instance; switching image providers and leaving the model field blank; env var missing in the container.","solutions":["Set IMAGE_GEN_MODEL_PREF to an image-capable model id available in your Ollama instance (e.g. after `ollama pull <model>`).","Confirm the model is actually pulled/loaded by Ollama.","Restart the server after setting the variable.","Remember IMAGE_GEN_MODEL_PREF is shared across image providers."],"exampleFix":"# before\nIMAGE_GEN_PROVIDER=ollama\nIMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434\n# (no model)\n\n# after\nIMAGE_GEN_PROVIDER=ollama\nIMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434\nIMAGE_GEN_MODEL_PREF=llava","handlingStrategy":"validation","validationCode":"function hasImageModel() {\n  return typeof process.env.IMAGE_GEN_MODEL_PREF === 'string'\n    && process.env.IMAGE_GEN_MODEL_PREF.trim().length > 0;\n}\nif (!hasImageModel()) {\n  throw new Error('Set IMAGE_GEN_MODEL_PREF before using image generation.');\n}","typeGuard":"function isImageModelSet() {\n  return !!process.env.IMAGE_GEN_MODEL_PREF && process.env.IMAGE_GEN_MODEL_PREF.trim().length > 0;\n}","tryCatchPattern":"try {\n  generator = new OllamaImageGenerator();\n} catch (e) {\n  if (/No Ollama image generation model/.test(e.message)) {\n    throw new Error('Set IMAGE_GEN_MODEL_PREF to a model available in your Ollama instance and restart.');\n  }\n  throw e;\n}","preventionTips":["Set IMAGE_GEN_MODEL_PREF to a model you have already `ollama pull`ed.","IMAGE_GEN_MODEL_PREF is shared across image providers — set it per active provider.","Validate required env vars together at startup.","Restart after .env changes."],"tags":["ollama","image-generation","configuration","missing-env","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}