HKUDS/nanobot · error · ImageGenerationError

Ollama image generation does not support reference images

Error message

Ollama image generation does not support reference images

What it means

Capability guard in OllamaImageProvider.generate: reference_images were supplied, but the Ollama image-generation backend only supports text-to-image prompts and has no image-input path. Raised before any request is sent.

Solutions

  1. Drop the reference images and use a text-only prompt
  2. Use a provider that supports image-to-image (e.g. Gemini/Imagen or OpenRouter image models) for reference-image workflows
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/providers/image_generation.py:649 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/26198dc1cf9e5f8d. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/providers/image_generation.py:649

    def _resolve_base_url(self, api_base: str | None) -> str:
        if api_base:
            base = api_base.rstrip("/")
            if base.endswith("/v1"):
                return f"{base[:-3]}/api"
            return base
        return self._default_base_url()

    async def generate(
        self,
        *,
        prompt: str,
        model: str,
        reference_images: list[str] | None = None,
        aspect_ratio: str | None = None,
        image_size: str | None = None,
    ) -> GeneratedImageResponse:
        if reference_images:
            raise ImageGenerationError(
                "Ollama image generation does not support reference images"
            )

        width, height = _ollama_dimensions(aspect_ratio, image_size)
        body: dict[str, Any] = {
            "model": model,
            "prompt": prompt,
            "width": width,
            "height": height,
            "steps": 0,
        }
        body.update(self.extra_body)
        body["stream"] = False

        headers = {
            "Content-Type": "application/json",
            **self.extra_headers,
        }

View on GitHub (pinned to 42f37dc4c0)