# Qwen Image 图像生成与编辑

适用于模型 ID 为 `qwen-image-*` 的模型。

接口、同步等待限制、成功响应与错误码等公共说明，见[图像生成与编辑总览](https://docs.myaigf.cfd/api/images)。

## 生成

`POST /v1/images/generations`，JSON 请求体。

| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `model` | string | 是 | 模型 ID，区分大小写 |
| `prompt` | string | 是 | 1–32000 字符 |
| `n` | integer | 否 | 生成数量，1–10 |
| `resolution` | string | 否 | `1k`、`2k`、`4k`，默认 `1k` |
| `aspect_ratio` | string | 否 | `1:1`、`3:2`、`2:3`、`4:3`、`3:4`、`16:9`、`9:16` |
| `quality` | string | 否 | `low`、`medium`、`high`、`xhigh`、`max`、`auto` |
| `size` | string | 否 | `auto` 或 `WIDTHxHEIGHT`；宽高为 16 的倍数，短边不小于 256，长边不超过 3840，长宽比不超过 3:1，总像素不超过 8294400 |
| `image` | string | 否 | 单张参考图 |
| `images` | string[] | 否 | 参考图，最多 3 张 |
| `response_format` | string | 否 | `url` 或 `b64_json` |
| `output_format` | string | 否 | `png`、`jpeg`、`webp` |

**提示：size 与 resolution / aspect_ratio**

`size` 与 `resolution` / `aspect_ratio` 不要同时使用。

```bash
curl "https://YOUR_API_BASE_URL/v1/images/generations" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_QWEN_IMAGE_MODEL",
    "prompt": "一张白底产品照片，柔和阴影",
    "n": 1,
    "resolution": "1k",
    "aspect_ratio": "16:9",
    "quality": "high"
  }'
```

## 编辑

`POST /v1/images/edits`，使用 `multipart/form-data`，上传 1–3 张参考图：

```bash
curl "https://YOUR_API_BASE_URL/v1/images/edits" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -F "model=YOUR_QWEN_IMAGE_MODEL" \
  -F "prompt=保持产品外观，把背景改成浅灰色" \
  -F "image=@reference.png"
```

## 相关阅读

- [图像生成与编辑总览](https://docs.myaigf.cfd/api/images)
- [GPT Image 系列](https://docs.myaigf.cfd/api/images-gpt)
- [Seedream 系列](https://docs.myaigf.cfd/api/images-seedream)
- [文件与素材](https://docs.myaigf.cfd/api/files)
- [错误与重试](https://docs.myaigf.cfd/guide/errors)
