Mintplex-Labs/anything-llm · error

Image provider returned no image data.

Error message

Image provider returned no image data.

What it means

requestImage() got a 2xx from client.images.generate(), normalized string bodies through safeJsonParse (some providers like Ollama return x-ndjson, which the SDK hands back unparsed), and then found neither b64_json nor url on payload.data[0] — or no data array at all. The provider responded, but not in any recognizable OpenAI images shape.

Solutions

  1. Log the raw result from images.generate() before normalization to inspect the actual payload.
  2. Ensure the provider returns the OpenAI images.generate shape: { data: [{ b64_json | url }] }.
  3. Upgrade or align the provider version with the OpenAI images API contract.
  4. Pick a different image engine whose responses this code path understands.
Defensive patterns

Strategy: try-catch

Type guard

function isUsableImageGeneratePayload(payload) {
  const image = payload?.data?.[0];
  return Boolean(
    image &&
      ((typeof image.b64_json === "string" && image.b64_json.length > 0) ||
        (typeof image.url === "string" && image.url.length > 0))
  );
}

Try / catch

try {
  const image = await generator.generateImage({ prompt, size, signal });
} catch (err) {
  if (err.message === "Image provider returned no image data.") {
    // provider returned 2xx but no data[0].b64_json/url:
    // inspect the raw generate result and align the provider with the OpenAI images schema
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: An OpenAI-compatible server returning a nonstandard envelope; a provider streaming NDJSON whose first JSON line lacks data[0]; an empty data array; an error body delivered with status 200; malformed JSON that safeJsonParse turns into null.

Common situations: Ollama's experimental OpenAI-compatible image endpoint returning ndjson; custom gateways (LM Studio, comfy bridges) with their own schemas; provider version upgrades that change the response format.

Understand the failure class

Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@f92433b4ea (2026-08-18). Data as JSON: /api/errors/a36c46ebb8666d73. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/ImageGenerators/base.js:168

      },
      { signal: signal ?? undefined }
    );

    // Some OpenAI-compatible providers (e.g. Ollama) return the body with a
    // non-JSON content-type (`application/x-ndjson`), so the SDK hands back the
    // raw string unparsed. Normalize to an object before reading the image.
    const { safeJsonParse } = require("../http");
    const payload = typeof result === "string" ? safeJsonParse(result) : result;
    const image = payload?.data?.[0];
    if (image?.b64_json)
      return { buffer: Buffer.from(image.b64_json, "base64") };
    if (image?.url) {
      const res = await fetch(image.url, { signal: signal ?? null });
      if (!res.ok)
        throw new Error(`Failed to fetch generated image: ${res.status}`);
      return { buffer: Buffer.from(await res.arrayBuffer()) };
    }
    throw new Error("Image provider returned no image data.");
  }
}

module.exports = { BaseImageGenerator };

View on GitHub (pinned to f92433b4ea)