# Qwen/Qwen-Image-Edit API

This document describes the input and output parameters of the `Qwen/Qwen-Image-Edit` model API, providing you the reference to understand these fields when using the interface.

---

## Request Parameters

### Request Body

| Field Name | Type   | Required | Default Value | Description                                                                                             |
| ---------- | ------ | -------- | ------------- | ------------------------------------------------------------------------------------------------------- |
| prompt     | string | Required | -             | The prompt                                                                                              |
| model      | string | Required | -             | The model name used for this request, which should be `Qwen/Qwen-Image-Edit`.                           |
| image      | string | Required | -             | Base64 data or image link `http://xxx`                                                                  |
| seed       | int    | Optional | -1            | Random seed used to control the randomness of the model's output. To keep the result consistent, use the same seed value. |
| size       | string | Optional | -             | The size of the generated image (width x height), with each dimension ranging from 256 to 1536. Example: `1024x1024`. |

## Response Parameters

| Field Name    | Type      | Description                                                                                                                                                                                                                                           |
| ------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| created       | `integer` | The Unix timestamp (in seconds) when this request was created.                                                                                                                                                                                       |
| data          | `array`   | Information about the output image, including the download URL or Base64 data.<br>• If the specified format for returning the generated image is URL, then the sub-field is URL;<br>• If it is b64_json, then the sub-field is b64_json.<br>Note: the link will expire in 7 days, so please save the image promptly. |
| error         | `Object`  | Error information object                                                                                                                                                                                                                             |
| error.code    | `string`  | Error code                                                                                                                                                                                                                                            |
| error.message | `string`  | Error message                                                                                                                                                                                                                                         |
| error.param   | `string`  | Request id                                                                                                                                                                                                                                            |

## Example

### OPENAI Compatible Interface

`POST https://api.umodelverse.ai/v1/images/generations`

#### Synchronous Request

```bash
curl --location 'https://api.umodelverse.ai/v1/images/generations' \
--header "Authorization: Bearer $MODELVERSE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "model": "Qwen/Qwen-Image-Edit",
    "prompt": "Convert to quick pencil sketch",
    "image": "data:image/png;base64,{image_base64_string}",
    "size": "1024x1024"
}'
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url=os.getenv("BASE_URL", "https://api.umodelverse.ai/v1"),
    api_key=os.getenv("API_KEY", "$MODELVERSE_API_KEY")
)

response = client.images.generate(
    model="Qwen/Qwen-Image-Edit",
    prompt="Convert to quick pencil sketch",
    extra_body={
        "image": "data:image/png;base64,{image_base64_string}",
        "size": "1024x1024"
    }
)

print(response.data[0].url)
```

### Response

```json
{
  "created": 1750667997,
  "data": [
    {
      "url": "https://xxxxx/xxxx.png",
      "b64_json": "data:image/png;base64,{image_base64_string}"
    }
  ],
  "usage": {
    "input_tokens_details": {}
  }
}
```

```json
{
  "error": {
    "message": "error_message",
    "type": "error_type",
    "param": "request_id",
    "code": "error_code"
  }
}
```

<!--
TODO:Asynchronous Request
### Asynchronous Request

``` -->