HKUDS/nanobot · error · ImageGenerationError

Ollama image generation failed

Error message

Ollama image generation failed (HTTP {response.status_code}): {detail}

What it means

Raised by OllamaImageGenerator.generate when the POST to {api_base}/generate returns a non-2xx status. It wraps httpx.HTTPStatusError and includes the status code plus the error body/detail extracted via _http_error_detail, meaning Ollama rejected the image-generation request (bad model, invalid params, server error).

Solutions

  1. Check that the Ollama server is running and reachable at api_base
  2. Verify the requested model is installed (ollama list) and supports image generation
  3. Inspect the detail text for the upstream Ollama error and correct request parameters (prompt, size options)
  4. Retry after fixing the server or request; check extra_headers/api_key if an auth proxy is used
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at nanobot/providers/image_generation.py:683 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/34787a684644cdd1. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/providers/image_generation.py:683

            "Content-Type": "application/json",
            **self.extra_headers,
        }
        if self.api_key:
            headers["Authorization"] = f"Bearer {self.api_key}"

        url = f"{self.api_base}/generate"
        response = await self._http_post(url, headers=headers, body=body)

        try:
            response.raise_for_status()
        except httpx.HTTPStatusError as exc:
            detail = _http_error_detail(response)
            logger.error(
                "Ollama image generation failed (HTTP {}): {}",
                response.status_code,
                detail,
            )
            raise ImageGenerationError(
                f"Ollama image generation failed (HTTP {response.status_code}): {detail}"
            ) from exc

        data = response.json()
        images = _ollama_images_from_payload(data)

        self._require_images(images, data)

        response_text = data.get("response")
        content = response_text if isinstance(response_text, str) else ""

        return GeneratedImageResponse(images=images, content=content, raw=data)


class GeminiImageGenerationClient(ImageGenerationProvider):
    """Async client for Gemini/Imagen image generation via the Generative Language API."""

    provider_name = "gemini"

View on GitHub (pinned to 42f37dc4c0)