> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Edit Returns Unable to Process Input Image?

> Nano Banana image edits return 400 'Unable to process input image' or 'empty inlineData parameter' because the inlineData image data in the request is empty. It has nothing to do with whether your image URL is reachable. Check your base64 conversion step and validate before sending.

## 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:

```json theme={null}
{
  "error": {
    "message": "Unable to process input image. Please retry or report in https://developers.generativeai.google/guide/troubleshooting",
    "code": 400
  }
}
```

```text theme={null}
Unable to submit request because it has an empty inlineData parameter. Add a value to the parameter and try again.
```

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.

<Info>
  **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.
</Info>

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

<Steps>
  <Step title="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.
  </Step>

  <Step title="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.
  </Step>

  <Step title="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.
  </Step>

  <Step title="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.
  </Step>
</Steps>

## Validate Before Sending

A few lines of checks before building the request will surface the problem locally instead of as an API error:

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    const b64 = (imageBase64 || '').replace(/^data:[^;]+;base64,/, '');
    if (!b64) {
      throw new Error('Reference image base64 is empty; check the download / encoding step');
    }

    const payload = {
      contents: [{
        parts: [
          { text: prompt },
          { inlineData: { data: b64, mimeType: imageMimeType } }
        ]
      }],
      generationConfig: {
        responseModalities: ['IMAGE'],
        imageConfig: { imageSize: '2K' }
      }
    };
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import base64, re

    def to_inline_data(image_bytes: bytes, mime_type: str) -> dict:
        if not image_bytes:
            raise ValueError("Reference image is empty; check the download / read step")
        b64 = base64.b64encode(image_bytes).decode()
        return {"inlineData": {"data": b64, "mimeType": mime_type}}

    def strip_data_url(s: str) -> str:
        b64 = re.sub(r"^data:[^;]+;base64,", "", s or "")
        if not b64:
            raise ValueError("Reference image base64 is empty")
        return b64
    ```
  </Tab>
</Tabs>

<Tip>
  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.
</Tip>

## Want to Pass an Image URL Instead?

The native Gemini endpoint also accepts an image link directly. Use `fileData`, **not** `inlineData`:

```json theme={null}
{
  "fileData": {
    "fileUri": "https://your-bucket.example.com/ref.png",
    "mimeType": "image/png"
  }
}
```

<Warning>
  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](/en/api-capabilities/nano-banana-dev-guide) for details.
</Warning>

## FAQ

<AccordionGroup>
  <Accordion title="My image is publicly readable. Why do I still get this error?">
    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.
  </Accordion>

  <Accordion title="Are these failed requests billed?">
    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.
  </Accordion>
</AccordionGroup>

## Related Docs

<CardGroup cols={2}>
  <Card title="Nano Banana Developer Guide" icon="book-open" href="/en/api-capabilities/nano-banana-dev-guide">
    Input image requirements, URL input and timeouts
  </Card>

  <Card title="Gemini Image Error Handling" icon="shield-alert" href="/en/api-capabilities/gemini-image-error-handling">
    How to handle each error and finishReason
  </Card>

  <Card title="Image MIME Type Mismatch?" icon="file-warning" href="/en/faq/image-mime-type-mismatch-with-query">
    Format mismatch caused by processing parameters in image URLs
  </Card>

  <Card title="Image Compression and Resolution" icon="minimize-2" href="/en/api-capabilities/image-compression-resolution">
    Compressing reference images does not hurt output quality
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.