| 1 | # 视频生成 |
| 2 | |
| 3 | 使用图片或文字生成视频片段(15秒以内)。 |
| 4 | |
| 5 | ## 请求 |
| 6 | |
| 7 | ```bash |
| 8 | curl -X POST "http://localhost:8000/api/sandbox/video" \ |
| 9 | -H "Content-Type: application/json" \ |
| 10 | -d '{ |
| 11 | |
| 12 | "model": "wan2.7-i2v", |
| 13 | "prompt": "一只猫在草地上奔跑", |
| 14 | "image": "code/result/image/user_upload/cat.png" |
| 15 | }' |
| 16 | ``` |
| 17 | |
| 18 | ## 参数说明 |
| 19 | |
| 20 | | 参数 | 必填 | 说明 | |
| 21 | |------|------|------| |
| 22 | |
| 23 | | model | | 模型,默认 wan2.7-i2v | |
| 24 | | prompt | ✅ | 视频描述 | |
| 25 | | image | ✅ | 参考图片路径 | |
| 26 | |
| 27 | ## 可用模型 |
| 28 | |
| 29 | | 模型 | 说明 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | | wan2.7-i2v | 默认,最新高性能模型 | |
| 34 | | doubao-seedance-2-0-260128 | 字节跳动高并发模型 | |
| 35 | | wan2.6-i2v-flash | 快速生成 | |
| 36 | | kling-v3 | | |
| 37 | | kling-v2-6 | | |
| 38 | | jimeng_ti2v_v30_pro | | |
| 39 | |
| 40 | ## ⚠️ 路径格式 |
| 41 | |
| 42 | - `image` 必须使用 `code/result/...` 格式的**相对路径** |
| 43 | - 禁止使用完整 URL 或本地路径 |
| 44 | |
| 45 | ## 响应 |
| 46 | |
| 47 | ```json |
| 48 | { |
| 49 | "success": true, |
| 50 | "video_path": "code/result/sandbox/videos/xxx.mp4", |
| 51 | "record_id": "xxx" |
| 52 | } |
| 53 | ``` |
| 54 | |
| 55 | ## 获取视频文件 |
| 56 | |
| 57 | ```python |
| 58 | # 直接从后端目录复制 |
| 59 | backend_path = "/code/result/sandbox/videos/{record_id}.mp4" |
| 60 | local_path = "~/.openclaw/workspace/temp_imgs/{record_id}.mp4" |
| 61 | shutil.copy2(backend_path, local_path) |
| 62 | ``` |
| 63 | |
| 64 | ## 注意事项 |
| 65 | |
| 66 | 1. 生成的视频较短(15秒以内) |
| 67 | 2. 如果需要生成长视频,请使用完整工作流 |
| 68 | |
| 69 | ## 常见问题 |
| 70 | |
| 71 | | 错误 | 原因 | 解决方法 | |
| 72 | |------|------|----------| |
| 73 | | `curl: (7) Failed to connect` | 后端未运行 | 启动后端服务 | |
| 74 | | `404 Not Found` | 路径格式错误 | 使用 `code/result/...` 格式 | |
| 75 | | `"error": "image not found"` | 图片文件不存在 | 检查图片路径是否正确 | |
| 76 | | `"success": false` | API Key 额度用完或无效 | 检查对应平台的 API Key | |
| 77 |