> ## 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.

# Wan 图像编辑

> 调用 Ali `wan2.7-image-pro` 执行图像编辑。

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



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/ali/wan-edit.json POST /v1/images/edits
openapi: 3.0.1
info:
  title: Wan 图像编辑
  version: 1.0.0
  description: >-
    阿里 Wan 图像编辑能力文档。公开统一入口为 `/v1/images/edits`，当前文档描述 `wan2.7-image-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: Wan Image
    description: Wan 图像编辑能力
paths:
  /v1/images/edits:
    post:
      tags:
        - Wan Image
      summary: Wan 图像编辑
      description: >-
        调用 Ali `wan2.7-image-pro` 执行图像编辑。


        公开调用方案保留顶层 `model`、`input`、`response_format`，并将
        `size`、`n`、`watermark`、`negative_prompt`、`seed`、`bbox_list`
        设计为顶层字段。输入图片位于 `input.messages[0].content[].image`，编辑指令位于同一数组中的
        `text`。请求体不接受顶层 `parameters`。
      operationId: aliWanImageEdit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WanImageEditRequest'
            examples:
              image_edit:
                summary: 图像编辑
                value:
                  model: wan2.7-image-pro
                  response_format: url
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://example.com/car.webp
                          - image: https://example.com/paint.webp
                          - text: 把图2的涂鸦喷绘在图1的汽车上
                  size: 2K
                  'n': 1
                  watermark: false
                  negative_prompt: 保留原车身颜色
                  seed: 0
              interactive_edit:
                summary: 交互式编辑
                value:
                  model: wan2.7-image-pro
                  response_format: url
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://example.com/clock.webp
                          - image: https://example.com/room.webp
                          - text: 把图1的闹钟放在图2框选的位置
                  bbox_list:
                    - []
                    - - - 989
                        - 515
                        - 1138
                        - 681
                  size: 2K
                  'n': 1
                  watermark: false
      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:
    WanImageEditRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - wan2.7-image-pro
          description: 模型名称。可选值：`wan2.7-image-pro`。
        response_format:
          type: string
          enum:
            - url
            - b64_json
          description: 统一响应格式。支持的值：`url` 或 `b64_json`。
          default: url
        input:
          $ref: '#/components/schemas/WanImageInput'
        size:
          type: string
          description: |-
            关于输出图片分辨率参数，支持以下两种方式，不可混用：

            **方式一：指定输出图片的分辨率（推荐）**
            支持 1K、2K（默认）、4K 三种规格。
            - 文生图（无图片输入，非组图生成）：支持 1K、2K、4K。
            - 其他场景：支持 1K、2K。
            - 各规格总像素：1K：1024×1024、2K：2048×2048、4K：4096×4096。
            - 当有图片输入时：输出宽高比与输入图像（多图输入时为最后一张）一致，并缩放到选定分辨率。
            - 当没有图片输入时：输出为正方形。

            **方式二：指定生成图像的宽高像素值**
            格式：`{width}*{height}`，例如 `1024*768`。
            - 文生图：总像素在 [768×768, 4096×4096] 之间，宽高比范围 [1:8, 8:1]。
            - 其他场景：总像素在 [768×768, 2048×2048] 之间，宽高比范围 [1:8, 8:1]。

            注意：输出图片的像素值可能和指定像素值存在微小差异。
          x-enum:
            - 1K
            - 2K
          default: 1K
        'n':
          type: integer
          minimum: 1
          maximum: 12
          description: |-
            重要：n 直接影响费用。费用 = 单价 × 成功生成的图片张数，请在调用前确认模型价格。

            关闭组图模式时，该数值代表生成图像数量，取值范围 1-4，默认为 1；

            开启组图模式时，该数值代表最大生成图像数量，取值范围 1-12，默认为 12。实际数量由模型决定且不超过 n。
        watermark:
          type: boolean
          description: 是否添加水印标识，水印位于图片右下角，文案固定为 "AI生成"。`false`（默认值）：不添加水印。`true`：添加水印。
          default: false
        negative_prompt:
          type: string
          description: 反向提示词，描述输出中应避免的内容。
        seed:
          type: integer
          description: |-
            随机数种子，取值范围 [0, 2147483647]。

            使用相同的 seed 参数值可使生成内容保持相对稳定。若不提供，算法将自动使用随机数种子。

            注意：模型生成过程具有概率性，即使使用相同的 seed，也不能保证每次生成结果完全一致。
          default: 0
          minimum: 0
          maximum: 2147483647
        bbox_list:
          type: array
          description: >+
            交互式编辑框选区域。


            对应关系：列表长度必须与输入图片数量一致。若某张图片无需编辑，请在对应位置传入空列表 `[]`。


            坐标格式：[x1, y1, x2, y2]（左上角 x, 左上角 y, 右下角 x, 右下角
            y），使用原图绝对像素坐标，左上角坐标为（0，0）。


            限制条件：单张图片最多支持 2 个边界框。


            示例：输入 3 张图片，其中第 2 张无框选，第 1 张有两个框选：


            ```

            [
              [[0, 0, 12, 12], [25, 25, 100, 100]],  # 图 1 (2个框)
              [],                                    # 图 2 (无框)
              [[10, 10, 50, 50]]                    # 图 3 (1个框)
            ]

            ```

          items:
            type: array
            items:
              type: array
              items:
                type: integer
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
          format: int64
          description: 响应生成时间戳。
        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
    WanImageInput:
      type: object
      required:
        - messages
      properties:
        messages:
          type: array
          minItems: 1
          maxItems: 1
          description: 请求内容数组。当前仅支持单轮对话，即传入一组 role、content 参数，不支持多轮对话。
          items:
            $ref: '#/components/schemas/WanImageMessage'
    ImageData:
      type: object
      properties:
        url:
          type: string
          description: 当结果以 URL 返回时使用。
        b64_json:
          type: string
          description: 当结果以 Base64 返回时使用。
        revised_prompt:
          type: string
          description: 上游返回的改写提示词。
    WanImageMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: 固定为 `user`。
        content:
          type: array
          description: 消息内容数组。包含 `text` 和/或 `image` 对象。
          items:
            $ref: '#/components/schemas/WanImageContent'
    WanImageContent:
      type: object
      properties:
        image:
          type: string
          description: |-
            输入图像的URL或Base64编码字符串。

            图像限制：

            图像格式：JPEG、JPG、PNG（不支持透明通道）、BMP、WEBP。

            图像分辨率：图像的宽高范围均为[240, 8000]像素，宽高比范围[1:8, 8:1]。

            文件大小：不超过20MB。

            图像数量限制：

            可传入0-9张图片。

            当输入多张图像时，需在content数组中传入多个image对象，并按照数组顺序定义图像顺序。

            支持的输入格式：

            - 使用公网可访问URL
              支持HTTP或HTTPS协议。
              示例值：`http://wanx.alicdn.com/material/xxx.jpeg`。

            - 传入 Base64 编码图像后的字符串
              格式：data:{MIME_type};base64,{base64_data}
              示例：data:image/jpeg;base64,GDU7MtCZzEbTbmRZ...（仅示意，实际需传入完整字符串）。
        text:
          type: string
          maxLength: 5000
          description: 用户输入提示词。支持中英文，长度不超过 5000 个字符，每个汉字、字母、数字或符号计为一个字符，超过部分会自动截断。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````