> ## 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-image-2.0-pro` 模型执行图像编辑任务。`input.messages[0].content[]` 数组需包含 1-3 个 `image` 对象（输入图像 URL 或 Base64）和 1 个 `text` 对象（编辑指令）。`parameters` 字段控制输出数量 `n`、反向提示词 `negative_prompt`、分辨率 `size`、提示词智能改写 `prompt_extend`、水印 `watermark`、随机种子 `seed` 等。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/ali/api/qwen-image-edit.json POST /ali/api/v1/services/aigc/multimodal-generation/generation
openapi: 3.0.1
info:
  title: 千问-图像编辑
  version: 1.0.0
  description: >-
    阿里云千问图像编辑能力文档。平台统一接口端点为
    `/ali/api/v1/services/aigc/multimodal-generation/generation`。本文档描述了
    `qwen-image-2.0-pro`模型的图像编辑调用契约：`input.messages[].content[]`
    携带1-3张输入图像和1条编辑指令，`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: 千问图像编辑能力
paths:
  /ali/api/v1/services/aigc/multimodal-generation/generation:
    post:
      tags:
        - Qwen Image
      summary: 千问-图像编辑
      description: >-
        调用阿里云千问 `qwen-image-2.0-pro` 模型执行图像编辑任务。`input.messages[0].content[]`
        数组需包含 1-3 个 `image` 对象（输入图像 URL 或 Base64）和 1 个 `text`
        对象（编辑指令）。`parameters` 字段控制输出数量 `n`、反向提示词 `negative_prompt`、分辨率
        `size`、提示词智能改写 `prompt_extend`、水印 `watermark`、随机种子 `seed` 等。
      operationId: aliQwenImageEdit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageEditRequest'
            examples:
              qwen_image_2_pro_edit:
                summary: Qwen-Image-2.0 Pro 图像编辑
                value:
                  model: qwen-image-2.0-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - image: >-
                              https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260310/jiydyi/image+%2818%29-2026-03-10-16-39-59.webp
                          - text: >-
                              在画面右下角石板路旁、靠近树干根部的位置，以浅灰墨色手写体题写一首七言绝句，字体为行楷风格，笔触自然流畅、略带飞白，大小适中（约占画面高度1/10），与整体水墨淡雅氛围协调。诗文内容为：“青石桥畔柳风轻，
                              素手拈花闭目听。 一水碧痕浮旧梦，
                              半篙烟雨入空舲。”诗句横向排列，四句分两行书写（前两句一行，后两句一行），末句“舲”字右下角钤一枚朱红小印，印文为“江南”二字篆书，尺寸约等于单字高度的1/3。
                  parameters:
                    'n': 1
                    negative_prompt: ' '
                    prompt_extend: true
                    watermark: false
                    size: 2048*2048
      responses:
        '200':
          description: 成功返回图像编辑结果。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
              examples:
                success:
                  summary: 成功响应
                  value:
                    output:
                      choices:
                        - finish_reason: stop
                          message:
                            content:
                              - image: >-
                                  https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx
                            role: assistant
                    usage:
                      height: 2048
                      image_count: 1
                      width: 2048
                    request_id: 571ae02f-5c9d-436c-83c2-f221e6df0xxx
        '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`。
        input:
          $ref: '#/components/schemas/QwenImageEditInput'
        parameters:
          $ref: '#/components/schemas/QwenImageEditParameters'
    ImageResponse:
      type: object
      properties:
        output:
          $ref: '#/components/schemas/ImageOutput'
          description: 包含模型生成结果。
        usage:
          $ref: '#/components/schemas/ImageUsage'
        request_id:
          type: string
          description: 请求唯一标识。可用于请求明细溯源和问题排查。
        code:
          type: string
          description: 请求失败的错误码。请求成功时不会返回此参数。
        message:
          type: string
          description: 请求失败的详细信息。请求成功时不会返回此参数。
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: 请求失败的错误码。请求成功时不会返回此参数。
        message:
          type: string
          description: 请求失败的详细信息。请求成功时不会返回此参数。
        request_id:
          type: string
          description: 请求唯一标识。可用于请求明细溯源和问题排查。
    QwenImageEditInput:
      type: object
      required:
        - messages
      properties:
        messages:
          type: array
          minItems: 1
          maxItems: 1
          description: 请求内容数组。当前仅支持单轮对话，因此数组内有且只有一个对象，该对象包含 `role` 和 `content` 两个属性。
          items:
            $ref: '#/components/schemas/QwenImageEditMessage'
      description: 输入参数对象。
    QwenImageEditParameters:
      type: object
      properties:
        negative_prompt:
          type: string
          maxLength: 500
          description: >-
            反向提示词，用来描述不希望在画面中看到的内容，可以对画面进行限制。支持中英文，长度上限 500
            个字符，每个汉字、字母、数字或符号计为一个字符，超过部分会自动截断。示例值：低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。
        'n':
          type: integer
          minimum: 1
          maximum: 6
          default: 1
          description: 输出图像的数量，默认值为 1。对于 `qwen-image-2.0` 系列模型，可选择输出 1-6 张图片。
        watermark:
          type: boolean
          default: false
          description: 是否在图像右下角添加 "Qwen-Image" 水印。默认值为 `false`。
        seed:
          type: integer
          format: int64
          minimum: 0
          maximum: 2147483647
          description: >-
            随机数种子，取值范围 [0, 2147483647]。使用相同的 `seed`
            参数值可使生成内容保持相对稳定。若不提供，算法将自动使用随机数种子。注意：模型生成过程具有概率性，即使使用相同的
            `seed`，也不能保证每次生成结果完全一致。
        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`。
        prompt_extend:
          type: boolean
          default: true
          description: 是否开启提示词智能改写，默认值为 `true`。开启后，模型会优化正向提示词（`text`），对描述较简单的提示词效果提升明显。
      description: 控制图像生成的附加参数。
    ImageOutput:
      type: object
      properties:
        choices:
          type: array
          description: 结果选项列表。
          items:
            $ref: '#/components/schemas/ImageChoice'
    ImageUsage:
      type: object
      properties:
        image_count:
          type: integer
          description: 生成图像的张数。
        width:
          type: integer
          description: 生成图像的宽度（像素）。
        height:
          type: integer
          description: 生成图像的高度（像素）。
      description: 本次调用的资源使用情况，仅调用成功时返回。
    QwenImageEditMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: 消息发送者角色，必须设置为 `user`。
        content:
          type: array
          minItems: 1
          maxItems: 1
          description: 消息内容，包含 1-3 张图像，格式为 `{"image":"..."}`；以及单个编辑指令，格式为 `{"text":"..."}`。
          items:
            $ref: '#/components/schemas/QwenImageEditContentItem'
    ImageChoice:
      type: object
      properties:
        finish_reason:
          type: string
          description: 任务停止原因，自然停止时为 `stop`。
        message:
          $ref: '#/components/schemas/ImageChoiceMessage'
    QwenImageEditContentItem:
      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 协议。


            示例值：`https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/fpakfo/image36.webp`。


            临时URL：


            支持OSS协议，必须通过上传文件获取临时 URL。


            示例值：oss://dashscope-instant/xxx/2024-07-18/xxx/cat.png。


            传入 Base64 编码图像后的字符串


            示例值：data:image/jpeg;base64,GDU7MtCZz...（示例已截断，仅做演示）
        text:
          type: string
          description: >-
            正向提示词用于描述您期望生成的图像内容、风格和构图。支持中英文，`qwen-image-2.0` 系列模型长度上限为 1300
            Token，超出部分将自动截断。注意：仅支持传入一个 `text`，不传或传入多个将报错。
    ImageChoiceMessage:
      type: object
      properties:
        role:
          type: string
          description: 消息的角色，固定为 `assistant`。
        content:
          type: array
          description: 消息内容，包含生成的图像信息。
          items:
            $ref: '#/components/schemas/ImageChoiceContentItem'
      description: 模型返回的消息。
    ImageChoiceContentItem:
      type: object
      properties:
        image:
          type: string
          description: 生成图像的 URL，格式为 PNG。链接有效期为 24 小时，请及时下载并保存图像。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传递 `Authorization: Bearer <token>`。'

````