Skip to main content

Symptoms

When you call a Nano Banana model (gemini-3.1-flash-image-preview, gemini-3-pro-image-preview, gemini-nano-banana-2.1, etc.) for an image edit with a reference image, the API returns HTTP 400 with one of these two errors:
The errors usually come in a burst and then stop, which makes the API look unstable.

Cause

inlineData.data in your request is empty, so the provider never received the image. Both errors have the same cause; different nodes word it differently. One says the inlineData parameter is empty. The other says it is “unable to process input image”, which makes people think the image is corrupted or its link is unreachable.
It is not about your image URL or whether your storage bucket is public. With inlineData, the image is sent as base64 inside the request body, and the provider never fetches any link. This error means the base64 string itself is empty. The problem is in the step where your code converts the image to base64.
You can confirm this in the console logs: the failed requests have very few input tokens (just the prompt), while normal requests with an image have hundreds to thousands more.

Checklist

1

Did the download or encoding step actually succeed?

Many programs first download the image from object storage (COS / OSS / S3) and then convert it to base64. If the download fails or times out, or the request is sent before an async step finishes, you get an empty string. Log the base64 length right before sending.
2

Is the variable undefined?

In JavaScript, JSON.stringify silently drops fields whose value is undefined. If imageBase64 is undefined, the serialized request has only mimeType under inlineData and no data field at all, so the provider reports an empty inlineData. You can’t see this in the code; you have to log the request body that is actually sent.
3

Does data include a data URL prefix?

inlineData.data must contain plain base64 only. If you have the full data:image/png;base64,iVBORw0... string, strip everything up to and including the comma.
4

Does mimeType match the real image format?

Set mimeType to image/png, image/jpeg or image/webp, matching the actual format. File extensions are unreliable (some phone .jpg files are really multi-frame images). The safest approach is to re-encode everything as PNG or JPEG during conversion.

Validate Before Sending

A few lines of checks before building the request will surface the problem locally instead of as an API error:
This 400 is caused by the request itself, so retrying the same request will not succeed. Once your code is fixed, no platform-side configuration is needed.

Want to Pass an Image URL Instead?

The native Gemini endpoint also accepts an image link directly. Use fileData, not inlineData:
With a URL, Google’s servers have to download the image. If your storage is served only through a mainland China CDN (for example, Tencent Cloud COS with default settings), Google often can’t reach it. The usual symptom is that the result ignores the reference image, not an error. Where possible, base64 is the more reliable option. See the Nano Banana Developer Guide for details.

FAQ

With inlineData, the provider never fetches any link, so public access doesn’t matter. Check the step where your code converts the image to base64 and make sure the data field you send is not empty.
No. The request is rejected at the provider’s entry point, no image is generated, and no charge is made. The console call logs are authoritative.

Nano Banana Developer Guide

Input image requirements, URL input and timeouts

Gemini Image Error Handling

How to handle each error and finishReason

Image MIME Type Mismatch?

Format mismatch caused by processing parameters in image URLs

Image Compression and Resolution

Compressing reference images does not hurt output quality