Ein xAI-Video erstellen
Verwenden Sie CometAPI POST /grok/v1/videos/generations, um Grok-Bild-zu-Video-Jobs aus einem Eingabebild und einem Prompt zu erstellen, und rufen Sie dann die Ergebnisse über request_id per Polling ab.
request_id zurück, behandeln Sie ihn also als ersten Schritt in einem asynchronen Workflow.
Mit einer kleinen Anfrage beginnen
- Verwenden Sie
model: grok-imagine-video-1.5 - Setzen Sie
image.urlauf eine öffentliche JPEG-, PNG- oder WebP-URL - Behalten Sie für eine erste Anfrage
durationauf1undresolutionauf720p - Halten Sie
prompteindeutig, damit die Animationsrichtung klar ist - Wenn Sie base64 senden, behalten Sie in den Docs und im OpenAPI-Beispielformat die Form
data:image/png;base64,<BASE64_IMAGE_DATA>bei
Dauer und Auflösung
Aufgabenablauf
Job erstellen
request_id.Polling bis zur Fertigstellung
done wird.Die Ausgabe speichern
video.url in Ihren eigenen Speicher, wenn Sie sie nach dem temporären Bereitstellungsfenster des Providers benötigen.Autorisierungen
Bearer token authentication. Use your CometAPI key.
Body
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.
Antwort
Request accepted.
Deferred request id used for polling.