Happy Horse 1.1 API
阿里巴巴 Happy Horse 1.1 视频生成模型的完整 API 参考。
模型变体
此 API 支持三种模型变体:
快速对比
支持的宽高比(Text to Video 与 Reference to Video)
Happy Horse 1.1 Text to Video
端点
POST /api/v1/video/task
请求参数
必填
可选
请求示例
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model_name: 'happyhorse-1.1-text-to-video',
prompt: 'A cat playing with a ball of yarn on a sunny windowsill',
duration: 5,
resolution: '1080p',
aspect_ratio: '16:9',
seed: 42,
}),
});
const { data } = await response.json();
const taskId = data.task_id;
Happy Horse 1.1 Image to Video
请求参数
必填
可选
注意: image-to-video 不支持 aspect_ratio。输出画幅会跟随上传的首帧图像。
请求示例
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model_name: 'happyhorse-1.1-image-to-video',
image_url: 'https://example.com/first-frame.jpg',
prompt: 'Gentle motion; cinematic lighting',
duration: 5,
resolution: '1080p',
seed: 42,
}),
});
const { data } = await response.json();
const taskId = data.task_id;
Happy Horse 1.1 Reference to Video
请求参数
必填
@ (AT) 引用占位符
@ (AT) 引用功能通过带编号的 <<<image_N>>> 占位符将参考图像关联到提示词。编号从 1 开始,并遵循 images 数组的顺序。
可选
参考图像要求
- 支持格式:
JPEG、JPG、PNG、WEBP
- 最大文件大小:每张图像 20 MB
- 最短边:400 px
- 数量:至少 1 张,最多 9 张图像
请求示例
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model_name: 'happyhorse-1.1-reference-to-video',
prompt: 'Subject moves naturally while preserving reference style and appearance',
duration: 5,
resolution: '1080p',
aspect_ratio: '16:9',
images: [
'https://example.com/ref-1.jpg',
'https://example.com/ref-2.jpg',
],
seed: 42,
}),
});
const { data } = await response.json();
const taskId = data.task_id;
@ (AT) 参考视频生成请求示例
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model_name: 'happyhorse-1.1-reference-to-video',
prompt: 'Show the person from <<<image_1>>> walking beside the bicycle from <<<image_2>>> through the street in <<<image_3>>>, preserving all reference details',
duration: 5,
resolution: '1080p',
aspect_ratio: '16:9',
images: [
'https://example.com/person-reference.jpg',
'https://example.com/bicycle-reference.jpg',
'https://example.com/street-reference.jpg',
],
seed: 42,
}),
});
const { data } = await response.json();
const taskId = data.task_id;
响应格式
初始响应
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "submitted"
}
}
轮询响应
轮询 GET /api/v1/video/{taskId} 以检查状态:
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"task_result": {
"videos": [
{
"url": "https://example.com/generated-video.mp4"
}
]
}
}
}
状态值
submitted: 任务已接受,正在等待处理
processing: 视频生成进行中
succeed: 视频生成已完成
failed: 视频生成失败
处理时间
典型处理时间为 2-5 分钟,具体取决于时长和队列负载。
最佳实践
- 清晰描述运动:加入主体运动、镜头运动和场景推进,以改善视频动态效果。
- 先使用短迭代:先从 3-5 秒生成开始,在运行更长片段前验证提示词方向。
- 选择合适的输入图像:对于 image-to-video,请使用清晰、光线良好且主体焦点明确的首帧图像。
- 筛选参考图像:对于 reference-to-video,请提供一致、高质量的参考图像,清楚呈现你希望保留的主体或风格。
- 复用种子生成变体:测试提示词优化时保持相同的
seed,以便更一致地比较输出。
- 匹配投放渠道比例:横向视频使用
16:9,短视频和 Reels 使用 9:16,方形版位使用 1:1。