# Troubleshooting Nano Banana errors: invalid argument, wrong aspect ratio, no image returned Source: https://ofox.ai/docs/develop/models/nano-banana/errors For parameter values, see [Nano Banana text to image & sizes](https://ofox.ai/docs/develop/models/nano-banana/text-to-image). ## Start from the symptom **Key point**:First identify the type of problem: a parameter error, a wrong aspect ratio, no image returned, or a timeout. | Symptom | Most common cause | Go to | |---|---|---| | `400 Request contains an invalid argument` | The aspect ratio or resolution is outside what the model supports | [invalid argument](#invalid-argument) | | Output aspect ratio or resolution is not what you expected | `imageConfig` is in the wrong place, or the model does not support that value | [Wrong aspect ratio or resolution](#ratio) | | No image found in the response | Only the first item of `parts` was read, or the request was blocked by the safety policy | [No image](#no-image) | | `410 model_deprecated` | A retired `-preview` model ID was used | [410](#deprecated) | | Edited result has nothing to do with the original | The reference image was passed the wrong way | [Editing requests](#edit) | | Timeout, 504, 524 | The client or proxy timeout is too short | [Timeouts](#timeout) | ## 400 Request contains an invalid argument ```json filename="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: | Request | Cause | Fix | |---|---|---| | `aspectRatio: "5:3"` | The ratio is not on the supported list | Use a supported ratio; see [values supported by each model](https://ofox.ai/docs/develop/models/nano-banana/text-to-image#support) | | `aspectRatio: "1:8"` on Nano Banana | The previous generation does not support 1:4, 4:1, 1:8 or 8:1 | Use Nano Banana 2 or 2 Lite | | `imageSize: "512"` or `"2K"` on 2 Lite | 2 Lite supports `1K` only | Change to `1K`, or use Nano Banana 2 | | `imageSize: "512"` on Pro | Pro has no 512 tier | Use `1K` or above | | `imageSize: "8K"` on any model | The maximum is `4K` | Use `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: | Situation | Fix | |---|---| | `imageConfig` is at the top level of the request body, alongside `contents` | Move it into `generationConfig`; see the correct form below | | You need `1:4`, `4:1`, `1:8` or `8:1` on Pro | Pro 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 API | That API sets the ratio with `aspect_ratio` and has no resolution parameter; use the native API for 2K or 4K | | No aspect ratio was sent | The model decides the ratio; pass `aspectRatio` explicitly if you need a fixed one | Correct form: ```json { "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 | Cause | Fix | |---|---| | Only `parts[0]` was read | The 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 policy | See [Safety blocks](#safety) below | In clients such as Cherry Studio or LobeHub, add the model as an image generation model, not a chat model. ## 410 model_deprecated ```json filename="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: | Retired | Replace with | |---|---| | `google/gemini-3-pro-image-preview` | `google/gemini-3-pro-image` | | `google/gemini-3.1-flash-image-preview` | `google/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 sent | Fix | |---|---| | `input_images` on `/v1/images/generations` | `input_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): | Value | Meaning | Fix | |---|---|---| | `finishReason: "IMAGE_SAFETY"` | The generated image was judged to violate policy | Change the prompt; retrying unchanged gives the same result | | `finishReason: "PROHIBITED_CONTENT"` or `blockReason: "PROHIBITED_CONTENT"` | The prompt or reference image involves prohibited content | Change the prompt or use a different reference image | | `blockReason: "SAFETY"` | The prompt was blocked by the safety policy | Change the prompt | | `finishReason: "NO_IMAGE"`, `"IMAGE_OTHER"` | The model did not generate an image | Make 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](https://ai.google.dev/api/generate-content#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 | Error | Cause | Fix | |---|---|---| | `Invalid JSON payload received. Unknown name "image_size": Cannot find field.` | `image_size` was sent to the OpenAI-compatible API | That API has no resolution parameter; use `imageSize` on the native API | | `404 model_not_found` | Model ID misspelled | Copy it from the [model ID list](https://ofox.ai/docs/develop/models/nano-banana#members) | | `429` | Request rate limit exceeded | Lower concurrency, back off and retry; see [Rate limits](https://ofox.ai/docs/develop/guides/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.