# Wan 2.6 API 阿里巴巴 Wan 2.6 视频生成模型的完整 API 参考文档。 ## 模型变体 此 API 支持两种模型变体: | 模型 | ID | 描述 | |-------|-----|-------------| | **Wan 2.6 Text to Video** | `wan-2.6-text-to-video` | 高质量文本到视频合成 | | **Wan 2.6 Image to Video** | `wan-2.6-image-to-video` | 图像动画与运动效果 | ## 快速对比 | 功能 | Text to Video | Image to Video | |---------|---------------|----------------| | 输入 | 文本提示词 | 图像 + 文本提示词 | | 时长范围 | 2-15 秒 | 2-15 秒 | | 分辨率选项 | 720p, 1080p | 720p, 1080p | | 起始帧 | 不支持 | 必需 | | 结束帧 | 不支持 | 不支持 | | 音频支持 | ✅ 是 | ✅ 是 | | 音频 URL | ✅ 是 | ✅ 是 | ## Wan 2.6 Text to Video ### 端点 ``` POST /api/v1/video/task ``` ### 请求参数 #### 必需参数 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `model_name` | string | 必须为 `"wan-2.6-text-to-video"` | | `prompt` | string | 视频生成提示词 | | `duration` | number | 视频时长(秒),范围 2-15 | | `resolution` | string | 输出分辨率:`"720p"` 或 `"1080p"` | #### 可选参数 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `aspect_ratio` | string | 视频宽高比:`"1:1"`, `"16:9"`, `"3:4"`, `"4:3"`, `"9:16"` | | `audio_url` | string | 要在视频中使用的音频文件 URL | ### 请求示例 ```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: 'wan-2.6-text-to-video', prompt: 'A cat playing with a ball of yarn', duration: 5, resolution: '1080p' }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Wan 2.6 Image to Video ### 请求参数 #### 必需参数 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `model_name` | string | 必须为 `"wan-2.6-image-to-video"` | | `prompt` | string | 视频生成提示词 | | `duration` | number | 视频时长(秒),范围 2-15 | | `resolution` | string | 输出分辨率:`"720p"` 或 `"1080p"` | | `image_url` | string | 视频的第一帧 | #### 可选参数 | 参数 | 类型 | 描述 | |-----------|------|-------------| | `audio_url` | string | 要在视频中使用的音频文件 URL | ### 请求示例 ```javascript { model_name: 'wan-2.6-image-to-video', image_url: 'https://example.com/image.jpg', prompt: 'Gentle camera pan from left to right', duration: 5, resolution: '1080p' } ``` ## 响应格式 ### 初始响应 两种模型都返回用于轮询的 `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" } } ``` ### 轮询响应 轮询 `/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 分钟,取决于时长和分辨率设置。 较长的视频(10-15 秒)可能需要最多 8 分钟。 ## 最佳实践 1. **描述场景和运动**:在提示词中同时包含场景内容和镜头运动 2. **分辨率选择**:使用 720p 以加快处理速度,使用 1080p 以获得最高质量 3. **时长规划**:较长的视频消耗更多费用(按秒计费) 4. **音频集成**:可以通过 `audio_url` 参数添加自定义音频 5. **图像质量**:对于图像到视频,使用高质量输入图像以获得最佳效果 ## 使用案例示例 ### 产品演示视频 ```javascript { model_name: 'wan-2.6-text-to-video', prompt: 'Smooth 360-degree rotation of a luxury watch on a pedestal', duration: 8, resolution: '1080p' } ``` ### 动画肖像 ```javascript { model_name: 'wan-2.6-image-to-video', image_url: 'portrait.jpg', prompt: 'Subtle head movement, natural breathing, soft smile', duration: 5, resolution: '1080p' } ``` ### 带音频的场景 ```javascript { model_name: 'wan-2.6-text-to-video', prompt: 'Ocean waves crashing on a beach at sunset', duration: 10, resolution: '1080p', audio_url: 'https://example.com/ocean-sounds.mp3' } ```