Skip to main content

Nano Banana Pro Errors & Troubleshooting: Which Codes to Retry

Nano Banana Pro (gemini-3-pro-image) error codes split three ways: retry 429 and 5xx with backoff, fix 400–404 first, and rewrite prompts for IMAGE_SAFETY.

LaoZhang AI TeamPublishedUpdated 25 min read
On this page
Nano Banana Pro troubleshooting overview for quota errors, server failures and safety response fields

A failed Nano Banana Pro (gemini-3-pro-image) call falls into one of three groups. Rate limits (429) and server errors (500, 503, 504) are temporary, so retry them with exponential backoff and a cap on attempts, then fall back to Nano Banana 2.1. Request errors (400, 401, 402, 403, 404) will fail the same way every time, so fix the key, billing, parameter or model ID before you send anything again. Safety blocks arrive as HTTP 200 with finishReason: SAFETY or IMAGE_SAFETY, or with promptFeedback.blockReason, and only a changed prompt or setting helps.

Updated October 8, 2026. The error table now says which codes come from the Interactions API and which from the classic generateContent endpoint, and "API key not valid" is listed as the 400 it actually returns rather than a 403. The free-tier RPM figures are gone: Google's image models have no free API tier. Nano Banana 2.1 (gemini-nano-banana-2.1, generally available since October 6, 2026) replaces Nano Banana 2 as the fallback model. The gemini-2.5-flash-image shutdown date is now shown as the conflict it is on Google's own pages.

Nano Banana Pro errors at a glance: retry, fix or rewrite

  • 429 (RESOURCE_EXHAUSTED, or rate_limit_exceeded, quota_exceeded, too_many_requests on the Interactions API) means a per-minute limit, a daily quota or a 10-minute spend cap. Back off for per-minute limits; daily quotas reset at midnight Pacific time.
  • 503 (UNAVAILABLE / service_unavailable, "The model is overloaded") is Google's capacity. Retry with backoff, then fall back to gemini-nano-banana-2.1. Google publishes no recovery time.
  • 400 covers malformed requests, wrong parameters such as a lowercase 1k, and, on generateContent, an invalid key ("API key not valid"). The Interactions API reports a bad key as 401 authentication. Neither is worth retrying.
  • 402 payment_required means your Prepay credit balance is at $0. Google says don't retry until you add credits.
  • 404 model_not_found usually means old code still sends a preview ID such as gemini-3-pro-image-preview, shut down on June 25, 2026.
  • SAFETY blocks come with safetyRatings for four adjustable categories. IMAGE_SAFETY has no documented setting, so rewrite the prompt. blockReason: OTHER gives no reason at all; see Nano Banana 2 blockReason OTHER: What It Means and What to Check.

Quick Diagnosis: Identify Your Nano Banana Pro Error in 30 Seconds

Diagnostic map connecting HTTP status and response fields to the next action

Start with two things: the HTTP status and the endpoint you called. Google's Gemini API errors reference (last updated September 20, 2026) lists the snake_case codes returned by the Interactions API (client.interactions.create), such as invalid_request or model_not_found, in an error.code field. The classic generateContent endpoint (models/gemini-3-pro-image:generateContent, or client.models.generate_content in the SDK) still returns a numeric error.code plus a gRPC-style error.status such as INVALID_ARGUMENT, RESOURCE_EXHAUSTED or UNAVAILABLE. Same HTTP status, different names, so search your logs for the one your surface uses. For a longer walkthrough, see the step-by-step debugging workflow.

