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。