Skip to Content
ModelsNano BananaTroubleshooting errors

Troubleshooting Nano Banana errors

For parameter values, see Nano Banana text to image & sizes.

Start from the symptom

Key pointFirst identify the type of problem: a parameter error, a wrong aspect ratio, no image returned, or a timeout.
SymptomMost common causeGo to
400 Request contains an invalid argumentThe aspect ratio or resolution is outside what the model supportsinvalid argument
Output aspect ratio or resolution is not what you expectedimageConfig is in the wrong place, or the model does not support that valueWrong aspect ratio or resolution
No image found in the responseOnly the first item of parts was read, or the request was blocked by the safety policyNo image
410 model_deprecatedA retired -preview model ID was used410
Edited result has nothing to do with the originalThe reference image was passed the wrong wayEditing requests
Timeout, 504, 524The client or proxy timeout is too shortTimeouts

400 Request contains an invalid argument

400 Bad Request
{ "error": { "code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT" } }

This error does not say which parameter is at fault. In our tests, all of the following return it:

RequestCauseFix
aspectRatio: "5:3"The ratio is not on the supported listUse a supported ratio; see values supported by each model
aspectRatio: "1:8" on Nano BananaThe previous generation does not support 1:4, 4:1, 1:8 or 8:1Use Nano Banana 2 or 2 Lite
imageSize: "512" or "2K" on 2 Lite2 Lite supports 1K onlyChange to 1K, or use Nano Banana 2
imageSize: "512" on ProPro has no 512 tierUse 1K or above
imageSize: "8K" on any modelThe maximum is 4KUse 4K or below

How to narrow it down: retry without imageConfig first; if the image generates, the problem is the aspect ratio or resolution, so add them back one at a time to find it.

Wrong aspect ratio or resolution

Check the actual width and height of the output image first, then go through this table:

SituationFix
imageConfig is at the top level of the request body, alongside contentsMove it into generationConfig; see the correct form below
You need 1:4, 4:1, 1:8 or 8:1 on ProPro does not support these four ratios; use Nano Banana 2 or 2 Lite
You need 2K or 4K on Nano Banana (2.5)2.5 does not support imageSize; use Nano Banana 2 or Pro
Setting the size on the OpenAI-compatible APIThat API sets the ratio with aspect_ratio and has no resolution parameter; use the native API for 2K or 4K
No aspect ratio was sentThe model decides the ratio; pass aspectRatio explicitly if you need a fixed one

Correct form:

{ "contents": [{ "parts": [{ "text": "..." }] }], "generationConfig": { "responseModalities": ["IMAGE"], "imageConfig": { "aspectRatio": "9:16", "imageSize": "2K" } } }

Both spellings are recognized — imageConfig / image_config and aspectRatio / aspect_ratio. In our tests, image_config: { aspect_ratio: "9:16" } correctly produced 768×1376.

No image in the response

CauseFix
Only parts[0] was readThe response may contain both text and an image, and the image is not necessarily the first item. Iterate over parts and look for the item with inlineData
The request was blocked by the safety policySee Safety blocks below

In clients such as Cherry Studio or LobeHub, add the model as an image generation model, not a chat model.

410 model_deprecated

410 Gone
{ "error": { "message": "Model 'google/gemini-3-pro-image-preview' is deprecated and no longer accepts requests; please switch to an active model", "type": "model_deprecated", "code": 410 } }

Old IDs ending in -preview have been retired; use the GA IDs instead:

RetiredReplace with
google/gemini-3-pro-image-previewgoogle/gemini-3-pro-image
google/gemini-3.1-flash-image-previewgoogle/gemini-3.1-flash-image

In the native API path, the model ID can include or omit the google/ prefix; both work in our tests.

Edited result has nothing to do with the original

What you sentFix
input_images on /v1/images/generationsinput_images is a Qwen-Image-only field that Gemini does not support. Upload files to /v1/images/edits instead, or use inlineData on the native API

To confirm the reference image was read: on the native API, check whether usageMetadata.promptTokensDetails contains an IMAGE entry; on the OpenAI-compatible API, check usage.input_tokens_details.image_tokens. We measured 1,120 tokens for one 1024×1024 reference image.

Safety blocks

When a request is blocked by the safety policy, the response contains no image, and the reason is recorded in finishReason or promptFeedback.blockReason. What each value means (per Google’s official definitions):

ValueMeaningFix
finishReason: "IMAGE_SAFETY"The generated image was judged to violate policyChange the prompt; retrying unchanged gives the same result
finishReason: "PROHIBITED_CONTENT" or blockReason: "PROHIBITED_CONTENT"The prompt or reference image involves prohibited contentChange the prompt or use a different reference image
blockReason: "SAFETY"The prompt was blocked by the safety policyChange the prompt
finishReason: "NO_IMAGE", "IMAGE_OTHER"The model did not generate an imageMake the prompt more specific, or retry later

Your code should not assume the response always contains an image: check that candidates exists and that finishReason is STOP before reading inlineData. Field definitions: Gemini API · FinishReason .

Timeouts, 504, 524

The API is synchronous. We measured about 5 to 20 seconds at 1K and about 30 seconds at 4K, longer at peak times. The common 60-second default timeout is not enough.

  • Set the client timeout to 300 seconds or more.
  • Check the timeouts of intermediate proxies such as Nginx, Vercel or Cloudflare, whose defaults are often only 60 to 100 seconds.
  • A 4K PNG is about 16 MB and the response body exceeds 20 MB; make sure your proxies do not truncate large responses.

If the client disconnects early, the request is still billed.

Other errors

ErrorCauseFix
Invalid JSON payload received. Unknown name "image_size": Cannot find field.image_size was sent to the OpenAI-compatible APIThat API has no resolution parameter; use imageSize on the native API
404 model_not_foundModel ID misspelledCopy it from the model ID list
429Request rate limit exceededLower concurrency, back off and retry; see Rate limits

When contacting support, include the request_id from the response and the full error message.

FAQ

How do I fix the Nano Banana error Request contains an invalid argument?

The error does not name the parameter; usually the aspect ratio or resolution is outside what the model supports. For example, 5:3 is not a supported ratio, Nano Banana 2 Lite is 1K only, Pro has no 512, and every model tops out at 4K. Retry without imageConfig first, then add values back one at a time to find the culprit.

I set aspectRatio on Nano Banana but the ratio is wrong. What should I do?

First make sure imageConfig is inside generationConfig, not at the top level of the request body. Then make sure the model supports the value: Pro does not support 1:4, 4:1, 1:8 or 8:1, and the previous-generation Nano Banana does not support imageSize.

Why is there no image in the Nano Banana response?

Most often the code reads only the first item of parts while the image comes later; iterate over parts to find inlineData. The other cause is that the request was blocked by the safety policy, in which case finishReason is not STOP.

gemini-3-pro-image-preview returns 410 model_deprecated. What should I do?

The preview IDs have been retired. Replace google/gemini-3-pro-image-preview with google/gemini-3-pro-image, and google/gemini-3.1-flash-image-preview with google/gemini-3.1-flash-image.

What should I do about IMAGE_SAFETY on Nano Banana?

IMAGE_SAFETY means the generated image was judged to violate the safety policy, and retrying unchanged gives the same result. Change the prompt to avoid real people, copyrighted characters or sensitive content, then try again.

Why does the reference image have no effect when editing with Nano Banana?

input_images is a Qwen-Image field that Gemini does not support. Upload files to /v1/images/edits instead, or on the Gemini native API put the image as inlineData in the same parts as the text.

Last updated on