What you seeHTTPSurfaceWhat it meansRetry?Fix
RESOURCE_EXHAUSTED429generateContentPer-minute limit, daily quota or 10-minute spend capYes, with backoffRead the message for which limit; slow down or wait for the reset
rate_limit_exceeded, too_many_requests429InteractionsPer-minute or per-second request or token limitYes, with backoffLower concurrency
quota_exceeded429InteractionsDaily quota used upNot until the resetWait for midnight Pacific time or request an increase
UNAVAILABLE / service_unavailable, "The model is overloaded"503BothModel at capacityYes, with backoffFall back to gemini-nano-banana-2.1
INTERNAL / api_error500BothUnexpected server errorYes, a few timesContact support if it persists
Bad Gateway502AnyUpstream routing failureYesRetry with backoff
DEADLINE_EXCEEDED / deadline_exceeded504BothRequest did not finish in timeYesRemove a short client timeout or raise it
INVALID_ARGUMENT / invalid_request, parameter_unknown400BothMalformed body, unsupported parameter or sizeNoFix the field named in the message
INVALID_ARGUMENT: "API key not valid. Please pass a valid API key."400generateContentKey missing, mistyped or deletedNoCreate a new key in AI Studio
authentication401InteractionsKey missing, invalid or expiredNoSame: check or replace the key
FAILED_PRECONDITION / failed_precondition400BothA prerequisite is missing, such as billingNoEnable billing on the project
payment_required402InteractionsPrepay credit balance is $0NoAdd credits or turn on auto-reload
PERMISSION_DENIED / permission_denied403BothKey lacks access to this project or resourceNoCheck key restrictions and project access
NOT_FOUND / model_not_found404BothWrong or retired model IDNoSwitch to a current model ID
finishReason: SAFETY200generateContentBlocked by an adjustable safety categoryNoRead safetyRatings, adjust that threshold
finishReason: IMAGE_SAFETY / image_safety200BothGenerated image blocked; rule not publishedNot as isRewrite the prompt
finishReason: NO_IMAGE / no_image200BothThe model returned no imageNot as isChange the prompt or settings
promptFeedback.blockReason: OTHER200generateContentPrompt blocked, no reason givenNot as isIsolate the trigger in the prompt

The rule behind the table: 5xx and 429 are temporary, every other 4xx is permanent until you change something, and a 200 without an image is a content or prompt problem that a plain resend will usually repeat.

Server-Side Errors (5xx): 500, 503 Overloaded and 504 Timeouts

Server errors are Google's side of the call. Nothing in your code fixes them immediately, so the job is bounded retries, a fallback model and a clear message to your users. For more server-error examples, see the Nano Banana Pro error codes guide.

503 overloaded is the one you meet during busy periods. On generateContent it arrives as UNAVAILABLE, often with the message "The model is overloaded"; the Interactions API calls it service_unavailable and recommends waiting and retrying with exponential backoff. Google publishes no failure rate or recovery time for 503, so any fixed recovery time you come across is anecdotal. Overload is model-specific: Nano Banana 2.1 may keep answering while Pro is busy, though nothing guarantees it. The pattern that works is to retry a few times with backoff and jitter, then send the same prompt to gemini-nano-banana-2.1 if the user needs an image now.

500 internal error (INTERNAL on generateContent, api_error on Interactions) is an unexpected failure on Google's side. The identical request often succeeds on the next attempt, and Google's advice is to retry and contact support if it persists. If a burst of 500s and 503s hits every model at once, check the Google AI Studio status page for the Gemini API, or the Google Cloud status dashboard if you call the model through Vertex AI. Threads such as "An internal error has occurred" on the Google AI Developers Forum show whether others are seeing the same thing.

504 deadline_exceeded means the request did not finish before the deadline. Nano Banana Pro thinks before it draws, which adds time to every call, so a short client-side timeout can cut a call off that would have completed. Google's fix is to remove or raise the client deadline and fall back to the server default. Pro also generates up to two interim images while it thinks, and the last one is the final image. Those interim images are part of normal output, not an error; the temporary images and bug fixes guide covers them.

502 Bad Gateway points to routing between a gateway and the backend rather than to your request. It usually clears on its own. Retry with backoff and log the timestamps so you can tell a short blip from a longer incident.

A practical production pattern for every 5xx is retry, fall back, queue: retry gemini-3-pro-image with backoff, switch to gemini-nano-banana-2.1 once retries are used up, and if that fails too, queue the job and tell the user the image is still in progress. Nano Banana 2 (gemini-3.1-flash-image) still answers, but Google lists it as deprecated on the Gemini API and recommends 2.1 for new projects, so it is no longer the fallback to build on. The code for this pattern is in the production error-handling section below.

Client-Side Errors (4xx): Fix Your Request Before Retrying

A 4xx means the problem is in your request, key, billing or model ID, so you can fix it without waiting for Google. Only 429 belongs in a retry loop. Google's Gemini API troubleshooting guide (last updated October 1, 2026) says to retry transient errors such as 429, 408 and 5xx, and not to retry 400, 402 or 403, because they signal invalid keys, depleted Prepay credits or bad syntax.

429 RESOURCE_EXHAUSTED: per-minute limit, daily quota or spend cap

