{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","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  /**\n   * Ollama's OpenAI-compatible image endpoint does not implement image editing\n   * or accept reference images in any form, so there is nothing we can do with\n   * them - we surface a descriptive error instead of silently dropping them and","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/ImageGenerators/ollama/index.js#L1-L26","documentation":"The OllamaImageGenerator constructor throws immediately when IMAGE_GEN_MODEL_PREF is unset or empty. There is no default model for Ollama image generation, so the shared IMAGE_GEN_MODEL_PREF must hold the model tag exposed by the Ollama instance; it is passed as `model` to every images.generate call. Fails fast at instantiation.","triggerScenarios":"Selecting the Ollama image engine without setting IMAGE_GEN_MODEL_PREF; the variable was cleared when switching image engines (it is shared across engines); .env edited but the process not restarted.","commonSituations":"Users who configured only IMAGE_GEN_OLLAMA_BASE_PATH; switching engines and leaving IMAGE_GEN_MODEL_PREF empty because the previous engine had its own default.","solutions":["Set IMAGE_GEN_MODEL_PREF to an image-capable model tag available in your Ollama build.","Confirm the model id with `ollama list` / the Ollama API before configuring.","Restart the server / recreate the container after saving.","Remember the variable is shared across image engines — keep it valid for whichever engine is active."],"exampleFix":"# .env — before\nIMAGE_GEN_ENGINE=ollama\nIMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434\n\n# .env — after\nIMAGE_GEN_ENGINE=ollama\nIMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434\nIMAGE_GEN_MODEL_PREF=<ollama-image-model-tag>","handlingStrategy":"validation","validationCode":"if (!process.env.IMAGE_GEN_MODEL_PREF) {\n  throw new Error(\n    \"Ollama image engine selected but IMAGE_GEN_MODEL_PREF is missing.\"\n  );\n}\nconst { OllamaImageGenerator } = require(\"server/utils/ImageGenerators/ollama\");\nconst generator = new OllamaImageGenerator();","typeGuard":"function hasImageModelPref(env = process.env) {\n  return (\n    typeof env.IMAGE_GEN_MODEL_PREF === \"string\" &&\n    env.IMAGE_GEN_MODEL_PREF.length > 0\n  );\n}","tryCatchPattern":"try {\n  new OllamaImageGenerator();\n} catch (err) {\n  if (err.message.includes(\"Ollama image generation model\")) {\n    // prompt the user to select an image model available in their Ollama build\n  }\n}","preventionTips":["Validate IMAGE_GEN_MODEL_PREF whenever the image engine changes — it is shared state.","Offer only models the Ollama instance actually exposes.","Env-check at boot and report all missing image-gen variables together."],"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"}