# Edit Image with Form Data

Edit an image with a multipart form-data request.

- Source: https://www.unifyllm.com/docs/api-reference/edit-image-form-data/
- Language: en

## 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/)

## Parameters

| Field | Location | Type | Required | Description | Allowed values | Example |
| --- | --- | --- | --- | --- | --- | --- |
| model | body | enum<string> | yes | Image editing model. Use gpt-image-2-c for 1K/2K output or gpt-image-2-4k-c for 4K output. | gpt-image-2-c, gpt-image-2-4k-c | gpt-image-2-c |
| prompt | body | string | yes | Text instruction describing the requested output. |  |  |
| image | body | file | yes | One or more source image files to edit. |  |  |
| size | body | enum<string> | no | Output dimensions. Use a listed preset or a custom WxH value. Custom sizes must have a maximum edge of 3840 px, both edges divisible by 16, an aspect ratio no greater than 3:1, and 655,360–8,294,400 total pixels. | 1024x1024, 1536x1024, 2048x1536, 1024x1536, 1536x2048, 1440x2160, 2048x2048, 2880x2880, 3200x2560, 2560x3200, 3264x2448, 2448x3264, 3504x2336, 2336x3504, 3840x2160, 2160x3840, 3696x1584, auto | auto |

## Generate Image

```json
{
  "model": "gpt-image-2-c",
  "prompt": "Transform the image into a Studio Ghibli-inspired style",
  "image": "@/path/to/image.png",
  "size": "1024x1536"
}
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unifyllm.top/v1/images/edits' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --form 'model=gpt-image-2-c' \
  --form 'prompt=Transform the image into a Studio Ghibli-inspired style' \
  --form 'image=@/path/to/image.png' \
  --form 'size=1024x1536'
```

### JavaScript

```javascript
import { readFile } from "node:fs/promises";

const form = new FormData();
form.append("model", "gpt-image-2-c");
form.append("prompt", "Transform the image into a Studio Ghibli-inspired style");
form.append("image", new Blob([await readFile("/path/to/image.png")]), "image.png");
form.append("size", "1024x1536");

const response = await fetch("https://api.unifyllm.top/v1/images/edits", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>"
  },
  body: form,
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

with open("/path/to/image.png", "rb") as image:
    response = requests.post(
        "https://api.unifyllm.top/v1/images/edits",
        headers={"Authorization": "Bearer <YOUR_API_KEY>"},
        data={
        "model": "gpt-image-2-c",
        "prompt": "Transform the image into a Studio Ghibli-inspired style",
        "size": "1024x1536",
        },
        files={
        "image": image,
        },
    )

response.raise_for_status()
print(response.json())
```

## Response examples

### Default — HTTP 200

```json
{"created":1785223107,"data":[{"url":"https://image.ezworkapi.top/origin-img?u=aHR0cHM6Ly9vc3M1LmN4a2VkdS5zaG9wL2ltYWdlcy8yMDI2LzA3LzI4LzE3ODUyMjMxMDdfMGNiMTE4MzMzMmMxMGM2Mzg3Mzk3N2QyMjJlMjY5ZjQucG5n&sig=df731cbb207003b14ed3d71c1fdf25369f66f1b1ea66a90f24d7a2dd5bac3eb0"}],"model":"gpt-image-2-c"}
```