429 has three causes, and each clears differently. A per-minute or per-second limit (rate_limit_exceeded on Interactions) clears within about a minute, so backoff works. A daily quota (quota_exceeded) resets at midnight Pacific time, so backoff only burns attempts. A spend-based limit is evaluated on a rolling 10-minute window and returns 429 RESOURCE_EXHAUSTED once your tier's ceiling is reached; the numbers are in the rate limits section below. On generateContent all three share the RESOURCE_EXHAUSTED status, so read the message text and log it.

Limits are counted per project, not per API key, so extra keys in the same project add no capacity. Retrying without a delay keeps you over the limit, which is why every retry needs exponential backoff with jitter. For per-model recovery steps and code that resumes unfinished jobs, see Nano Banana Pro RESOURCE_EXHAUSTED: Fix 429 and Resume Image Jobs; for how long each kind of image 429 lasts, see Gemini Image 429 Rate Limit: How Long It Lasts and How to Fix It.

400 INVALID_ARGUMENT, including "API key not valid"

A 400 is a structural problem with the request, and the message usually names the field. Common causes with Nano Banana Pro:

  • Image size spelled wrong. Google's image generation guide accepts 1K, 2K and 4K for Pro and says lowercase values such as 1k are rejected.
  • A size the model does not support. Pro has no 512 size; only Nano Banana 2 (gemini-3.1-flash-image) lists 512. See the Nano Banana 2.1 section for what happens when 512 reaches 2.1.
  • Too much input. gemini-3-pro-image accepts 65,536 input tokens, according to its model page, and long multi-turn edit histories can cross that even when the latest prompt is short. Inline (base64) data is capped at 100 MB per request, according to Google's file input page (last updated October 7, 2026); larger files go through the Files API.
  • An unknown or misplaced parameter (parameter_unknown on Interactions). Remove it rather than retrying.

On the classic generateContent endpoint, an invalid key also lands here. A generateContent call made with an invalid key on October 8, 2026 returned HTTP 400 INVALID_ARGUMENT with "API key not valid. Please pass a valid API key." Create a new key in Google AI Studio and confirm it works with a plain text request before you debug anything image-specific. FAILED_PRECONDITION (also 400) means a prerequisite is missing, most often billing on the project.

401 authentication and 402 payment_required on the Interactions API

The Interactions API separates two problems that generateContent folds into other codes. 401 authentication means the key is missing, invalid or expired; replace it. 402 payment_required means the Prepay credit balance on your billing account is at $0. Google's Gemini API billing page says requests then fail with 402 until you add credits, and the errors page says not to retry. Add credits or turn on auto-reload. Prepay credits expire after 12 months, so an old top-up can lapse before you use it.

403 PERMISSION_DENIED: key permissions, leaked keys and regions

A 403 means the key exists but is not allowed to do this. Check that the key belongs to the project you think it does, that any key restrictions allow the Gemini API, and that the project has access to the model. Google also blocks keys it has identified as publicly leaked; those return "Your API key was reported as leaked. Please use another API key." AI Studio shows which of your keys are blocked, and the only fix is a new key kept out of public code.

Location matters too. Google's list of available regions for the Gemini API and AI Studio (last updated April 28, 2026) does not include Russia, mainland China or Hong Kong. From a location that is not on the list, a key and project that work elsewhere will still be refused. Google offers no workaround for this, so check the list before you build on the Gemini API from such a location. Vertex AI publishes its own regional availability.

404 model_not_found: retired preview model IDs

A 404 with NOT_FOUND or model_not_found almost always means the model ID. Google's Gemini API deprecations page lists the preview image IDs as shut down, and code or ComfyUI workflows that still send them will fail:

Old IDShut downReplacement
gemini-3-pro-image-previewJune 25, 2026gemini-3-pro-image
gemini-3.1-flash-image-previewJune 25, 2026gemini-nano-banana-2.1
gemini-2.5-flash-image-previewJanuary 15, 2026gemini-nano-banana-2.1

Google's advice for model_not_found is to verify the model name or fall back to a different model. Change the ID in config rather than in a dozen call sites, and the next retirement becomes a one-line change. For current IDs and setup, see Nano Banana API Docs and Tutorial: Key, Model IDs, and Code.

Nano Banana 2.1 errors: 512 size, Vertex sampling parameters and fallback choice

