# Gemini Image Edit — Upload

Upload reference images with multipart form-data to edit images using gemini-nano-banana-2.1-c. Returns one image URL.

- Source: https://www.unifyllm.com/docs/api-reference/gemini-image-edit/
- Language: en
- Updated: 2026-11-27

## Endpoint

```http
POST https://api.unifyllm.top/v1/images/edits
```

Use the authentication and headers shown in the request examples. Content-Type: multipart/form-data

[Integration guide](https://www.unifyllm.com/docs/gemini-image/)

## Model and response format

These are UnifyLLM compatibility rules for gemini-nano-banana-2.1-c. Use https://api.unifyllm.top with the endpoint paths shown below. Check the corresponding documentation for other image models.

- Returns one stored image URL. Download that URL without an API key. A download failure is not a reason to resubmit generation.

- One upstream generation submission per request; paid POST requests are not automatically retried.

- Default reference limits are 14 images and 40 MB of original bytes combined; platform or account limits may be tighter. Supported PNG/JPEG/WebP images must be readable.

## Resolution and aspect ratio

Dimensions select a resolution tier and composition; exact pixels are not promised. The public gateway test on 2026-11-27 requested 1920x1080 and received 2752×1536. The result is not resized or cropped.

| Input | Example | Mapped result |
| --- | --- | --- |
| size | auto | Default 1K; text-only defaults to 1:1, references let upstream choose |
| size | 1536x1024 | 1K / 3:2 |
| size | 1920x1080 | 2K / 16:9 |
| size | 1600x1000 | 2K / 3:2 (nearest) |
| size | 4096x2304 | Still 2K / 16:9, not 4K |

## Single-turn input and reference limits

- Images generation is text-only; use edits for references. Chat uses only the last user message and does not restore previous images.

- URL references must be publicly accessible; private addresses are rejected. Replace example.com URLs and Base64 placeholders. Do not put API keys in image URLs.

- n, response_format, quality, mask, input_fidelity, background, output_format, and output_compression are ignored. They do not enable multiple images, Base64, transparency, or format conversion.

- The default whole-request limit is 64 MB including Base64 and JSON overhead. The original-image limit is not the final encoded request size.

## Usage, errors, and saving results

- usage / usageMetadata is returned only when provided upstream. Images use input_tokens/output_tokens; Chat uses prompt_tokens/completion_tokens. Missing usage is not a zero-cost statement.

- 400 usually means invalid parameters or model capabilities; 401 is authentication; 413 is request size; 429 is capacity or rate limiting. Upstream rejection, timeout, no valid image, or storage failure may return 500. Keep the request ID and error for diagnosis.

- Generation can take time. Chat stream=true starts only after successful generation and storage, without waiting-period progress. Read SSE through data: [DONE]; do not parse the entire stream as one JSON object.

- URLs are not permanent archives: cleanup or signature changes can invalidate them. Download promptly and preserve id, sig, and the original query string.

## Parameters

| Field | Location | Type | Required | Description | Allowed values | Example |
| --- | --- | --- | --- | --- | --- | --- |
| model | body | string | yes | Public model ID. The example uses gemini-nano-banana-2.1-c; availability depends on your key. |  | gemini-nano-banana-2.1-c |
| prompt | body | string | yes | Non-empty prompt, up to 12,000 characters. |  |  |
| image | body | file | yes | Single image file. For multiple images, repeat image[] in order. Let your HTTP client set the multipart boundary. |  |  |
| size | body | string | no | auto or positive WIDTHxHEIGHT. Long edge ≤1536 requests 1K; >1536 requests 2K. The nearest supported aspect ratio is used; exact pixels are not guaranteed. 1K, 2K, 4K, and 16:9 are not valid size values. |  | 1920x1080 |

## Upload reference image

```json
{
  "model": "gemini-nano-banana-2.1-c",
  "prompt": "Change the red teapot to blue; preserve the shape and white background.",
  "image": "@/path/to/reference.jpg",
  "size": "1024x1024"
}
```

### cURL

```bash
curl --fail-with-body --max-time 300 'https://api.unifyllm.top/v1/images/edits' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --form 'model=gemini-nano-banana-2.1-c' \
  --form 'prompt=Change the red teapot to blue; preserve the shape and white background.' \
  --form 'image=@/path/to/reference.jpg' \
  --form 'size=1024x1024'
```

### JavaScript

```javascript
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("model", "gemini-nano-banana-2.1-c");
form.append("prompt", "Change the red teapot to blue; preserve the shape and white background.");
form.append("image", new Blob([await readFile("/path/to/reference.jpg")]), "reference.jpg");
form.append("size", "1024x1024");

const response = await fetch("https://api.unifyllm.top/v1/images/edits", {
  method: "POST",
  headers: {
  "Authorization": "Bearer <YOUR_API_KEY>"
},
  body: form,
  signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data);
```

### Python

```python
import json
import requests

with open("/path/to/reference.jpg", "rb") as image:
    response = requests.post(
        "https://api.unifyllm.top/v1/images/edits",
        headers={"Authorization": "Bearer <YOUR_API_KEY>"},
        data=json.loads("{\n  \"model\": \"gemini-nano-banana-2.1-c\",\n  \"prompt\": \"Change the red teapot to blue; preserve the shape and white background.\",\n  \"size\": \"1024x1024\"\n}"),
        files={"image": ("reference.jpg", image, "image/jpeg")},
        timeout=(10, 300),
    )
response.raise_for_status()
print(response.json())
```

## Response examples

### URL result — HTTP 200

```json
{
  "created": 1795730000,
  "model": "gemini-nano-banana-2.1-c",
  "data": [
    {
      "url": "https://image.ezworkapi.top/gemini-img?id=EXAMPLE_IMAGE_ID&sig=EXAMPLE_SIGNATURE"
    }
  ],
  "usage": {
    "input_tokens": 28,
    "output_tokens": 1120,
    "total_tokens": 1148
  }
}
```

## Related endpoints

- [Gemini Image Edit — JSON](https://www.unifyllm.com/docs/api-reference/gemini-image-edit-json/)
- [Gemini Image — Images API](https://www.unifyllm.com/docs/api-reference/gemini-image-create/)
- [Gemini Native Image Generation](https://www.unifyllm.com/docs/api-reference/nano-banana-image/)
