Troubleshooting Nano Banana errors
For parameter values, see Nano Banana text to image & sizes.
Start from the symptom
400 Request contains an invalid argument
{
"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:
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:
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
In clients such as Cherry Studio or LobeHub, add the model as an image generation model, not a chat model.
410 model_deprecated
{
"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:
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
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):
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
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.