HKUDS/nanobot · error · ImageGenerationError
Zhipu image generation failed
Error message
Zhipu image generation failed: {detail} What it means
Raised in ZhipuImageGenerator._generate_with_client when the response has a non-2xx status. Wraps httpx.HTTPStatusError; detail carries the upstream error body, meaning Zhipu rejected the request (invalid API key, quota, or invalid parameters).
Solutions
- Verify the Zhipu API key (Authorization header)
- Inspect detail for quota or parameter errors and adjust the prompt/body
- Review extra_body overrides
- Retry after fixing the request
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at nanobot/providers/image_generation.py:1883 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/f9854679370ae5b9.
Report an issue: GitHub.
Appendix: source
Thrown at nanobot/providers/image_generation.py:1883
self,
client: httpx.AsyncClient,
*,
headers: dict[str, str],
body: dict[str, Any],
url: str,
) -> GeneratedImageResponse:
try:
response = await self._http_post(url, headers=headers, body=body, client=client)
except httpx.TimeoutException as exc:
raise ImageGenerationError("Zhipu image generation timed out") from exc
except httpx.RequestError as exc:
raise ImageGenerationError(f"Zhipu image generation request failed: {exc}") from exc
try:
response.raise_for_status()
except httpx.HTTPStatusError as exc:
detail = response.text[:500]
raise ImageGenerationError(f"Zhipu image generation failed: {detail}") from exc
payload = response.json()
images = await _zhipu_images_from_payload(payload, proxy=self.proxy)
self._require_images(images, payload)
return GeneratedImageResponse(images=images, content="", raw=payload)
def _zhipu_size(
aspect_ratio: str | None,
image_size: str | None,
) -> str:
"""Resolve aspect ratio / image_size to Zhipu size string.
Zhipu glm-image model supports: 1280x1280 (default), 1568x1056,
1056x1568, 1472x1088, 1088x1472, 1728x960, 960x1728.
"""View on GitHub (pinned to 42f37dc4c0)