Tạo video xAI
Sử dụng CometAPI POST /grok/v1/videos/generations để tạo tác vụ image-to-video Grok từ một ảnh đầu vào và prompt, sau đó thăm dò kết quả qua request_id.
request_id ngay lập tức, vì vậy hãy coi đây là bước đầu tiên trong một quy trình async.
Bắt đầu với một yêu cầu nhỏ
- Sử dụng
model: grok-imagine-video-1.5 - Đặt
image.urlthành một URL JPEG, PNG hoặc WebP công khai - Với yêu cầu đầu tiên, giữ
durationở1vàresolutionở720p - Giữ
promptrõ ràng để hướng chuyển động của animation được xác định cụ thể - Nếu bạn gửi base64, hãy giữ nguyên định dạng trong tài liệu và ví dụ OpenAPI là
data:image/png;base64,<BASE64_IMAGE_DATA>
Duration và resolution
Luồng tác vụ
Tạo tác vụ
request_id được trả về.Thăm dò để hoàn tất
done.Lưu trữ đầu ra
video.url cuối cùng vào hệ thống lưu trữ của riêng bạn nếu bạn cần dùng nó sau thời gian cung cấp tạm thời của provider.Ủy quyền
Bearer token authentication. Use your CometAPI key.
Nội dung
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.
Phản hồi
Request accepted.
Deferred request id used for polling.