Grok Imagine Video
Generate videos from text or an image with Grok Imagine Video through asynchronous media tasks.
model=grok-imagine-video, mode=fast. Supports Txt2Video and Img2Video, durations from 1 to 15 seconds, resolutions 480p / 720p / 1080p, and aspect ratios 1:1 / 2:3 / 3:2 / 16:9 / 9:16 / auto.
Async task workflow
- Prepare input media. For image-to-video,
input.imagesmust contain publicly reachable HTTPS image URLs. Local files, Base64 / Data URLs, and existing remote URLs can be converted to a publicfileUrlwith HopsAPI file uploads. Do not passasset://,s3://,file://, or private-network URLs directly. - Create the task. Send the model-specific
task,model,mode, andinputfields documented below toPOST /v1/router/task/create. The response guarantees a platformtask_idintsk_*format; other success fields come from the current upstream and are not a fixed contract. Optionalcallback_urlasks HopsAPI to POST a signed webhook when the task finishes. See Media task callbacks. That URL is not forwarded upstream. - Poll or cancel. Save
task_idand callGET /v1/router/tasks/{task_id}every 3–5 seconds. To stop a queued or processing task, send{"task_id":"tsk_..."}toPOST /v1/router/task/stop. An API key can only query or cancel tasks owned by the same buyer. - Read the result. Continue polling until the task reaches a terminal status:
| Status | Meaning |
|---|---|
0 | Queued — submitted and awaiting scheduling |
1 | Processing — the model is generating |
2 | Completed — output URLs are usually in results[].urls; cost is your price in credits |
3 | Failed — the reserved amount is released and no charge is settled |
4 | Cancelled — the reserved amount is released and no charge is settled |
Failure details may appear in error_message, fail_reason, or message; do not depend on only one field. The fixed price is locked at task creation and temporarily reserved from the available balance before upstream submission. It is settled only after successful completion. Failure or cancellation releases the reserved amount without a charge.
Result URLs expire in about 24 hours. Download and store the output promptly.
Request parameters
| Parameter | Required | Description |
|---|---|---|
task | Yes | Txt2Video or Img2Video |
model | Yes | Set to grok-imagine-video |
mode | Yes | Must be fast; omitting it or using another value is rejected |
input.prompt | No | Text describing the desired video or motion |
input.images | Image-to-video | Public HTTPS image URLs used by Img2Video |
input.duration | Yes | Integer from 1 to 15, measured in seconds |
input.resolution | Yes | 480p, 720p, or 1080p |
input.aspect_ratio | Yes | 1:1, 2:3, 3:2, 16:9, 9:16, or auto |
callback_url | No | Optional public HTTPS webhook. See Media task callbacks. |
Pricing
The official reference price is calculated per second. Your final price also applies the pricing factor configured for your account.
| Resolution | Reference price |
|---|---|
480p | 2 credits/second |
720p | 3 credits/second |
1080p | 5 credits/second |
For example, a 6-second 720p task has an official reference price of 18 credits, and a 5-second 1080p task has an official reference price of 25 credits, before applying your pricing factor.
Request examples
# Text-to-video: 6 seconds at 720p, 18 reference credits before your pricing factor
curl https://hopsapi.com/v1/router/task/create \
-H "Authorization: Bearer sk-YOUR_KEY" -H "content-type: application/json" \
-d '{"task":"Txt2Video","model":"grok-imagine-video","mode":"fast",
"input":{"prompt":"a cat surfing at sunset","duration":6,"resolution":"720p","aspect_ratio":"16:9"}}'# Image-to-video: 5 seconds at 1080p, 25 reference credits before your pricing factor
curl https://hopsapi.com/v1/router/task/create \
-H "Authorization: Bearer sk-YOUR_KEY" -H "content-type: application/json" \
-d '{"task":"Img2Video","model":"grok-imagine-video","mode":"fast",
"input":{"prompt":"animate the waves and camera movement","images":["https://assets.example.com/input.png"],"duration":5,"resolution":"1080p","aspect_ratio":"9:16"}}'