{"record":{"id":"aae637fdc9f8d2ae","repo":"HKUDS/nanobot","slug":"gemini-image-generation-failed-http-response-sta","errorCode":null,"errorMessage":"Gemini image generation failed (HTTP {response.status_code}): {detail}","messagePattern":"Gemini image generation failed \\(HTTP (.+?)\\): (.+?)","errorType":"exception","errorClass":"ImageGenerationError","httpStatus":null,"severity":"error","filePath":"nanobot/providers/image_generation.py","lineNumber":837,"sourceCode":"            \"contents\": [{\"role\": \"user\", \"parts\": parts}],\n            \"generationConfig\": generation_config,\n        }\n        body.update(self.extra_body)\n\n        url = f\"{self.api_base}/models/{model}:generateContent\"\n        headers = {\n            \"x-goog-api-key\": self.api_key or \"\",\n            \"Content-Type\": \"application/json\",\n            **self.extra_headers,\n        }\n        response = await self._http_post(url, headers=headers, body=body)\n\n        try:\n            response.raise_for_status()\n        except httpx.HTTPStatusError as exc:\n            detail = _http_error_detail(response)\n            logger.error(\"Gemini image generation failed (HTTP {}): {}\", response.status_code, detail)\n            raise ImageGenerationError(\n                f\"Gemini image generation failed (HTTP {response.status_code}): {detail}\"\n            ) from exc\n\n        data = _as_json_object(response.json()) or {}\n        images: list[str] = []\n        text_parts: list[str] = []\n        for candidate in _as_json_objects(data.get(\"candidates\")):\n            content = _as_json_object(candidate.get(\"content\")) or {}\n            for part in _as_json_objects(content.get(\"parts\")):\n                if \"text\" in part:\n                    text = part[\"text\"]\n                    if isinstance(text, str):\n                        text_parts.append(text)\n                inline = _as_json_object(part.get(\"inlineData\"))\n                if inline is not None:\n                    mime = inline.get(\"mimeType\", \"image/png\")\n                    b64 = inline.get(\"data\", \"\")\n                    if isinstance(mime, str) and isinstance(b64, str) and b64:","sourceCodeStart":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/providers/image_generation.py#L819-L855","documentation":"Error \"Gemini image generation failed (HTTP {response.status_code}): {detail}\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/providers/image_generation.py:837 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}