Nano Banana 2.1 (gemini-nano-banana-2.1) has been generally available on the Gemini API and on Vertex AI since October 6, 2026, and Google's image guide recommends it for all new projects. That makes it the natural fallback when Pro is overloaded, at $0.0336 per 1K image against Pro's $0.134 on Standard pricing (Gemini API pricing page, as of October 8, 2026). It also brings a few errors of its own.

512 sent to 2.1. Google lists 1K, 2K and 4K for 2.1; the 512 size exists only on Nano Banana 2. Code that falls back from Nano Banana 2 to 2.1 and keeps imageSize: "512" should switch to 1K first. Through LaoZhang API the outcome has changed from day to day: on October 7, 2026 a 512 request to 2.1 returned HTTP 400 "Image size 512 is not supported for this model" and was not charged, while on October 8 the same request returned a 1K image and was billed $0.045. Either way, do not send it.

Disclosure: laozhang.ai is our own service. Its prices are platform pricing, not an independent comparison.

Sampling parameters on Vertex AI. Google's Vertex AI page for 2.1 says seed, topK, logprobs, temperature and topP return an API error on this model. Strip them from the request when you switch a Vertex call to 2.1; 2.1 is served from the global location there and does not support Flex. ComfyUI's Nano Banana 2.1 node already leaves out temperature and top_p for this model, but it still shows a seed field, so do not expect seeds to reproduce an image on 2.1. Setup details are in Vertex AI Nano Banana API: Model IDs, Setup, and Cost per Image.

Nano Banana 2 and the original Nano Banana. On the Gemini API, Nano Banana 2 (gemini-3.1-flash-image) is deprecated with no shutdown date announced; on Vertex AI its retirement is listed as May 28, 2027 or later. For gemini-2.5-flash-image, Google's pages disagree: as of October 8, 2026, the deprecations table lists a shutdown on March 15, 2027, with gemini-3.1-flash-lite-image as the replacement, while a warning on the pricing page still says it "will be shut down on October 2, 2026." Vertex AI lists March 15, 2027. Either way it is on its way out, so do not build a new fallback on it. For which model to use now, see Nano Banana 2 Lite vs 2 vs 2.1 vs Pro: Which Model to Use Now.

2.1 is not a drop-in copy of Pro. In a 9-prompt test on October 8, 2026, at 1K with one image per prompt, 2.1 changed the requested wording in 3 text tasks where Pro kept it; the results are in Nano Banana 2.1 vs Pro vs GPT Image 2.5: 9-Prompt Test and Cost. If your images carry exact text, flag fallback results for review instead of shipping them silently.

What Google Documents About Safety Blocks: SAFETY, IMAGE_SAFETY and OTHER

Prompt refusal and candidate safety finish reasons have different meanings and next actions

Safety blocks are the most confusing Nano Banana Pro errors because the response rarely says why. It helps to separate what Google documents from what developers guess. Google does not publish a "layer" architecture or a list of internal moderation stages; it publishes the fields and values the API returns, plus the safety settings you can change. Build your error handling around those. For how Google separates content blocks, rate limits and account enforcement, see Nano Banana Pro Risk Control: Blocks, Rate Limits and Suspension.

Here is what is documented. Google's safety settings page (last updated September 17, 2026) lists four adjustable categories: harassment, hate speech, sexually explicit and dangerous content. You set their thresholds through safetySettings, and if you set none, the default for Gemini 2.5 and 3 models is Off. Separately, built-in protections against core harms, such as content that endangers child safety, are always blocked and cannot be adjusted. On generateContent, a candidate's finishReason can be SAFETY (inspect safetyRatings), IMAGE_SAFETY, IMAGE_PROHIBITED_CONTENT, IMAGE_RECITATION, IMAGE_OTHER, NO_IMAGE or OTHER, and promptFeedback.blockReason can be SAFETY, BLOCKLIST, PROHIBITED_CONTENT, IMAGE_SAFETY or OTHER. The Interactions API reports the same family as generation-blocked codes (image_safety, image_prohibited_content, image_recitation, image_other) and the generation error no_image, with the advice to modify your input before trying again.

The practical difference is what you can change. When finishReason is SAFETY, safetyRatings tell you which category fired, and you can adjust that category's threshold. Setting a category to BLOCK_NONE loosens that category only; it should not be expected to clear OTHER or the always-blocked protections. When you see finishReason: "IMAGE_SAFETY" or the message "generated images may contain unsafe content", the image was blocked on safety grounds. Google does not say which rule fired and documents no setting that turns it off, so the practical response is to rewrite the prompt.

