Complex prompt (possible cause) leading to no image with Nano Banana Pro API

I have an app using Nano Banana Pro preview for generating language lessons with high dense text. Works fine quite a few times but then there are times when it just refuses to generate images and output no image. The code remains the same, just the behaviour of the service becomes erratic.

raise ValueError("No image data found in response parts")

ValueError: No image data found in response parts

raise ValueError(error_msg)

ValueError: No image data found. Finish reason: FinishReason.STOP

*“A bustling cafe scene in Garmisch-Partenkirchen, Bavaria, Germany. The cafe, “Cafe Wilder,” has large windows overlooking snow-capped mountains. Inside, three people are seated at a wooden table cluttered with maps, hiking brochures, and half-empty Apfelschorle glasses. One is a young man with a tablet showing a hiking app. The second is an older woman in traditional Bavarian Tracht, pointing at a map of the Alps. The third, presumably the learner’s persona, is looking thoughtfully at the maps. A chalkboard menu displays German cakes and coffee variations: “Kuchen: Schwarzwälder Kirschtorte, Apfelstrudel. Kaffee: Kaffee, Cappuccino, Latte Macchiato.” A sign near the entrance reads: “Wanderkarten erhältlich!” (Hiking maps available!). Outside, a couple in hiking gear, including functional jackets and sturdy boots, walks by. [LEFT BOX: dark background, white text] Exercise Instructions: Role-play with the AI as the learner. You are helping your friends plan a hiking trip in the Bavarian Alps. Express your preferences, make suggestions about routes and difficulty, and give advice on what to pack, considering weather and “Schicki Micki” locations. [RIGHT BOX: dark background, white text] Übungsanweisungen: Spiele mit der KI als Lernender. Du hilfst deinen Freunden bei der Planung einer Wanderung in den bayerischen Alpen. Äußere deine Vorlieben, mache Vorschläge zu Routen und Schwierigkeitsgrad, und gib Ratschläge, was man einpacken sollte, unter Berücksichtigung des Wetters und “Schicki Micki” Orten.”

The time it works I do get a good image.*

Question is why does it fail so many times.

Just 5 mins later I try the prompt and the api is just not working for this prompt, which is similar to the previous one.

*“A sun-drenched café terrace in Garmisch-Partenkirchen, Bavaria, Germany. In the foreground, a wooden table with a red-and-white checkered tablecloth. Spread on the table are various hiking maps of the Bavarian Alps, brochures for local attractions, and a half-eaten “Apfelstrudel” with a dusting of powdered sugar. Two partially filled glasses of “Apfelschorle” sit beside the food. Two young adults, Lena and Markus, are seated at the table, intensely studying the maps. Lena is wearing a modern hiking jacket and has her hair pulled back in a ponytail. Markus is sporting a traditional Bavarian “Trachten” jacket and a casual t-shirt. In the background, the majestic Zugspitze mountain looms, its peak dusted with snow. A sign on the café building reads “Café am Berg - Kaffee und Kuchen.” A waitress wearing a traditional “Dirndl” is approaching the table with a tray. Another poster on the wall advertises a “Wanderwoche” (hiking week) with guided tours. The vibe is very relaxed and a little “Schicki Micki”. [LEFT BOX: white text on black background] Exercise Instructions: You are helping Lena and Markus plan their hiking trip. Suggest an itinerary for their week, considering their interest in both challenging hikes and relaxed sightseeing. Express your preferences and give advice on specific trails and activities, incorporating vocabulary related to hiking gear and landscapes. [RIGHT BOX: white text on black background] Übungsanleitung: Sie helfen Lena und Markus bei der Planung ihrer Wanderreise. Schlagen Sie eine Reiseroute für ihre Woche vor, unter Berücksichtigung ihres Interesses an sowohl anspruchsvollen Wanderungen als auch entspanntem Sightseeing. Äußern Sie Ihre Vorlieben und geben Sie Ratschläge zu bestimmten Wanderwegen und Aktivitäten, unter Einbeziehung von Vokabular zu Wanderausrüstung und Landschaften.”

Very unrealiable API service for Nano Banana Pro and Gemini Live API. Hopefully they are stable once they are out from preview.*

Hi @DataSiens_AI ,

Could you try to Lower the Safety Filter in your code by setting safety_settings to BLOCK_ONLY_HIGH to see if the issue persists?

Thanks Sonali.
Today the API has been simply unreliable for me, tried the BLOCK_ONLY_HIGH filter and no image was being generated. Reverted to old set of filters and its the same behaviour. The reason I don’t doubt my code is because I do get images when the API works.

15:50 CET
google.genai.errors.ClientError: 429 RESOURCE_EXHAUSTED. {‘error’: {‘code’: 429, ‘message’: ‘Resource exhausted. Please try again later. Please refer to Error code 429  |  Generative AI on Vertex AI  |  Google Cloud Documentation for more details.’, ‘status’: ‘RESOURCE_EXHAUSTED’}}

File “/code/app/image_generator.py”, line 109, in _attempt_image_generation
raise ValueError(error_msg)
ValueError: No image data found. Finish reason: FinishReason.STOP

Same with the Gemini Live API

Backend error: received 1008 (policy violation) Publisher Model `projects/langtrak-adk-dev/locations/global/publishers/google/models/gemini-live-2.5-flash-native-audio` wa; then sent 1008 (policy violation) Publisher Model `projects/langtrak-adk-dev/locations/global/publishers/google/models/gemini-live-2.5-flash-native-audio` wa. Please check backend configuration.

Need to add that if I switch to gemini-2.5-flash-image - the same code works perfectly fine, except that the image quality is not what I need for my use case. Also when I generate images using AI studio, I rarely encounter errors with Nano Banana Pro, making this all about the resource allocation for Nano Banana Pro on Vertex AI.

Hi @DataSiens_AI ,

I have tested your prompt with safety_settings set to BLOCK_ONLY_HIGH and the response was Finish Reason: 1 Success! Image found.Could you please try again and let us know if the issue still persists? Thanks!

The vertex AI nano banana pro API is simply unusable and unreliable. Yesterday was lightening fast and today is throwing resource ex

INFO:backoff:Backing off _attempt_image_generation(…) for 0.5s (google.genai.errors.ClientError: 429 RESOURCE_EXHAUSTED. {‘error’: {‘code’: 429, ‘message’: ‘Resource exhausted. Please try again later. Please refer to Error code 429  |  Generative AI on Vertex AI  |  Google Cloud Documentation for more details.’, ‘status’: ‘RESOURCE_EXHAUSTED’}})

I’m now using the Gemini API and rarely running into these problems. I will switch back to the vertex API after some testing, which will take a few weeks.