创建 xAI 视频
使用 CometAPI POST /grok/v1/videos/generations,通过输入图像和 prompt 创建 Grok 图生视频任务,然后通过 request_id 轮询结果。
request_id,因此请将其视为异步工作流的第一步。
从小请求开始
- 使用
model: grok-imagine-video-1.5 - 将
image.url设置为公开可访问的 JPEG、PNG 或 WebP URL - 对于首次请求,将
duration保持为1,并将resolution保持为720p - 保持
prompt表达明确,以便动画方向清晰 - 如果你发送 base64,请将文档和 OpenAPI 示例中的格式保持为
data:image/png;base64,<BASE64_IMAGE_DATA>
时长和分辨率
任务流程
创建任务
request_id。轮询完成状态
done。持久化输出
video.url 复制到你自己的存储中。授权
Bearer token authentication. Use your CometAPI key.
请求体
Prompt describing how the source image should animate. CometAPI requires this field for this route.
"Animate the still image with a slow camera move and natural motion."
Output aspect ratio. Combine with resolution to choose the target frame; for example 480p with 1:1 targets 480x480, 720p with 16:9 targets 1280x720, and 720p with 9:16 targets 720x1280. This endpoint does not expose an exact size field.
1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3 Output duration in seconds. Use an integer from 1 through 15. If omitted, CometAPI treats the request as an 8-second generation for billing and default handling.
Source image for image-to-video. Use a public JPEG, PNG, or WebP URL, or a data URI such as data:image/png;base64,<BASE64_IMAGE_DATA>.
xAI video model id. The default example uses Grok Imagine 1.5 for image-to-video.
"grok-imagine-video-1.5"
Output resolution. Use 720p for a small image-to-video test, or 1080p when you need a higher resolution tier.
480p, 720p, 1080p Deprecated size field. Prefer aspect_ratio and resolution.
Optional end-user identifier.
响应
Request accepted.
Deferred request id used for polling.