What about blockReason: OTHER? The API reference defines it in one line: the prompt was blocked due to unknown reasons. The troubleshooting guide adds that with OTHER, the query or response may violate the terms of service or be otherwise unsupported. There is no field to inspect and no documented setting that clears it, so do not expect BLOCK_NONE to help. For how to isolate the trigger, see Nano Banana 2 blockReason OTHER: What It Means and What to Check.

For IMAGE_SAFETY, these practitioner tactics sometimes help, though Google does not document them and no success rate is published. Replace character names or IP references with generic descriptions ("a princess in a blue dress" instead of a named character). Add an explicit art style such as "digital illustration in watercolor style". Avoid combining human subjects with clothing or pose descriptors that could be read as depicting a minor. Because the block comes from the model's own protections, a gateway that serves the same Google model should not be expected to change the outcome; change the prompt instead.

Google publishes no block rates per category, so measure your own. E-commerce prompts with human models in clothing and fan-art or parody prompts based on recognizable characters are worth testing first; landscapes, objects and abstract art run into trouble less often. A 200 response with text and no image is a related but separate case, covered in Nano Banana API Returns No Image? Find the Cause in the Response.

Rate Limits and Quotas: No Free Tier, 10-Minute Spend Caps

To tell a per-minute 429 from a quota or spend problem, you need to know where your ceilings sit. Three facts matter most for Nano Banana Pro, all from Google's pages as of October 8, 2026.

There is no free API tier for image models. On the Gemini API pricing page, the Free Tier column reads "Not available" for Nano Banana Pro, 2.1, 2 and 2 Lite. A free-tier RPM figure such as "15 RPM" does not apply to any of these models. Image calls need a project with billing linked. A Google AI Pro or Ultra subscription adds no API quota either; it applies to the Gemini app, not to API keys.

Google publishes no RPM table for image models. The Gemini API rate limits page (last updated September 2, 2026) says limits apply per project, depend on your usage tier, and that your active RPM, TPM and images-per-minute (IPM) limits are shown only in AI Studio. IPM applies only to image models. Requests-per-day quotas reset at midnight Pacific time.

Usage tiers add a spend ceiling per rolling 10 minutes. Tiers follow the cumulative spend of the linked billing account:

TierHow you qualifyMonthly billing account capSpend limit per rolling 10 minutes
Tier 1Link an active billing account$250$10
Tier 2$100 paid and 3 days since the first successful payment$2,000$50
Tier 3$1,000 paid and 30 days since the first successful payment$20,000–$100,000+$200

The 10-minute limit is the one that surprises Pro users, because Pro images are expensive. At the Standard price of $0.134 per 1K or 2K image, Tier 1's $10 covers at most 74 Pro images per 10 minutes ($10 ÷ $0.134 = 74.6), or 41 at 4K ($10 ÷ $0.24 = 41.7). Tier 2 allows about 373 ($50 ÷ $0.134) and Tier 3 about 1,492 ($200 ÷ $0.134). Input and thinking tokens are billed on top, so the real count is lower. Past that point you get 429 RESOURCE_EXHAUSTED even if your RPM is far from its limit. Monthly caps sit on top: the tier's billing account cap, plus any project cap you set on the Spend page in AI Studio. For how to move up a tier, see Nano Banana Pro API Quota Increase: Tier 1–3 Caps in Images and Gemini API Rate Limits 2026: Free vs Paid Tiers and How to Raise.

Prices that decide your fallback. As of October 8, 2026, Google's Standard price for gemini-3-pro-image is $0.134 per 1K or 2K image and $0.24 at 4K; Batch halves that to $0.067 and $0.12. Nano Banana 2.1 costs $0.0336 at 1K, $0.0504 at 2K and $0.113 at 4K, and Nano Banana 2 costs $0.067 at 1K and $0.101 at 2K. Thinking tokens are billed on top for all of them. Batch is the documented half-price route for image models. The pricing page also shows Flex rows for Pro at the Batch price, but Google's Flex inference page lists no image model among supported models, and Pro's model page says it does not support Flex inference. Plan on Batch, not Flex. For the full breakdown, see Gemini 3 Pro Image API Pricing: $0.067–$0.432 per Image by Tier and Nano Banana Pro Batch API Cost: Cheapest at 1K/2K, Not at 4K.

