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

# 通用视频生成接口

> 创建并查询视频生成任务，统一协议支持文生视频、图生视频、首尾帧与参考媒体输入

通用视频生成接口采用异步任务模式：你先调用创建接口获得 `task_id`，再通过查询接口轮询任务状态，任务成功后从响应中获取视频地址。

## 功能特性

* 统一协议接入多个视频模型，通过 `model` 指定平台模型标识
* 支持文生视频、图生视频（首帧 / 尾帧 / 参考图 / 参考视频 / 参考音频）
* 支持负向提示词、分辨率、宽高比、时长、水印与随机种子等生成参数
* 媒体输入支持公网 URL 与 base64 data URI
* 支持 `callback_url` 结果回调（仅 seedance 渠道生效；为空时由网关注入默认回调）

## 认证方式

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

## 支持的视频模型

模型广场中可用的视频模型，请参考 [模型列表](https://portal.haitoken.ai/zh/models)。

## 快速示例

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

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

  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/video/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'seedance-2.0',
      prompt: '一只金毛犬在日落的海边奔跑，镜头缓慢跟随',
      duration: 5,
      resolution: '720p',
      ratio: '16:9',
      watermark: false
    })
  });

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

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

创建成功后返回任务 ID：

```json theme={null}
{
  "task_id": "cgt-20260730120000-a1b2c3",
  "status": "queued"
}
```

## 下一步

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


## OpenAPI

````yaml zh/api-reference/video/generation/openapi.json POST /v1/video/generations
openapi: 3.0.1
info:
  title: 默认模块
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/video/generations:
    post:
      tags: []
      summary: 创建视频生成任务
      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/VideoGenerationRequest'
              description: ''
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationResponse'
                description: 通用视频生成任务创建响应
      deprecated: false
      security: []
components:
  schemas:
    VideoGenerationRequest:
      type: object
      properties:
        negative_prompt:
          type: string
          description: 负向提示词
        generate_audio:
          type: boolean
          description: 是否生成音频,部分模型不支持
        callback_url:
          type: string
          description: 结果回调地址（仅 seedance 渠道生效；空则由网关注入默认回调）
        model:
          type: string
          description: 平台模型标识
        prompt:
          type: string
          description: 文本提示词
        medias:
          type: array
          items:
            $ref: '#/components/schemas/MediaInput'
            description: 媒体输入项
          description: 参考媒体输入列表（首帧/尾帧/参考图/参考视频/参考音频；URL 或 base64 data URI）
        duration:
          type: integer
          description: 生成时长（秒）
        resolution:
          type: string
          description: 分辨率档位，如 480p/720p/1080p/4k（视模型支持情况）
        ratio:
          type: string
          description: 宽高比，如 16:9/9:16/1:1/adaptive
        watermark:
          type: boolean
          description: 是否带水印
        seed:
          type: integer
          description: 随机种子
          format: int64
      required:
        - model
    VideoGenerationResponse:
      type: object
      properties:
        task_id:
          type: string
          description: 任务ID（客户端凭此查询）
        status:
          type: string
          description: 任务状态：queued / running
    MediaInput:
      type: object
      properties:
        type:
          type: string
          description: 媒体类型：image/video/audio
        url:
          type: string
          description: 媒体 URL 或 base64 data URI
        role:
          type: string
          description: >-
            角色：first_frame 首帧 / last_frame 尾帧 / reference_image 参考图 /
            reference_video 参考视频 / reference_audio 参考音频（缺省 first_frame）
      required:
        - type
        - url

````