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

# HappyHorse 视频生成接口

> 兼容 HappyHorse 1.1协议的视频生成接口，支持文生视频、图生视频与视频编辑

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

## 请求结构

请求体由三部分组成：

* `model`：平台模型标识（必填）
* `input`：输入内容，包含 `prompt` 与媒体元素列表 `media`（`first_frame` 首帧 / `reference_image` 参考图 / `video` 待编辑视频，支持公网 URL 或 base64 data）
* `parameters`：生成参数，包含 `resolution`（`480P` / `720P` / `1080P`）、`ratio`（`16:9` 默认 / `9:16` / `1:1` / `4:3` / `3:4` / `5:4` / `4:5` / `9:21` / `21:9`）、`duration`、`watermark`、`seed`

## 认证方式

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

## 支持的视频模型

| 模型标识                      | 模型类型 | 模型描述     |
| ------------------------- | ---- | -------- |
| happyhorse-1.1-t2v        | 文生视频 | 基于文本生成视频 |
| happyhorse-1.1-i2v        | 图生视频 | 基于图像生成视频 |
| happyhorse-1.1-r2v        | 参考视频 | 基于参考生成视频 |
| happyhorse-1.0-video-edit | 视频编辑 | 编辑输入视频   |

## 快速示例

<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-i2v",
      "input": {
          "prompt": "一只金毛犬在日落的海边奔跑，镜头缓慢跟随",
          "media": [
              {
                  "type": "first_frame",
                  "url": "https://example.com/images/dog.png"
              }
          ]
      },
      "parameters": {
          "resolution": "720P",
          "ratio": "16:9",
          "duration": 5,
          "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/alibaba/video/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'wan2.7-i2v',
      input: {
        prompt: '一只金毛犬在日落的海边奔跑，镜头缓慢跟随',
        media: [
          {
            type: 'first_frame',
            url: 'https://example.com/images/dog.png'
          }
        ]
      },
      parameters: {
        resolution: '720P',
        ratio: '16:9',
        duration: 5,
        watermark: false
      }
    })
  });

  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-i2v",
      "input": {
        "prompt": "一只金毛犬在日落的海边奔跑，镜头缓慢跟随",
        "media": [
          {
            "type": "first_frame",
            "url": "https://example.com/images/dog.png"
          }
        ]
      },
      "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "duration": 5,
        "watermark": false
      }
    }'
  ```
</CodeGroup>

创建成功后返回任务 ID：

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

## 下一步

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


## OpenAPI

````yaml zh/api-reference/video/happyHorse/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: 创建视频生成任务（兼容HappyHorse协议）
      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:
              description: ''
              type: object
              properties:
                model:
                  type: string
                  description: >-
                    平台模型标识（如 wan2.7-t2v / wan2.7-i2v / wan2.7-r2v /
                    wan2.7-videoedit），

                    路由后由网关改写为渠道模型名
                input:
                  description: 输入内容（提示词与媒体元素）
                  type: object
                  properties:
                    prompt:
                      type: string
                      description: 文本提示词
                    media:
                      type: array
                      items:
                        description: 媒体元素
                        type: object
                        properties:
                          type:
                            type: string
                            description: >-
                              元素类型：first_frame 首帧  / reference_image 参考图 / video
                              待编辑视频
                          url:
                            type: string
                            description: 媒体 URL 或 base64 data
                        required:
                          - type
                          - url
                      description: 媒体元素列表（首帧/尾帧/参考图/参考视频/待编辑视频）
                parameters:
                  description: 生成参数
                  type: object
                  properties:
                    resolution:
                      type: string
                      description: 分辨率档位：480P/ 720P / 1080P
                    ratio:
                      type: string
                      description: >-
                        宽高比：16:9 (默认) / 9:16 / 1:1 / 4:3 / 3:4 / 5:4 / 4:5 /
                        9:21 / 21:9  
                    duration:
                      type: integer
                      description: 生成时长（秒）
                    watermark:
                      type: boolean
                      description: 是否带水印
                    seed:
                      type: integer
                      description: 随机种子
                      format: int64
              required:
                - model
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlibabaCreateTaskResponse'
          headers: {}
      deprecated: false
      security: []
components:
  schemas:
    AlibabaCreateTaskResponse:
      type: object
      properties:
        request_id:
          type: string
          description: 网关请求ID
        output:
          $ref: '#/components/schemas/TaskOutput'
          description: 任务输出
    TaskOutput:
      type: object
      properties:
        task_id:
          type: string
          description: 任务ID
        task_status:
          type: string
          description: 任务状态：PENDING

````