Gemini finishReason NO_IMAGE: Surface Image Failures in UI
Your Gemini image call returns HTTP 200 and no image. The reason is in `candidate.finishReason`: `NO_IMAGE` means the model produced nothing, `IMAGE_SAFETY` means the output tripped a safety filter. Both arrive as 200s, not errors β so your UI must classify the finish reason before it reads theβ¦
If your Gemini image call returns HTTP 200 with no image, check candidate.finishReason before anything else: NO_IMAGE means the model was expected to generate an image and produced nothing; IMAGE_SAFETY means the generated image was blocked by a safety filter. Neither throws β they arrive as successful responses, which is exactly why your UI shows a blank frame instead of an explanation. Below: the exact response shapes, why each fires, and a firebase_ai 5.0.0 Dart classifier (for Nano Banana image generation ) that turns both into friendly UI states. π¬ Watch: Nano Banana image-generation walkthrough focused on avoiding wasted generations β prompt discipline, reference images, and retry control. Partial problem-match (no finishReason-specific video found): watch the retry discipline β every blind regeneration it warns against is a call your new finishReason classifier would have explained. Data unavailable β± Data unavailable Β· Data unavailable β click to play inline, or watch on YouTube . What the failure looks like: gemini finishReason NO_IMAGE The confusing part is what you *don't* get: no 4xx, no exception, no error body. The raw REST shape of the failure: { "candidates": [{ "content": { "parts": [], "role": "model" }, "finishReason": "NO_IMAGE", "safetyRatings": [ ... ] }], "promptFeedback": { "safetyRatings": [ ... ] } } HTTP 200. An empty parts list. The entire diagnosis lives in that one enum string. The sibling you will meet just as often: { "candidates": [{ "finishReason": "IMAGE_SAFETY", "...": "..." }] } IMAGE_SAFETY = the model generated (or tried to generate) an image that tripped an output safety filter. NO_IMAGE = the model was expected to produce an image and failed to β moderation-adjacent, and developers report plainly safe prompts landing hereβ¦