# Qwen Image Edit API

> Qwen Image Edit — fast, high-fidelity AI image generation & editing.

- **Provider**: Qwen
- **Model id**: `qwen-image-edit`
- **Modality**: image
- **Price**: 3.36 credits

## Overview

Qwen Image Edit is called in two steps: create a generation task, then poll the task until the result is ready.

## Authentication

All requests require a Bearer Token in the request header:

```
Authorization: Bearer YOUR_API_KEY
```

## Create Task

`POST https://you.bot/api/v1/generate`

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| modelId | string | Yes | Model id: `qwen-image-edit` |
| input | object | Yes | Input parameters object (see below) |
| callbackUrl | string | No | https URL to receive a signed webhook on completion |

### input object parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| prompt | string | Yes | The prompt to generate the image with (default: Enhance into a rich cinematic color grade with soft golden rim light, refined detail, and natural depth.) |
| image_url | string | Yes | The URL of the image to edit. (image URL) |
| acceleration | string | No | Acceleration level for image generation. Options: 'none', 'regular'. Higher acceleration increases speed. 'regular' balances speed and quality. Default value: "none" (options: none | regular | high) (default: none) |
| image_size | string | No | The size of the generated image. Default value: landscape_4_3 (options: square | square_hd | portrait_4_3 | portrait_16_9 | landscape_4_3 | landscape_16_9) (default: landscape_4_3) |
| num_inference_steps | number | No | The number of inference steps to perform. Default value: 30 (range 2-49) (default: 25) |
| seed | number | No | The same seed and the same prompt given to the same version of the model will output the same image every time. |
| guidance_scale | number | No | The CFG (Classifier Free Guidance) scale is a measure of how close you want the model to stick to your prompt when looking for a related image to show you. Default value: 4 (range 0-20) (default: 4) |
| sync_mode | boolean | No | If set to true, the function will wait for the image to be generated and uploaded before returning the response. This will increase the latency of the function but it allows you to get the image directly in the response without going through the CDN. (true/false) (default: false) |
| num_images | string | No | Options: 1 | 2 | 3 | 4 |
| enable_safety_checker | boolean | No | If set to true, the safety checker will be enabled. Default value: true (true/false) (default: true) |
| output_format | string | No | The format of the generated image. Default value: "png" (options: jpeg | png) (default: png) |
| negative_prompt | string | No | The negative prompt for the generation Default value: " " (default: blurry, ugly) |
| nsfw_checker | boolean | No | A configurable parameter. Defaults to true in the Playground. (true/false) (default: true) |

### Request example

```json
{
  "modelId": "qwen-image-edit",
  "input": {
    "prompt": "A photorealistic portrait of a red fox in a snowy forest, soft morning light, shallow depth of field, 85mm.",
    "image_url": "https://example.com/input.jpg",
    "acceleration": "none",
    "image_size": "landscape_4_3",
    "num_inference_steps": "25",
    "seed": "1",
    "guidance_scale": "4",
    "sync_mode": false,
    "num_images": "1",
    "enable_safety_checker": true,
    "output_format": "png",
    "negative_prompt": "blurry, low quality, distorted, watermark, text",
    "nsfw_checker": true
  }
}
```

### Response example

```json
{
  "taskId": "281e5b0…f39b9",
  "creditsCharged": 24
}
```

## Query Task

`GET https://you.bot/api/v1/task/{taskId}?model=qwen-image-edit`

When `state` is `success`, the output is in `resultUrls`: `{ "state": "success", "resultUrls": [ ... ] }`. (Text models return inline in the create response.)

## Error Codes

| Code | Description |
|------|-------------|
| 200 | Request successful |
| 400 | Invalid request parameters |
| 401 | Authentication failed, check API Key |
| 402 | Insufficient account balance |
| 422 | Parameter validation failed |
| 429 | Request rate limit exceeded |
| 500 | Internal server error |