The Gemini app is a different system. Limits in the Gemini app are compute-based and refresh every 5 hours until a weekly limit, according to Google's Gemini app help center, and Google publishes no per-day image count. On Google's image overview page, Nano Banana 2.1 is described as the model for Google AI plan subscribers, while the help center still describes Nano Banana 2 as the default and Pro as a "redo" option for plan holders. A limit hit in the app has nothing to do with API errors. For each surface's limits, see Nano Banana Pro Limits: Gemini, AI Mode, Workspace and API Quotas.

Which Errors to Retry, and What the google-genai SDK Does by Default

Retry only temporary errors: 408, 429 and 5xx. Use exponential backoff with jitter and a maximum number of attempts. Do not retry 400, 401, 402, 403 or 404, and do not resend a prompt that came back as IMAGE_SAFETY without changing it.

The SDK default is where many retry loops go wrong. Google's troubleshooting guide says the Python SDK retries transient errors up to four times by default, with about 1 second initial delay and 60 seconds maximum. That holds for the Interactions API, not for generateContent:

  • client.models.generate_content sends one request and raises on a default client. In a test on October 5, 2026 with google-genai 2.28.0 against a server that always returned 429, it made a single request; with http_options=types.HttpOptions(retry_options=types.HttpRetryOptions()) it made 5 (4 retries). google-genai 2.29.0 behaves the same: without retry_options it stops after one attempt.
  • client.interactions.create retried 3 times by default in the same 2.28.0 test.

If you call generate_content, which is what most Nano Banana Pro code does, pass HttpRetryOptions or write your own loop. Do not count on the documented default.

Production-Grade Error Handling Code: Retries, Fallback and Safety Checks

The code below uses the current google-genai SDK (pip install google-genai; the older google-generativeai package is a different library). It turns on SDK retries for temporary codes only, falls back from Pro to Nano Banana 2.1 when 5xx errors outlast the retries, stops at once on request errors, and checks the response for prompt blocks and missing images before returning.

python
from google import genai
from google.genai import errors, types

PRIMARY = "gemini-3-pro-image"        # Nano Banana Pro
FALLBACK = "gemini-nano-banana-2.1"   # Nano Banana 2.1

# generate_content does not retry unless you pass retry options.
# Retry only transient codes: 408, 429 and 5xx. Never 400, 402 or 403.
client = genai.Client(
    http_options=types.HttpOptions(
        retry_options=types.HttpRetryOptions(
            attempts=5,            # the first call plus 4 retries
            initial_delay=1.0,     # seconds, doubles with jitter
            max_delay=60.0,
            http_status_codes=[408, 429, 500, 502, 503, 504],
        )
    )
)


def generate(prompt: str, size: str = "2K") -> dict:
    for model in (PRIMARY, FALLBACK):
        try:
            resp = client.models.generate_content(
                model=model,
                contents=prompt,
                config=types.GenerateContentConfig(
                    response_modalities=["IMAGE"],
                    image_config=types.ImageConfig(image_size=size),  # "1K", "2K" or "4K"
                ),
            )
        except errors.APIError as e:
            if e.code == 429:
                # Retries are used up: per-minute limit, daily quota or 10-minute spend cap.
                return {"status": "quota", "model": model, "message": e.message}
            if e.code >= 500:
                continue  # still failing after retries: try the fallback model
            # 400, 401, 402, 403, 404: the request, key, billing or model ID needs fixing.
            return {"status": "fix_request", "model": model, "code": e.code, "message": e.message}

        if resp.prompt_feedback and resp.prompt_feedback.block_reason:
            return {"status": "prompt_blocked", "reason": resp.prompt_feedback.block_reason.name}
        cand = resp.candidates[0] if resp.candidates else None
        parts = cand.content.parts if cand and cand.content and cand.content.parts else []
        for part in parts:
            if part.inline_data:
                return {"status": "ok", "model": model, "image": part.inline_data.data}
        # HTTP 200 without an image: do not retry the same prompt blindly.
        reason = cand.finish_reason.name if cand and cand.finish_reason else "NO_CANDIDATE"
        return {"status": "no_image", "model": model, "finish_reason": reason}

    return {"status": "unavailable", "message": "both models failed after retries"}

