# 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`。