> ## 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`、`thinking_mode`、`enable_sequential`、`color_palette`、`seed` 设计为顶层字段。提示词位于 `input.messages[0].content[0].text`。请求体不接受顶层 `parameters`。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/ali/wan-text-to-image.json POST /v1/images/generations
openapi: 3.0.1
info:
  title: Wan 文生图
  version: 1.0.0
  description: >-
    阿里 Wan 文生图能力文档。公开统一入口为 `/v1/images/generations`，当前文档描述 `wan2.7-image-pro`
    对外公开的网关契约：保留 `input.messages[].content[].text` 承载提示词，其余控制字段使用顶层 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/generations:
    post:
      tags:
        - Wan Image
      summary: Wan 文生图
      description: >-
        调用 Ali `wan2.7-image-pro` 执行文生图。


        公开调用方案保留顶层 `model`、`input`、`response_format`，并将
        `size`、`n`、`watermark`、`thinking_mode`、`enable_sequential`、`color_palette`、`seed`
        设计为顶层字段。提示词位于 `input.messages[0].content[0].text`。请求体不接受顶层 `parameters`。
      operationId: aliWanTextToImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WanTextToImageRequest'
            examples:
              basic_generation:
                summary: 基础文生图
                value:
                  model: wan2.7-image-pro
                  response_format: url
                  input:
                    messages:
                      - role: user
                        content:
                          - text: 一间有着精致窗户的花店，漂亮的木质门，摆放着花朵
                  size: 2K
                  'n': 1
                  watermark: false
                  thinking_mode: true
                  seed: 0
              sequential_generation:
                summary: 组图生成
                value:
                  model: wan2.7-image-pro
                  response_format: url
                  input:
                    messages:
                      - role: user
                        content:
                          - text: >-
                              电影感组图，记录同一只流浪橘猫，特征必须前后一致。第一张：春天，橘猫穿梭在盛开的樱花树下；第二张：夏天，橘猫在老街的树荫下乘凉避暑；第三张：秋天，橘猫踩在满地的金色落叶上；第四张：冬天，橘猫在雪地上走留下足迹。
                  enable_sequential: true
                  'n': 4
                  size: 2K
                  color_palette:
                    - hex: '#C2D1E6'
                      ratio: 23.51%
                    - hex: '#CDD8E9'
                      ratio: 20.13%
                    - hex: '#B5C8DB'
                      ratio: 15.88%
      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:
    WanTextToImageRequest:
      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/WanTextToImageInput'
        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
            - 4K
          default: 1K
        'n':
          type: integer
          minimum: 1
          maximum: 12
          description: |-
            重要：`n` 直接影响费用。费用 = 单价 × 成功生成的图片张数，请在调用前确认模型价格。

            必填范围：1 <= n <= 12。

            关闭组图模式时，该数值代表生成图像数量，取值范围 1-4，默认为 1；
            开启组图模式时，该数值代表最大生成图像数量，取值范围 1-12，默认为 12。实际数量由模型决定且不超过 `n`。
        watermark:
          type: boolean
          description: 是否添加水印标识，水印位于图片右下角，文案固定为 "AI生成"。`false`（默认值）：不添加水印。`true`：添加水印。
          default: false
        thinking_mode:
          type: boolean
          description: 是否开启思考模式，默认为 `true`（开启）。开启时，模型将增强推理能力以提升出图质量，但会增加生成耗时。仅在关闭组图模式时生效。
        enable_sequential:
          type: boolean
          description: 控制生成模式。`false`（默认）：普通模式。`true`：开启组图输出模式。
        color_palette:
          type: array
          description: >-
            自定义颜色主题，一个包含颜色（hex）和占比（ratio）的对象数组。需要包含 3 至 10 种颜色，推荐设置为 8
            种。仅当关闭组图模式（`enable_sequential=false`）时可用。
          items:
            $ref: '#/components/schemas/WanColorPaletteItem'
        seed:
          type: integer
          format: int64
          description: |-
            随机数种子，取值范围 [0, 2147483647]。

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

            注意：模型生成过程具有概率性，即使使用相同的 seed，也不能保证每次生成结果完全一致。
          default: 0
          minimum: 0
    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:
          $ref: '#/components/schemas/ErrorObject'
    WanTextToImageInput:
      type: object
      required:
        - messages
      properties:
        messages:
          type: array
          minItems: 1
          maxItems: 1
          description: 请求内容数组。当前仅支持单轮对话，即传入一组 role、content 参数，不支持多轮对话。
          items:
            $ref: '#/components/schemas/WanTextToImageMessage'
    WanColorPaletteItem:
      type: object
      required:
        - hex
        - ratio
      properties:
        hex:
          type: string
          description: HEX 颜色值，例如 `#C2D1E6`。
        ratio:
          type: string
          description: 颜色百分比，精确到小数点后 2 位，例如 `"23.51%"`。所有比例之和必须为 100.00%。
    ImageData:
      type: object
      properties:
        url:
          type: string
          description: 当结果以 URL 返回时使用。
        b64_json:
          type: string
          description: 当结果以 Base64 返回时使用。
        revised_prompt:
          type: string
          description: 上游返回的改写提示词。
    ErrorObject:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
        param:
          type: string
        code:
          type: string
    WanTextToImageMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: 固定为 `user`。
        content:
          type: array
          minItems: 1
          description: 消息内容数组。包含 `text` 和/或 `image` 对象。
          items:
            $ref: '#/components/schemas/WanTextToImageContentItem'
    WanTextToImageContentItem:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          maxLength: 5000
          description: 提示词。支持中英文，最长 5000 字符（每个汉字、字母、数字、符号均计为一个字符），超出部分将自动截断。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````