What was run, and what was not. On October 8, 2026, this exact code ran with google-genai 2.29.0 against a local stub that imitates the generateContent endpoint, not against Google's servers. Two 429s followed by success returned an image after 3 requests (about 4 seconds). A permanent 429 stopped after 5 requests (about 17 seconds) with status: "quota". A 503 on Pro made 5 requests to Pro and then succeeded on gemini-nano-banana-2.1 (about 16 seconds). A 400 "API key not valid", a 402 and a 404 each stopped after one request. IMAGE_SAFETY, a text-only reply and blockReason: OTHER came back as no_image or prompt_blocked without a retry. The stub does not show real overload behavior or real safety decisions; those depend on Google's side.

Two choices in the code are worth explaining. A 429 that outlasts the retries is returned rather than sent to the fallback model. Per-minute limits are set per model, but the 10-minute spend cap covers the whole billing account, so switching models will not help there; queue the job instead. For 2.1, keep size at 1K, 2K or 4K, because 2.1 has no 512 size. If you call the model through Vertex AI, do not add seed, temperature, topP or topK to the 2.1 request.

Beyond the core loop, three patterns pay off in production. First, queue jobs that fail every attempt and process them later instead of showing users an error. Second, add a circuit breaker: after a run of 503s from Pro within a short window, send traffic straight to the fallback until a health check succeeds. Third, track errors by category (429, 5xx, request errors, safety) so you can tell a capacity incident from a quota ceiling, and set your own alert thresholds from that baseline. For a longer step-by-step debugging workflow, see the debugging guide.

When to Consider Alternative Providers for Nano Banana Pro

Not every Nano Banana Pro error has a quick fix. Persistent 503s at peak hours, IMAGE_SAFETY blocks that resist prompt changes, or quotas that cap a production workload are reasons to look at a multi-model or multi-route setup. That does not mean abandoning Nano Banana Pro; it means one failing route no longer stops your application. For a quality and reliability comparison with another model family, see FLUX.2 Pro vs Nano Banana Pro: Editing, API Costs, and Which to Choose.

The simplest version is the primary/fallback pattern from the code above, with the fallback pointed at a second route. LaoZhang API is one such route. It serves the Nano Banana models behind one endpoint at a fixed price per call. As of October 8, 2026, its Nano Banana 2.1 guide and model overview list $0.09 per call for gemini-3-pro-image at any size, $0.045 for gemini-nano-banana-2.1, $0.055 for gemini-3.1-flash-image and $0.025 for gemini-3.1-flash-lite-image (1K only). Against Google's Standard prices, $0.09 for Pro is about 32.8% less at 1K/2K (($0.134 − $0.09) ÷ $0.134) and 62.5% less at 4K (($0.24 − $0.09) ÷ $0.24). Google's Batch price is lower at 1K/2K ($0.067), while at 4K Batch ($0.12) the per-call price is 25% lower. For plan, API and gateway costs side by side, see How Much Is Nano Banana Pro? API, Plan, and Usable-Image Cost.

Disclosure: laozhang.ai is our own service. Its prices are platform pricing, not an independent comparison.

Know the billing rules before you route retries there. LaoZhang API charges an HTTP 200 without an image as one call, because it does not review prompts or outputs. A request rejected with 429 or 503 before generation is usually not charged. So do not resend a safety-blocked prompt in a loop. Size and aspect ratio can only be set on the Gemini-native route; the OpenAI-compatible route has no size or ratio setting and returns 1K images. Safety blocks come from Google's model, so a gateway does not change them.

Whatever the second route, keep the generation call behind one interface that takes a prompt and returns an image or a typed error, and choose the route at runtime. Keep the model ID in config, since preview IDs have already been shut down once. Check the terms that apply to your plan before relying on any single model or provider for an uptime commitment.

Nano Banana Pro Error FAQ

How long does a Nano Banana Pro 429 RESOURCE_EXHAUSTED error last?

It depends on which limit you hit. A per-minute limit clears within about a minute, so exponential backoff starting at 1–2 seconds and capped near 60 seconds is enough. A daily quota resets at midnight Pacific time. A spend-based limit works on a rolling 10-minute window ($10, $50 or $200 by tier), so it clears as older spend leaves the window. Retrying without a delay keeps you over the limit in every case.

Why does Nano Banana Pro say "API key not valid" with a 400 instead of a 403?

On the classic generateContent endpoint, an invalid or missing key is reported as HTTP 400 INVALID_ARGUMENT with "API key not valid. Please pass a valid API key." The Interactions API reports it as 401 authentication. A 403 PERMISSION_DENIED means the key exists but is not allowed to use this project or resource. In all three cases, fix the key or its permissions instead of retrying.

