# Happy Horse 1.1 API 阿里巴巴 Happy Horse 1.1 影片生成模型的完整 API 參考。 ## 模型變體 此 API 支援三種模型變體: | 模型 | ID | 描述 | | --------------------------------------- | ------------------------------------ | ---------------------------------------------------- | | **Happy Horse 1.1 Text to Video** | `happyhorse-1.1-text-to-video` | 直接根據文字提示詞生成影片 | | **Happy Horse 1.1 Image to Video** | `happyhorse-1.1-image-to-video` | 根據提示詞引導,讓單張首幀圖像動起來 | | **Happy Horse 1.1 Reference to Video** | `happyhorse-1.1-reference-to-video` | 根據最多 9 張參考圖像引導生成影片 | ## 快速比較 | 功能 | Text to Video | Image to Video | Reference to Video | | -------------- | ------------------------- | ------------------------- | ------------------------- | | 輸入 | 文字提示詞 | 首幀圖像 + 提示詞 | 參考圖像 + 提示詞 | | 時長範圍 | 3-15 秒 | 3-15 秒 | 3-15 秒 | | 解析度 | 720p、1080p(預設 1080p) | 720p、1080p(預設 1080p) | 720p、1080p(預設 1080p) | | 長寬比 | 支援 9 種比例(預設 16:9) | 不支援(跟隨輸入圖像) | 支援 9 種比例(預設 16:9) | | Seed | 選填 | 選填 | 選填 | ### 支援的長寬比(Text to Video 與 Reference to Video) | 比例 | 描述 | | ------ | ---------------------- | | `16:9` | 橫向(寬螢幕) | | `9:16` | 縱向(直式) | | `3:4` | 標準直式 | | `4:3` | 標準橫向 | | `4:5` | 縱向 | | `5:4` | 橫向 | | `1:1` | 方形 | | `9:21` | 超高縱向 | | `21:9` | 超寬橫向 | ## Happy Horse 1.1 Text to Video ### 端點 ``` POST /api/v1/video/task ``` ### 請求參數 #### 必填 | 參數 | 類型 | 描述 | | -------------- | ------ | ------------------------------------------------------------------ | | `model_name` | string | 必須為 `"happyhorse-1.1-text-to-video"` | | `prompt` | string | 影片生成提示詞 | | `duration` | number | 影片時長,單位為秒(3-15) | | `resolution` | string | 輸出解析度:`"720p"` 或 `"1080p"`(預設 `"1080p"`) | | `aspect_ratio` | string | 影片長寬比(見上方表格;預設 `"16:9"`) | #### 選填 | 參數 | 類型 | 描述 | | ------- | ------ | ---------------------------------------------------------------------------------- | | `seed` | number | 用於可重現生成的隨機種子,範圍為 `0` 到 `2147483647` 的整數 | ### 請求範例 ```javascript 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 ### 請求參數 #### 必填 | 參數 | 類型 | 描述 | | ------------ | ------ | ------------------------------------------------------------------ | | `model_name` | string | 必須為 `"happyhorse-1.1-image-to-video"` | | `prompt` | string | 影片生成提示詞 | | `duration` | number | 影片時長,單位為秒(3-15) | | `resolution` | string | 輸出解析度:`"720p"` 或 `"1080p"`(預設 `"1080p"`) | | `image_url` | string | 首幀圖像 URL(僅作為第一幀) | #### 選填 | 參數 | 類型 | 描述 | | ------- | ------ | ---------------------------------------------------------------------------------- | | `seed` | number | 用於可重現生成的隨機種子,範圍為 `0` 到 `2147483647` 的整數 | > **注意:** image-to-video 不支援 `aspect_ratio`。輸出畫幅會跟隨上傳的首幀圖像。 ### 請求範例 ```javascript 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 ### 請求參數 #### 必填 | 參數 | 類型 | 描述 | | -------------- | -------- | ------------------------------------------------------------------ | | `model_name` | string | 必須為 `"happyhorse-1.1-reference-to-video"` | | `prompt` | string | 影片生成提示詞。可以撰寫不含佔位符的一般提示詞,也可以選擇使用 @ (AT) 引用功能,透過 `<<>>` 明確引用 `images` 陣列中的項目 | | `duration` | number | 影片時長,單位為秒(3-15) | | `resolution` | string | 輸出解析度:`"720p"` 或 `"1080p"`(預設 `"1080p"`) | | `aspect_ratio` | string | 影片長寬比(見上方表格;預設 `"16:9"`) | | `images` | string[] | 參考圖像 URL(1-9 張圖像) | #### @ (AT) 引用佔位符 @ (AT) 引用功能透過帶編號的 `<<>>` 佔位符將參考圖像連結至提示詞。編號從 `1` 開始,並依照 `images` 陣列的順序。 | 佔位符 | 引用值 | |-------------|------------------| | `<<>>` | `images[0]` | | `<<>>` | `images[1]` | | `<<>>` | `images[2]` | #### 選填 | 參數 | 類型 | 描述 | | ------- | ------ | ---------------------------------------------------------------------------------- | | `seed` | number | 用於可重現生成的隨機種子,範圍為 `0` 到 `2147483647` 的整數 | ### 參考圖像要求 - 支援格式:`JPEG`、`JPG`、`PNG`、`WEBP` - 最大檔案大小:每張圖像 20 MB - 最短邊:400 px - 數量:至少 1 張,最多 9 張圖像 ### 請求範例 ```javascript 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) 參考影片生成請求示例 ```javascript 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 <<>> walking beside the bicycle from <<>> through the street in <<>>, 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; ``` ## 回應格式 ### 初始回應 ```json { "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}` 以檢查狀態: ```json { "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": { "credit": 0.2, "videos": [ { "url": "https://example.com/generated-video.mp4" } ] } } } ``` ### 狀態值 - `submitted`: 任務已接受,正在等待處理 - `processing`: 影片生成進行中 - `succeed`: 影片生成已完成 - `failed`: 影片生成失敗 ## 處理時間 典型處理時間為 2-5 分鐘,具體取決於時長和佇列負載。 ## 最佳實務 1. **清楚描述動作**:加入主體動作、鏡頭移動和場景推進,以改善影片動態效果。 2. **先使用短迭代**:先從 3-5 秒生成開始,在執行更長片段前驗證提示詞方向。 3. **選擇合適的輸入圖像**:對於 image-to-video,請使用清晰、光線良好且主體焦點明確的首幀圖像。 4. **篩選參考圖像**:對於 reference-to-video,請提供一致、高品質的參考圖像,清楚呈現你希望保留的主體或風格。 5. **重複使用種子生成變體**:測試提示詞最佳化時保持相同的 `seed`,以便更一致地比較輸出。 6. **匹配投放渠道比例**:橫向影片使用 `16:9`,短影片和 Reels 使用 `9:16`,方形版位使用 `1:1`。