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

# 万相 2.7 视频生成接口

> 兼容阿里万相2.7协议的视频生成接口，支持文生视频、图生视频与视频编辑

此接口与阿里万相（DashScope）官方协议一致，请求体可直接复用官方文档中的参数结构。无需携带 `X-DashScope-Async` 头，网关已内置异步语义。`model` 须为平台模型标识（如 `wan2.7-t2v` / `wan2.7-i2v` / `wan2.7-r2v` / `wan2.7-videoedit`），路由后由网关改写为渠道模型名。

## 请求结构

请求体由三部分组成：

* `model`：平台模型标识（必填）
* `input`：输入内容，包含 `prompt` / `negative_prompt` / `audio_url` 与媒体元素列表 `media`（首帧 / 尾帧 / 参考图 / 参考视频 / 待编辑视频，支持公网 URL 或 base64 data URI，并可通过 `reference_voice` 指定主体音色）
* `parameters`：生成参数，包含 `resolution` / `ratio` / `duration` / `watermark` / `seed` / `prompt_extend` / `audio_setting`

<Note>
  `audio_setting` 仅对视频编辑模型有效：`auto`（默认）由模型根据提示词智能判断是否重新生成音频；`origin` 强制保留输入视频的原声。
</Note>

## 认证方式

在请求头中携带 `Authorization` 字段，格式为 `Bearer YOUR_API_KEY`。

## 支持的视频模型

| 模型标识             | 模型类型 | 模型描述     |
| ---------------- | ---- | -------- |
| wan2.7-t2v       | 文生视频 | 基于文本生成视频 |
| wan2.7-i2v       | 图生视频 | 基于图像生成视频 |
| wan2.7-r2v       | 参考视频 | 基于参考生成视频 |
| wan2.7-videoedit | 视频编辑 | 编辑输入视频   |

## 快速示例

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.haitoken.ai/v1/alibaba/video/generations"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "model": "wan2.7-t2v",
      "input": {
          "prompt": "一只金毛犬在日落的海边奔跑，镜头缓慢跟随"
      },
      "parameters": {
          "resolution": "720P",
          "ratio": "16:9",
          "duration": 5,
          "watermark": False,
          "prompt_extend": True
      }
  }

  response = requests.post(url, json=data, headers=headers)
  print(response.json())
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.haitoken.ai/v1/alibaba/video/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'wan2.7-t2v',
      input: {
        prompt: '一只金毛犬在日落的海边奔跑，镜头缓慢跟随'
      },
      parameters: {
        resolution: '720P',
        ratio: '16:9',
        duration: 5,
        watermark: false,
        prompt_extend: true
      }
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```curl cURL theme={null}
  curl -X POST 'https://api.haitoken.ai/v1/alibaba/video/generations' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "model": "wan2.7-t2v",
      "input": {
        "prompt": "一只金毛犬在日落的海边奔跑，镜头缓慢跟随"
      },
      "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "duration": 5,
        "watermark": false,
        "prompt_extend": true
      }
    }'
  ```
</CodeGroup>

创建成功后返回任务 ID：

```json theme={null}
{
  "request_id": "8f3d2c1a-9b7e-4f5a-8c2d-1e6f0a9b3c5d",
  "output": {
    "task_id": "cgt-20260730120000-a1b2c3",
    "task_status": "PENDING"
  }
}
```

## 下一步

* 查看 [查询万相视频任务](/docs/zh/api-reference/video/wan-status) 获取生成结果
* 查看 [视频生成](/docs/zh/api-reference/video/generation) 了解统一协议
* 查看 [HappyHorse 协议](/docs/zh/api-reference/video/happyHorse) 了解 HappyHorse 兼容参数
* 查看 [模型列表](/docs/zh/api-reference/models/list-models) 了解可用的视频模型


## OpenAPI

````yaml zh/api-reference/video/wan/openapi.json POST /v1/alibaba/video/generations
openapi: 3.0.1
info:
  title: 默认模块
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/alibaba/video/generations:
    post:
      tags: []
      summary: 创建视频生成任务（兼容阿里万相协议）
      description: |-
        <p>
        Body 与万相官方一致（无需 X-DashScope-Async 头，网关异步语义内置）；
        model 须为平台模型标识（路由后改写为渠道模型名）。
      parameters:
        - name: Authorization
          in: header
          description: API Key token (Bearer sk-xxx)
          required: true
          example: 'Bearer '
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlibabaCreateTaskRequest'
              description: ''
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlibabaCreateTaskResponse'
          headers: {}
      deprecated: false
      security: []
components:
  schemas:
    AlibabaCreateTaskRequest:
      type: object
      properties:
        model:
          type: string
          description: |-
            平台模型标识（如 wan2.7-t2v / wan2.7-i2v / wan2.7-r2v / wan2.7-videoedit），
            路由后由网关改写为渠道模型名
        input:
          $ref: '#/components/schemas/Input'
          description: 输入内容（提示词与媒体元素）
        parameters:
          $ref: '#/components/schemas/Parameters'
          description: 生成参数
      required:
        - model
    AlibabaCreateTaskResponse:
      type: object
      properties:
        request_id:
          type: string
          description: 网关请求ID
        output:
          $ref: '#/components/schemas/TaskOutput'
          description: 任务输出
    Input:
      type: object
      properties:
        negative_prompt:
          type: string
          description: 负向提示词
        audio_url:
          type: string
          description: 音频 URL（如驱动音频）或 base64 data URI
        prompt:
          type: string
          description: 文本提示词
        media:
          type: array
          items:
            $ref: '#/components/schemas/MediaItem'
            description: 媒体元素
          description: 媒体元素列表（首帧/尾帧/参考图/参考视频/待编辑视频）
    Parameters:
      type: object
      properties:
        audio_setting:
          type: string
          description: |-
            视频声音设置(仅对视频编辑模型有效)
            auto （默认）：模型根据 prompt 内容智能判断。若提示词涉及声音描述，可能重新生成音频；否则可能保留输入素材的原声。
            origin：强制保留输入视频的原声，不重新生成。
        prompt_extend:
          type: boolean
          description: 是否开启提示词智能改写
        resolution:
          type: string
          description: 分辨率档位：480P / 720P / 1080P
        ratio:
          type: string
          description: 宽高比：16:9 / 9:16 / 1:1
        duration:
          type: integer
          description: 生成时长（秒）
        watermark:
          type: boolean
          description: 是否带水印
        seed:
          type: integer
          description: 随机种子
          format: int64
    TaskOutput:
      type: object
      properties:
        task_id:
          type: string
          description: 任务ID
        task_status:
          type: string
          description: 任务状态：PENDING
    MediaItem:
      type: object
      properties:
        reference_voice:
          type: string
          description: 音频 URL。用于指定参考素材（图像/视频）中主体角色的音色
        type:
          type: string
          description: |-
            元素类型：first_frame 首帧 / last_frame 尾帧 / reference_image 参考图 /
            reference_video 参考视频 / video 待编辑视频
        url:
          type: string
          description: 媒体 URL 或 base64 data URI（base64 由网关转存 OBS 后替换）
      required:
        - type
        - url

````