概述
HappyHorse 视频生成接口,基于阿里云 DashScope,支持文生视频(T2V)、图生视频(I2V)、参考生视频(R2V)和视频编辑(V2V)四种模式。
Base URL: https://mm-internal-cn.leonecloud.com
认证方式
所有接口均需要在请求头中携带 Token 进行认证:
Authorization: Bearer {YOUR_AUTH_TOKEN}快速开始
cURL 示例
创建 HappyHorse 任务(文生视频)
curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/hh" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "一个小女孩走在路上",
"resolution": "1080P",
"ratio": "16:9",
"duration": 5
}'创建 HappyHorse 任务(图生视频)
curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/hh" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "让图片中的场景动起来",
"genType": "i2v",
"imageUrls": ["https://example.com/image.jpg"],
"resolution": "1080P",
"duration": 5
}'创建 HappyHorse 任务(参考生视频)
curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/hh" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "身着红色旗袍的女性character1,手持折扇character2,耳坠character3随动作轻盈摆动",
"genType": "r2v",
"imageUrls": [
"https://example.com/girl.jpg",
"https://example.com/fan.jpg",
"https://example.com/earrings.jpg"
],
"resolution": "1080P",
"ratio": "16:9",
"duration": 5
}'创建 HappyHorse 任务(视频编辑)
curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/hh" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "让视频中的角色穿上图片中的条纹毛衣",
"genType": "v2v",
"videoUrl": "https://example.com/input.mp4",
"imageUrls": ["https://example.com/sweater.jpg"],
"resolution": "720P",
"audioSetting": "origin"
}'查询任务状态
curl -X GET "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/73b75c04-d565-441a-a499-1d8f4f696d51" \
-H "Authorization: Bearer fc_e6495f062c19dfd54f204442bdc7a4c5cc4174ad936e2588effd43e2b3ff51f6"接口列表
1. 创建 HappyHorse 任务
POST /open/aigc/hh
创建一个 HappyHorse 视频生成任务。
Content-Type: application/json
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| prompt | string | 是 | 视频描述提示词,最大2500字符。r2v模式下可用 character1、character2 等指代对应位置的参考图 |
| genType | string | 否 | 生成类型:t2v(文生视频,默认) / i2v(图生视频) / r2v(参考生视频) / v2v(视频编辑)。不填时自动推断:有videoUrl→v2v;多张图→r2v;单张图→i2v;无图→t2v |
| imageUrls | string[] | 条件 | 参考图片 URL。i2v时必填(仅用第一张);r2v时必填(1-9张);v2v时可选(0-5张) |
| base64File | string | 否 | Base64 编码的图片数据,支持 jpg/png/bmp/webp,最大 10MB |
| base64FileList | string[] | 否 | Base64 编码的多张图片数据,每张支持 jpg/png/bmp/webp,单张最大 10MB |
| videoUrl | string | 条件 | 输入视频URL,v2v(视频编辑)时必填。支持MP4/MOV,3-60秒,最大100MB |
| resolution | string | 否 | 分辨率:1080P(默认) / 720P |
| ratio | string | 否 | 宽高比:16:9(默认) / 9:16 / 1:1 / 4:3 / 3:4。仅t2v和r2v支持,i2v自动跟随首帧,v2v不支持 |
| duration | int | 否 | 视频时长:3-15秒,默认5秒。仅t2v/i2v/r2v支持,v2v输出时长跟随输入视频(最长15秒) |
| seed | int | 否 | 随机种子,用于复现结果,范围 [0, 2147483647] |
| watermark | bool | 否 | 是否带水印,默认 true |
| audioSetting | string | 否 | 声音控制(仅v2v有效):auto(默认,模型自行控制) / origin(保留原声) |
| callbackUrl | string | 否 | 任务完成后的回调通知 URL |
说明:
-base64File、imageUrls、base64FileList可同时使用,图片处理顺序为:base64File(单张,放最前面)→imageUrls(URL列表)→base64FileList(多张base64,追加到末尾)
- 支持任意外部图片 URL,系统会自动下载并转存
输入图片要求(I2V/R2V/V2V)
- 尺寸:宽高不小于 300px(r2v建议短边不低于400px)
- 宽高比:介于 1:2.5 ~ 2.5:1 之间
- 格式:JPEG、JPG、PNG、WEBP
- 文件大小:不超过 10MB
输入视频要求(V2V)
- 格式:MP4、MOV(建议H.264编码)
- 时长:3-60秒(输出最长15秒,超过15秒自动截取前15秒)
- 分辨率:长边不超过2160px,短边不小于320px
- 宽高比:1:2.5 ~ 2.5:1
- 文件大小:不超过 100MB
- 帧率:大于 8fps
请求示例
文生视频(T2V):
{
"prompt": "一个小女孩走在路上",
"resolution": "1080P",
"ratio": "16:9",
"duration": 5
}图生视频(I2V):
{
"prompt": "让图片中的场景动起来",
"genType": "i2v",
"imageUrls": ["https://example.com/image.jpg"],
"resolution": "1080P",
"duration": 5
}参考生视频(R2V):
{
"prompt": "身着红色旗袍的女性character1,手持折扇character2,耳坠character3随动作轻盈摆动",
"genType": "r2v",
"imageUrls": [
"https://example.com/girl.jpg",
"https://example.com/fan.jpg",
"https://example.com/earrings.jpg"
],
"resolution": "1080P",
"ratio": "16:9",
"duration": 5
}视频编辑(V2V):
{
"prompt": "让视频中的角色穿上图片中的条纹毛衣",
"genType": "v2v",
"videoUrl": "https://example.com/input.mp4",
"imageUrls": ["https://example.com/sweater.jpg"],
"resolution": "720P",
"audioSetting": "origin"
}响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| msg | string | 状态信息 |
| data.taskId | string | 任务 ID,用于查询任务状态 |
| data.status | string | 任务状态,创建时固定为 processing |
| data.createdAt | string | 创建时间 |
响应示例
成功
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260422150000_abc12345",
"status": "processing",
"createdAt": "2026-04-22 15:00:00"
}
}2. 查询任务状态
GET /open/aigc/{taskId}
查询单个任务的执行状态。
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| taskId | string | 是 | 任务 ID |
响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| msg | string | 状态信息 |
| data.taskId | string | 任务 ID |
| data.status | string | 任务状态:processing / success / failed |
| data.result | string[] | 生成的视频 URL 列表(成功时返回) |
| data.errorMsg | string | 错误信息(失败时返回) |
| data.createdAt | string | 创建时间 |
| data.updatedAt | string | 更新时间 |
响应示例
处理中
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260422150000_abc12345",
"status": "processing",
"createdAt": "2026-04-22 15:00:00",
"updatedAt": "2026-04-22 15:00:05"
}
}成功
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260422150000_abc12345",
"status": "success",
"result": [
"https://fc-gw-sh.oss-accelerate.aliyuncs.com/videos/2026/04/22/output.mp4"
],
"createdAt": "2026-04-22 15:00:00",
"updatedAt": "2026-04-22 15:02:30"
}
}3. 批量查询任务状态
POST /open/aigc/batch
批量查询多个任务的执行状态(最多 100 个)。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| taskIds | string[] | 是 | 任务 ID 列表,最多 100 个 |
请求示例
{
"taskIds": ["task_20260422150000_abc12345", "task_20260422150200_def67890"]
}回调通知
当任务完成(成功或失败)时,如果创建任务时提供了 callbackUrl,系统会向该 URL 发送 POST 请求。
回调请求
Headers
Content-Type: application/json
X-Funcloud-Event: task.completed
X-Funcloud-Signature: {签名}Body
{
"event": "task.completed",
"taskId": "task_20260422150000_abc12345",
"status": "success",
"result": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/videos/output.mp4"],
"errorMsg": "",
"timestamp": "2026-04-22T15:02:30+08:00",
"signature": "a1b2c3d4e5f6..."
}错误码
| code | 说明 |
|---|---|
| 0 | 成功 |
| 10002 | 参数缺失或格式错误 |
| 10005 | API Key 无效或缺失 |
| 30003 | 任务不存在 |
| 90003 | 服务器内部错误 |
最佳实践
1. 轮询策略
建议的轮询间隔:
- 前 30 秒:每 3 秒查询一次
- 30 秒 ~ 2 分钟:每 5 秒查询一次
- 2 分钟后:每 10 秒查询一次
2. 处理时间参考
- 文生视频(T2V):通常 1 ~ 3 分钟(根据时长和分辨率)
- 图生视频(I2V):通常 1 ~ 3 分钟(根据时长和分辨率)
- 参考生视频(R2V):通常 1 ~ 5 分钟(根据参考图数量、时长和分辨率)
- 视频编辑(V2V):通常 1 ~ 5 分钟(根据输入视频时长和分辨率)
3. Prompt 建议
- 描述要清晰具体,包含主体、动作、场景、风格等
- 可以指定镜头运动(推进、拉远、环绕等)
- 最大支持 2500 字符