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

# HappyHorse 1.1 视频生成

> 使用 HappyHorse 1.1 生成、参考图生成或编辑视频

* 对外模型固定为 `happyhorse-1.1`
* 通过 `action` 区分文生视频、首帧图生视频、参考图生视频和视频编辑
* 未传 `action` 时，存在首帧图会自动按图生视频处理，否则按文生视频处理
* 异步任务管理，通过任务 ID 查询结果

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 进行认证。

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" default="happyhorse-1.1" required>
  视频生成模型名称，固定为 `happyhorse-1.1`。
</ParamField>

<ParamField body="action" type="string" default="text-to-video">
  生成模式。

  可选项：

  * `text-to-video` - 文生视频
  * `image-to-video` - 首帧图生视频
  * `reference-to-video` - 参考图生视频
  * `video-edit` - 视频编辑

  如果省略该字段，服务端会根据是否传入首帧图自动判断。
</ParamField>

<ParamField body="prompt" type="string">
  视频内容描述。

  文生视频、参考图生视频和视频编辑必填。首帧图生视频可选，但建议填写以控制画面运动和风格。
</ParamField>

<ParamField body="image_urls" type="string[]">
  图生视频首帧图片 URL。仅使用第一张图片。

  也可以使用兼容字段 `input_reference`、`images`、`image` 或 `image_with_roles[{ role: "first_frame" }]`。

  图片要求：

  * 格式：`JPEG`、`JPG`、`PNG`、`BMP`、`WEBP`
  * 文件大小：不超过 `10MB`
  * 宽高：不小于 `300px`
  * 宽高比：`1:2.5` 到 `2.5:1`
</ParamField>

<ParamField body="reference_images" type="string[]">
  参考图片 URL 列表。

  `reference-to-video` 必填，支持 `1` 到 `9` 张；`video-edit` 可选，最多 `5` 张。
</ParamField>

<ParamField body="url" type="string">
  视频编辑的输入视频 URL。`action=video-edit` 时必填。
</ParamField>

<ParamField body="audio_setting" type="string" default="auto">
  视频编辑的声音控制。仅 `action=video-edit` 有效。

  可选项：

  * `auto`
  * `origin`
</ParamField>

<ParamField body="duration" type="integer" default={5}>
  视频时长，单位秒。可选范围：`3` 到 `15`。
</ParamField>

<ParamField body="resolution" type="string" default="1080P">
  视频分辨率。

  可选项：

  * `720P`
  * `1080P`
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  文生视频宽高比。图生视频会根据首帧图决定画幅。

  可选项：

  * `16:9`
  * `9:16`
  * `1:1`
  * `4:3`
  * `3:4`

  也可以使用兼容字段 `size`。
</ParamField>

<ParamField body="seed" type="integer">
  随机种子，用于控制生成结果的确定性。
</ParamField>

<ParamField body="watermark" type="boolean" default={true}>
  是否添加水印。
</ParamField>

## 文生视频示例

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "happyhorse-1.1",
    "action": "text-to-video",
    "prompt": "夜晚的铁路桥下，一个涂鸦少年从墙上活过来，一边快速演唱英文 rap，一边做出充满活力的说唱动作。",
    "duration": 10,
    "resolution": "1080P",
    "aspect_ratio": "16:9",
    "seed": 42,
    "watermark": true
  }'
```

## 图生视频示例

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "happyhorse-1.1",
    "action": "image-to-video",
    "prompt": "让图片中的角色自然动起来，保持原始画面风格。",
    "image_urls": ["https://example.com/first-frame.png"],
    "duration": 5,
    "resolution": "1080P"
  }'
```

## 参考图生视频示例

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "happyhorse-1.1",
    "action": "reference-to-video",
    "prompt": "图 1 中的主角在图 2 的场景中奔跑，随后拿起图 3 中的道具。画面保持 3D 卡通风格。",
    "reference_images": [
      "https://example.com/image-01.jpg",
      "https://example.com/image-02.png",
      "https://example.com/image-03.jpeg"
    ],
    "duration": 5,
    "resolution": "1080P",
    "aspect_ratio": "16:9",
    "watermark": false
  }'
```

## 视频编辑示例

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "happyhorse-1.1",
    "action": "video-edit",
    "prompt": "让视频中的场景更有电影感，保留主体动作。",
    "url": "https://example.com/input.mp4",
    "reference_images": ["https://example.com/reference.png"],
    "resolution": "1080P",
    "audio_setting": "origin",
    "seed": 42
  }'
```

## 查询任务

提交接口会返回任务 ID。使用通用视频任务查询接口获取状态和结果：

```bash theme={null}
curl --request GET \
  --url https://toapis.com/v1/videos/generations/{task_id} \
  --header "Authorization: Bearer YOUR_API_KEY"
```

## 渠道配置

HappyHorse 使用 DashScope API Key。默认上游地址为 `https://dashscope.aliyuncs.com`。

如需使用国际站，在管理后台将该渠道的 Base URL 覆盖为：

```text theme={null}
https://dashscope-intl.aliyuncs.com
```
