> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powertokens.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Qwen 图像编辑

> 调用 Ali `qwen-image-2.0-pro` 执行单图编辑或多图融合。

公开调用方案保留顶层 `model`、`input`、`response_format`，并将 `n`、`size`、`watermark`、`prompt_extend`、`negative_prompt`、`seed` 设计为顶层字段。输入图片位于 `input.messages[0].content[].image`，编辑指令位于同一数组中的 `text`。请求体不接受顶层 `parameters`。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/ali/qwen-edit.json POST /v1/images/edits
openapi: 3.0.1
info:
  title: Qwen 图像编辑
  version: 1.0.0
  description: >-
    阿里 Qwen 图像编辑能力文档。公开统一入口为 `/v1/images/edits`，当前文档描述 `qwen-image-2.0-pro`
    对外公开的网关契约：保留 `input.messages[].content[]` 承载图片与文本指令，其余控制字段使用顶层 OpenAI
    风格字段，由网关映射到上游 `parameters`。
  license:
    name: Project License
    url: https://github.com/QuantumNous/new-api/blob/main/LICENSE
servers:
  - url: https://api.powertokens.ai
    description: Baze API 服务地址
security: []
tags:
  - name: Qwen Image
    description: Qwen 图像编辑能力
paths:
  /v1/images/edits:
    post:
      tags:
        - Qwen Image
      summary: Qwen 图像编辑
      description: >-
        调用 Ali `qwen-image-2.0-pro` 执行单图编辑或多图融合。


        公开调用方案保留顶层 `model`、`input`、`response_format`，并将
        `n`、`size`、`watermark`、`prompt_extend`、`negative_prompt`、`seed`
        设计为顶层字段。输入图片位于 `input.messages[0].content[].image`，编辑指令位于同一数组中的
        `text`。请求体不接受顶层 `parameters`。
      operationId: aliQwenImageEdit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageEditRequest'
            examples:
              single_image_edit:
                summary: 单图编辑
                value:
                  model: qwen-image-2.0-pro
                  response_format: url
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://example.com/source.webp
                          - text: 将背景替换成海边日落
                  'n': 2
                  size: 1536*1024
                  watermark: false
                  prompt_extend: true
                  negative_prompt: 低质量
                  seed: 0
              multi_image_fusion:
                summary: 多图融合
                value:
                  model: qwen-image-2.0-pro
                  response_format: url
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://example.com/input1.png
                          - image: https://example.com/input2.png
                          - image: https://example.com/input3.png
                          - text: 图1中的女生穿着图2中的黑色裙子按图3的姿势坐下
                  'n': 2
                  size: 1024*1536
                  watermark: false
                  prompt_extend: true
                  negative_prompt: 低分辨率
      responses:
        '200':
          description: 调用成功，返回图像编辑结果。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '400':
          description: 请求参数不合法。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 鉴权失败，例如未提供令牌或令牌无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: 请求体过大。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: 触发速率限制或账户额度不足。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 服务端处理请求时发生内部错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: 上游服务返回异常响应。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: 上游服务暂不可用，或当前模型暂无可用渠道。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    ImageEditRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - qwen-image-2.0-pro
          description: 模型名称。示例值：`qwen-image-2.0-pro`。
        response_format:
          type: string
          enum:
            - url
            - b64_json
          description: 响应格式。`url` 返回图片下载链接；`b64_json` 返回 Base64 编码的图片数据。默认值为 `url`。
          default: url
        input:
          $ref: '#/components/schemas/QwenImageInput'
        'n':
          type: integer
          minimum: 1
          maximum: 6
          default: 1
          description: 输出图像数量，默认值为 1。对于 `qwen-image-2.0` 系列模型，可选择输出 1-6 张图片。
        size:
          type: string
          description: >-
            输出图像分辨率，格式为 `宽*高`，例如 `1024*1536`。`qwen-image-2.0` 系列模型输出图像总像素需在
            `512*512` 至 `2048*2048` 之间。默认总像素接近
            `1024*1024`，宽高比贴近输入图片（多图时以最后一张为准）。推荐常用分辨率：1:1
            `1024*1024`、`1536*1536`；2:3 `768*1152`、`1024*1536`；3:2
            `1152*768`、`1536*1024`；3:4 `960*1280`、`1080*1440`；4:3
            `1280*960`、`1440*1080`；9:16 `720*1280`、`1080*1920`；16:9
            `1280*720`、`1920*1080`；21:9 `1344*576`、`2048*872`。
          x-options:
            - label: 512*512
              value: 512*512
            - label: 1K
              value: 1000*1000
            - label: 2K
              value: 2000*2000
          default: 512*512
        watermark:
          type: boolean
          description: 是否在图像右下角添加 "Qwen-Image" 水印。默认值为 `false`。
          default: false
        prompt_extend:
          type: boolean
          default: true
          description: 是否开启提示词智能改写，默认值为 true。开启后，模型会优化正向提示词（text），对描述较简单的提示词效果提升明显。
        negative_prompt:
          type: string
          maxLength: 500
          description: >-
            反向提示词，用于描述不希望在图像中出现的内容，对画面进行限制。支持中英文，长度不超过 500
            个字符，超出部分将自动截断。示例值：低分辨率，低画质，肢体畸形，手指畸形，画面过饱和，蜡像感，人脸无细节，过度光滑，画面具有AI感。构图混乱。文字模糊，扭曲。
        seed:
          type: integer
          format: int64
          minimum: 0
          maximum: 2147483647
          description: >-
            随机数种子，取值范围 [0, 2147483647]。使用相同的 `seed`
            参数值可使生成内容保持相对稳定。若不提供，算法将自动使用随机数种子。注意：模型生成过程具有概率性，即使使用相同的
            `seed`，也不能保证每次生成结果完全一致。
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
          format: int64
          description: 创建时间的 Unix 时间戳（秒）。
        data:
          type: array
          description: 生成的图像列表。
          items:
            $ref: '#/components/schemas/ImageData'
        metadata:
          type: object
          description: 附加结果信息。字段内容会随能力不同而变化。
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              description: 错误类型，例如 `invalid_request_error`、`api_error` 或上游兼容错误类型。
            code:
              type: string
            param:
              type: string
    QwenImageInput:
      type: object
      required:
        - messages
      properties:
        messages:
          type: array
          minItems: 1
          maxItems: 1
          description: 请求内容数组。当前仅支持单轮对话，数组内有且只有一个元素。
          items:
            $ref: '#/components/schemas/QwenImageMessage'
    ImageData:
      type: object
      properties:
        url:
          type: string
          description: 图片下载链接。有效期 24 小时。
        b64_json:
          type: string
          description: Base64 编码的图片数据。
        revised_prompt:
          type: string
          description: 优化后的提示词。
    QwenImageMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: 消息角色。此参数必须设置为 `user`。
        content:
          type: array
          minItems: 2
          maxItems: 4
          description: >-
            消息内容。包含 1-3 个 `{"image":"..."}` 格式的图片对象和 1 个 `{"text":"..."}`
            格式的编辑指令。
          items:
            $ref: '#/components/schemas/QwenImageContent'
    QwenImageContent:
      type: object
      required:
        - image
        - text
      properties:
        image:
          type: string
          description: >-
            输入图像的 URL 或 Base64
            编码数据。支持传入1-3张图像。多图输入时，按照数组顺序定义图像顺序，输出图像的比例以最后一张为准。图像要求：图像格式：JPG、JPEG、PNG、BMP、TIFF、WEBP和GIF。输出图像为PNG格式，对于GIF动图，仅处理其第一帧。图像分辨率：为获得最佳效果，建议图像的宽和高均在384像素至3072像素之间。分辨率过低可能导致生成效果模糊，过高则会增加处理时长。图像大小：不超过10MB。支持的输入格式：公网URL（支持
            HTTP 和 HTTPS 协议）、临时URL（支持OSS协议，`oss://` 前缀）、传入 Base64
            编码图像后的字符串（`data:image/jpeg;base64,...`）。
        text:
          type: string
          description: >-
            编辑指令。支持中英文，`qwen-image-2.0` 系列模型长度上限为 1300
            Token，超出部分将自动截断。注意：仅支持传入一个 `text`，不传或传入多个将报错。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````