Mintplex-Labs/anything-llm · critical · Error

No Ollama image generation model was set.

Error message

No Ollama image generation model was set.

What it means

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.

Source

Thrown at server/utils/ImageGenerators/ollama/index.js:8

const { BaseImageGenerator } = require("../base");

class OllamaImageGenerator extends BaseImageGenerator {
  constructor() {
    if (!process.env.IMAGE_GEN_OLLAMA_BASE_PATH)
      throw new Error("No Ollama image generation base path was set.");
    if (!process.env.IMAGE_GEN_MODEL_PREF)
      throw new Error("No Ollama image generation model was set.");
    const { OpenAI: OpenAIApi } = require("openai");
    // Ollama serves image generation through its OpenAI-compatible `/v1`
    // endpoint (experimental, macOS only).
    const basePath = process.env.IMAGE_GEN_OLLAMA_BASE_PATH.replace(/\/+$/, "");
    super({
      client: new OpenAIApi({
        baseURL: `${basePath}/v1`,
        apiKey: process.env.IMAGE_GEN_OLLAMA_AUTH_TOKEN || "ollama",
      }),
      model: process.env.IMAGE_GEN_MODEL_PREF,
      className: "OllamaImageGenerator",
    });
  }

  async editImage({ prompt, images, signal }) {
    this.log(
      `Ollama does not support image editing. Dropping ${images.length} reference image(s) and generating from prompt only.`
    );

View on GitHub (pinned to 526360e320)

Solutions

  1. Set IMAGE_GEN_MODEL_PREF to an image-capable model id available in your Ollama instance (e.g. after `ollama pull <model>`).
  2. Confirm the model is actually pulled/loaded by Ollama.
  3. Restart the server after setting the variable.
  4. Remember IMAGE_GEN_MODEL_PREF is shared across image providers.

Example fix

# before
IMAGE_GEN_PROVIDER=ollama
IMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434
# (no model)

# after
IMAGE_GEN_PROVIDER=ollama
IMAGE_GEN_OLLAMA_BASE_PATH=http://localhost:11434
IMAGE_GEN_MODEL_PREF=llava
Defensive patterns

Strategy: validation

Validate before calling

function hasImageModel() {
  return typeof process.env.IMAGE_GEN_MODEL_PREF === 'string'
    && process.env.IMAGE_GEN_MODEL_PREF.trim().length > 0;
}
if (!hasImageModel()) {
  throw new Error('Set IMAGE_GEN_MODEL_PREF before using image generation.');
}

Type guard

function isImageModelSet() {
  return !!process.env.IMAGE_GEN_MODEL_PREF && process.env.IMAGE_GEN_MODEL_PREF.trim().length > 0;
}

Try / catch

try {
  generator = new OllamaImageGenerator();
} catch (e) {
  if (/No Ollama image generation model/.test(e.message)) {
    throw new Error('Set IMAGE_GEN_MODEL_PREF to a model available in your Ollama instance and restart.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Instantiating new OllamaImageGenerator() when process.env.IMAGE_GEN_MODEL_PREF is unset or empty.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/bb119c8a2288befb. Report an issue: GitHub.