Qwen Image Edit API 文档

用于外部系统调用图片编辑能力。支持登录态和 Bearer API Key 两种鉴权方式。

接口地址

POST /api/qwen-image-edit

鉴权方式

  • 登录态会话(浏览器 Cookie)
  • API Key(请求头): Authorization: Bearer sk-xxxxxxxx

请求参数

  • instruction / prompt: 编辑指令(最多 800 字符)
  • model: 可选,默认 chatgpt-image-2-free;也可传 chatgpt-image-2 作为别名
  • imageUrl / imageUrls / imageBase64: 至少提供一个图片输入,最多 4 张;不同模型的上限见下方模型表
  • n: 输出图片数量;当前图片编辑模型最多输出 1 张,多余数量会按模型上限裁剪
  • aspectRatio: 比例取值依模型而定。ChatGPT Image 2 Free 支持 auto、1:1、3:2、2:3
  • 可选字段:watermark, negative_prompt, size, prompt_extend

支持的模型

model名称输入图输出图aspectRatio积分/张
chatgpt-image-2-freeChatGPT Image 2 Free41auto, 1:1, 3:2, 2:36
gpt-image-2GPT Image 211由上游模型决定6
nano-banana-2Nano Banana 241auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 21:96
gpt-image-1-5GPT Image 1.5111:1, 3:2, 2:36 或 22
seedream-5-0Seedream 5.041auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 21:96
qwen-imageQwen Image311:1, 16:9, 9:16, 4:3, 3:46

未传 model 时会使用 chatgpt-image-2-free。gpt-image-2 和 chatgpt-image-2-free 是不同上游通道,推荐优先使用 chatgpt-image-2-free。

cURL 示例:ChatGPT Image 2

curl -X POST "https://qwen-image-edit.com/api/qwen-image-edit" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -d '{
    "model": "chatgpt-image-2-free",
    "imageUrls": ["https://your-cdn.com/input.jpg"],
    "instruction": "把背景改成雪山,主体保持不变",
    "aspectRatio": "1:1",
    "n": 1
  }'

Python 示例

import requests

url = "https://qwen-image-edit.com/api/qwen-image-edit"
headers = {
    "Authorization": "Bearer sk-your-api-key",
    "Content-Type": "application/json",
}
payload = {
    "model": "chatgpt-image-2-free",
    "imageUrls": ["https://your-cdn.com/input.jpg"],
    "instruction": "把背景改成雪山,主体保持不变",
    "aspectRatio": "1:1",
    "n": 1,
}

response = requests.post(url, json=payload, headers=headers, timeout=120)
response.raise_for_status()
print(response.json())

价格与积分

API 与网页共用积分账户。完整套餐见定价页;下表为当前公开积分单价摘要。 查看定价

项目积分说明
图片编辑 / 文生图6多数模型每次输出 1 张
视频生成21按次计费
新用户赠送15注册后到账
Basic 月付600 / mo$9.90
Pro 月付1300 / mo$19.90
Max 月付2100 / mo$29.90

成功响应示例

{
  "data": [
    {
      "url": "data:image/png;base64,iVBORw0K...",
      "index": 0
    }
  ],
  "cost": 6,
  "warnings": [],
  "generation": {
    "uuid": "generation-uuid",
    "stored_images": ["https://your-storage.com/result.png"]
  },
  "usage": {
    "prompt_tokens": 1,
    "completion_tokens": 1,
    "total_tokens": 2
  },
  "model": "chatgpt-image-2-free"
}

常见错误码

  • 400: 参数错误
  • 401: 未认证
  • 402: 积分不足
  • 500: 服务异常
API 文档 - Qwen Image Edit