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

# 万相-图像生成与编辑2.7

> 调用阿里云万相 `wan2.7-image-pro` 模型执行图像生成与编辑任务。

请求体的 `input.messages[0].content[]` 数组可包含 `text` 对象（提示词）和/或 `image` 对象（输入图像）。`parameters` 字段控制框选区域 `bbox_list`、组图模式 `enable_sequential`、分辨率 `size`、数量 `n`、思考模式 `thinking_mode`、颜色主题 `color_palette`、水印 `watermark`、随机种子 `seed` 等。该模型支持文生图、图生图和交互式编辑。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/ali/api/wan2.7-image-generation.json POST /ali/api/v1/services/aigc/multimodal-generation/generation
openapi: 3.0.1
info:
  title: 万相-图像生成与编辑2.7
  version: 1.0.0
  description: >-
    阿里云万相2.7图像生成与编辑能力文档。平台统一接口端点为
    `/ali/api/v1/services/aigc/multimodal-generation/generation`。本文档描述了
    `wan2.7-image-pro` 模型的图像生成与编辑调用契约：`input.messages[].content[]`
    携带提示词和/或输入图像，`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: 万相图像生成与编辑能力
paths:
  /ali/api/v1/services/aigc/multimodal-generation/generation:
    post:
      tags:
        - Wan Image
      summary: 万相-图像生成与编辑2.7
      description: >-
        调用阿里云万相 `wan2.7-image-pro` 模型执行图像生成与编辑任务。


        请求体的 `input.messages[0].content[]` 数组可包含 `text` 对象（提示词）和/或 `image`
        对象（输入图像）。`parameters` 字段控制框选区域 `bbox_list`、组图模式 `enable_sequential`、分辨率
        `size`、数量 `n`、思考模式 `thinking_mode`、颜色主题 `color_palette`、水印
        `watermark`、随机种子 `seed` 等。该模型支持文生图、图生图和交互式编辑。
      operationId: aliWan27ImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              文生图:
                summary: 文生图
                value:
                  model: wan2.7-image-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - text: 一间有着精致窗户的花店，漂亮的木质门，摆放着花朵
                  parameters:
                    size: 2K
                    'n': 1
                    watermark: false
                    thinking_mode: true
              图像编辑:
                summary: 图像编辑
                value:
                  model: wan2.7-image-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - image: https://example.com/input.png
                          - text: 将图片中的天空改为星空
                  parameters:
                    size: 1K
                    'n': 1
                    thinking_mode: true
                    watermark: false
              组图模式:
                summary: 组图模式
                value:
                  model: wan2.7-image-pro
                  input:
                    messages:
                      - role: user
                        content:
                          - text: 一组四季风景插画，春、夏、秋、冬
                  parameters:
                    size: 1K
                    'n': 4
                    enable_sequential: true
                    thinking_mode: true
                    watermark: false
      responses:
        '200':
          description: 成功返回图像生成结果。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
              example:
                output:
                  choices:
                    - finish_reason: stop
                      message:
                        content:
                          - image: >-
                              https://dashscope-xxx.oss-xxx.aliyuncs.com/xxx.png?Expires=xxx
                            type: image
                        role: assistant
                  finished: true
                usage:
                  image_count: 1
                  input_tokens: 10867
                  output_tokens: 2
                  size: 1488*704
                  total_tokens: 10869
                request_id: 71dfc3c6-f796-9972-97e4-bc4efc4faxxx
        '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:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - wan2.7-image-pro
          description: 模型名称。可选值：`wan2.7-image-pro`。
        input:
          $ref: '#/components/schemas/WanImageInput'
        parameters:
          $ref: '#/components/schemas/WanImageParameters'
    ImageResponse:
      type: object
      properties:
        output:
          $ref: '#/components/schemas/WanImageOutput'
        usage:
          $ref: '#/components/schemas/WanImageUsage'
        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: 请求ID。
    WanImageInput:
      type: object
      required:
        - messages
      properties:
        messages:
          type: array
          minItems: 1
          maxItems: 1
          description: 当前仅支持单轮对话，即传入一组 `role`、`content` 参数。
          items:
            $ref: '#/components/schemas/WanImageMessage'
    WanImageParameters:
      type: object
      properties:
        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
              minItems: 4
              maxItems: 4
        enable_sequential:
          type: boolean
          default: false
          description: 控制生图模式。`false`（默认值）：普通模式。`true`：启用组图输出模式。
        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-options:
            - label: 1K
              value: 1K
            - label: 2K
              value: 2K
            - label: 4K
              value: 4K
        'n':
          type: integer
          minimum: 1
          default: 1
          description: |-
            重要：n 直接影响费用。费用 = 单价 × 成功生成的图片张数，请在调用前确认模型价格。

            关闭组图模式时，该数值代表生成图像数量，取值范围 1-4，默认为 1；
            开启组图模式时，该数值代表最大生成图像数量，取值范围 1-12，默认为 12。实际数量由模型决定且不超过 n。
        thinking_mode:
          type: boolean
          default: true
          description: >-
            是否开启思考模式，默认为
            true（开启）。仅在关闭组图模式且无图片输入时生效。开启时，模型将增强推理能力以提升出图质量，但会增加生成耗时。
        color_palette:
          type: array
          description: >-
            自定义颜色主题，一个包含颜色（hex）和占比（ratio）的对象数组。需要包含 3 至 10 种颜色，推荐设置为 8
            种。仅当关闭组图模式（enable_sequential=false）时可用。
          items:
            type: object
            required:
              - hex
              - ratio
            properties:
              hex:
                type: string
                description: 十六进制（HEX）格式的色值，例如 `#C2D1E6`。
              ratio:
                type: string
                description: 颜色所占的百分比，需精确到小数点后两位，如 `"23.51%"`。所有 ratio 值相加总和必须为 100.00%。
        watermark:
          type: boolean
          default: false
          description: 是否添加水印标识，水印位于图片右下角，文案固定为 "AI生成"。`false`（默认值）：不添加水印。`true`：添加水印。
        seed:
          type: integer
          format: int64
          minimum: 0
          maximum: 2147483647
          description: |-
            随机数种子，取值范围[0,2147483647]。

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

            注意：模型生成过程具有概率性，即使使用相同的seed，也不能保证每次生成结果完全一致。
    WanImageOutput:
      type: object
      properties:
        choices:
          type: array
          description: 生成结果列表。
          items:
            $ref: '#/components/schemas/WanImageChoice'
        finished:
          type: boolean
          description: 任务是否结束。
    WanImageUsage:
      type: object
      properties:
        image_count:
          type: integer
          description: 生成图像的张数。
        size:
          type: string
          description: 生成的图像分辨率，例如 `1376*768`。
        input_tokens:
          type: integer
          description: 输入 token 数量（不计费）。按图片张数计费。
        output_tokens:
          type: integer
          description: 输出 token 数量（不计费）。按图片张数计费。
        total_tokens:
          type: integer
          description: 总 token 数量（不计费）。按图片张数计费。
    WanImageMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: 固定为 `user`。
        content:
          type: array
          minItems: 1
          description: 消息内容数组。包含 `text` 和/或 `image` 对象。支持 0-9 张图片。
          items:
            $ref: '#/components/schemas/WanImageContentItem'
    WanImageChoice:
      type: object
      properties:
        finish_reason:
          type: string
          description: 结束原因，成功时为 `stop`。
        message:
          $ref: '#/components/schemas/WanImageChoiceMessage'
    WanImageContentItem:
      type: object
      properties:
        text:
          type: string
          maxLength: 5000
          description: 用户输入提示词。支持中英文，长度不超过 5000 个字符，每个汉字、字母、数字或符号计为一个字符，超过部分会自动截断。
        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,...`。
    WanImageChoiceMessage:
      type: object
      properties:
        role:
          type: string
          description: 角色，固定为 `assistant`。
        content:
          type: array
          description: 生成内容列表。
          items:
            $ref: '#/components/schemas/WanImageChoiceContentItem'
    WanImageChoiceContentItem:
      type: object
      properties:
        type:
          type: string
          description: 输出类型，固定为 `image`。
        image:
          type: string
          description: 生成图像的 URL，图像格式为 PNG。链接有效期为 24 小时，请及时下载并保存图像。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传递 `Authorization: Bearer <token>`。'

````