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:
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.
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.Checklist
Did the download or encoding step actually succeed?
Is the variable undefined?
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.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.Does mimeType match the real image format?
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:- JavaScript
- Python
Want to Pass an Image URL Instead?
The native Gemini endpoint also accepts an image link directly. UsefileData, not inlineData:
URL Input Returns Cannot fetch content from the provided URL
When you pass images withfileData.fileUri, you may also hit a different 400, and this one does return an error:
inlineData. Google allows roughly 60 seconds to fetch a URL, and if your storage responds slowly to Google’s servers, the request hits that limit. The telltale sign is that every failure comes back at about 60 seconds.
- Send base64 with
inlineData(recommended): download the image yourself and convert it to base64 so Google no longer has to fetch anything. This error goes away entirely. Keep the non-empty base64 check described above. - If you must use a URL, cut down how long Google takes to fetch it: set the object’s
Content-Typeto its real format on upload (such asimage/png, not the S3 defaultbinary/octet-stream), and prefer a global CDN address such as CloudFront. This helps but does not guarantee the timeout won’t happen.
FAQ
My image is publicly readable. Why do I still get this error?
My image is publicly readable. Why do I still get this error?
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.Are these failed requests billed?
Are these failed requests billed?