Can you bypass the IMAGE_SAFETY filter on Nano Banana Pro?

Google documents no setting that turns off IMAGE_SAFETY. The safetySettings thresholds apply only to the four adjustable categories, and built-in protections against core harms are always blocked. For finishReason: SAFETY, inspect safetyRatings and adjust the matching threshold. For IMAGE_SAFETY, rewrite the prompt: generic descriptions instead of character names, an explicit art style, and no human subjects paired with descriptors that could suggest a minor. These are practitioner tactics with no published success rate.

Why does Nano Banana Pro keep saying "generated images may contain unsafe content"?

That message is an image-level safety block, the same family as finishReason: IMAGE_SAFETY. Google does not say which rule fired, so the message does not tell you whether a character, a real person or the composition caused it. Rewrite the prompt with a generic description and an explicit style such as "watercolor illustration" or "flat vector art", and simplify it step by step if the same prompt keeps failing.

What is the difference between finishReason SAFETY and IMAGE_SAFETY?

finishReason: SAFETY means a candidate was stopped for a safety reason; safetyRatings shows the category, and for the four adjustable categories you can change the threshold. finishReason: IMAGE_SAFETY means the generated image was blocked; Google does not say which rule fired and documents no setting that changes it, so rewrite the prompt. Neither is the same as promptFeedback.blockReason: OTHER, which Google defines only as "unknown reasons".

Why do I get 404 model_not_found for gemini-3-pro-image-preview?

Google shut down gemini-3-pro-image-preview on the Gemini API on June 25, 2026. Change the model ID to gemini-3-pro-image. gemini-3.1-flash-image-preview was shut down the same day, and gemini-2.5-flash-image-preview on January 15, 2026; Google lists gemini-nano-banana-2.1 as the replacement for both.

Is there a free tier for Nano Banana Pro in the API?

No. As of October 8, 2026, Google's Gemini API pricing page marks the free tier as "Not available" for Nano Banana Pro and every other Nano Banana image model, so image calls need a project with billing linked. Pro costs $0.134 per 1K or 2K image and $0.24 at 4K on Standard pricing. Free image generation exists only in the Gemini app, and a Google AI Pro or Ultra plan adds no API quota. For what $5 of credit buys, see Gemini Image API Free? No Free Tier, but $5 Buys Up to 148 Images.

How do I check if Nano Banana Pro is down?

Check the Google AI Studio status page for the Gemini API, or the Google Cloud status dashboard for Vertex AI. If neither shows an incident but you still get 503s, send a short text-only request and a simple image prompt: if text works and images fail, the image model is the likely bottleneck, not your key or project. The Google AI Developers Forum often has threads from other developers when a wider problem starts.

Sources12

External pages this guide links to, in the order they appear. Last updated Oct 8, 2026.

  1. 1.Gemini API errors referenceai.google.dev/gemini-api/docs/api-errors
  2. 2.Google AI Studio status pageaistudio.google.com/status
  3. 3.Google Cloud status dashboardstatus.cloud.google.com
  4. 4.Google AI Developers Forumdiscuss.ai.google.dev
  5. 5.Gemini API troubleshooting guideai.google.dev/gemini-api/docs/troubleshooting
  6. 6.Google AI Studioaistudio.google.com
  7. 7.Gemini API billing pageai.google.dev/gemini-api/docs/billing
  8. 8.list of available regions for the Gemini API and AI Studioai.google.dev/gemini-api/docs/available-regions
  9. 9.Gemini API deprecations pageai.google.dev/gemini-api/docs/deprecations
  10. 10.safety settings pageai.google.dev/gemini-api/docs/safety-settings
  11. 11.Gemini API pricing pageai.google.dev/gemini-api/docs/pricing
  12. 12.Gemini API rate limits pageai.google.dev/gemini-api/docs/rate-limits
Nano Banana Pro troubleshooting hub covering error codes, temporary images, and platform comparison
AI Image Generation

Nano Banana Pro Troubleshooting Hub: Fix Every Error Code with Proven Solutions (2026)

Nano Banana Pro API errors can derail your image generation pipeline. This troubleshooting hub covers every error code (429, 503, 400, 403, 500), explains the temporary image thinking mechanism, provides production-ready Python code for error handling, and compares Gemini API versus Vertex AI stability — all based on real developer reports and official documentation as of February 2026.

25 min