HKUDS/nanobot · error · ImageGenerationError

AIHubMix image generation failed

Error message

AIHubMix image generation failed: {detail}

What it means

HTTP-error mapping in AIHubMix's _generate_with_client: the predictions endpoint returned a non-success status; the body's error detail is embedded as {detail}. Typically auth failure, invalid model path, or quota exhaustion on AIHubMix.

Solutions

  1. Read the embedded detail for AIHubMix's error message
  2. Verify the AIHubMix API key and quota
  3. Check that the model name maps to a valid AIHubMix model path
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at nanobot/providers/image_generation.py:538 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/4f53b24618f43f21. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/providers/image_generation.py:538

        model_path = _aihubmix_model_path(model)
        url = f"{self.api_base}/models/{model_path}/predictions"
        try:
            response = await self._http_post(
                url,
                headers={**headers, "Content-Type": "application/json"},
                body=body,
                client=client,
            )
        except httpx.TimeoutException as exc:
            raise ImageGenerationError("AIHubMix image generation timed out") from exc
        except httpx.RequestError as exc:
            raise ImageGenerationError(f"AIHubMix image generation request failed: {exc}") from exc

        try:
            response.raise_for_status()
        except httpx.HTTPStatusError as exc:
            detail = response.text[:500]
            raise ImageGenerationError(f"AIHubMix image generation failed: {detail}") from exc

        payload = _as_json_object(response.json()) or {}
        images = await _aihubmix_images_from_payload(payload, proxy=self.proxy)

        self._require_images(images, payload)

        return GeneratedImageResponse(images=images, content="", raw=payload)


def _http_error_detail(response: httpx.Response) -> str:
    """Extract a readable error message from an HTTP error response."""
    try:
        data = _as_json_object(response.json())
        if data is not None:
            err = _as_json_object(data.get("error"))
            if err is not None:
                message = err.get("message")
                return message if isinstance(message, str) else str(err)

View on GitHub (pinned to 42f37dc4c0)