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

  1. Prepare input media. For image-to-video, input.images must contain publicly reachable HTTPS image URLs. Local files, Base64 / Data URLs, and existing remote URLs can be converted to a public fileUrl with HopsAPI file uploads. Do not pass asset://, s3://, file://, or private-network URLs directly.
  2. Create the task. Send the model-specific task, model, mode, and input fields documented below to POST /v1/router/task/create. The response guarantees a platform task_id in tsk_* format; other success fields come from the current upstream and are not a fixed contract. Optional callback_url asks HopsAPI to POST a signed webhook when the task finishes. See Media task callbacks. That URL is not forwarded upstream.
  3. Poll or cancel. Save task_id and call GET /v1/router/tasks/{task_id} every 3–5 seconds. To stop a queued or processing task, send {"task_id":"tsk_..."} to POST /v1/router/task/stop. An API key can only query or cancel tasks owned by the same buyer.
  4. Read the result. Continue polling until the task reaches a terminal status:
StatusMeaning
0Queued — submitted and awaiting scheduling
1Processing — the model is generating
2Completed — output URLs are usually in results[].urls; cost is your price in credits
3Failed — the reserved amount is released and no charge is settled
4Cancelled — 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

ParameterRequiredDescription
taskYesTxt2Video or Img2Video
modelYesSet to grok-imagine-video
modeYesMust be fast; omitting it or using another value is rejected
input.promptNoText describing the desired video or motion
input.imagesImage-to-videoPublic HTTPS image URLs used by Img2Video
input.durationYesInteger from 1 to 15, measured in seconds
input.resolutionYes480p, 720p, or 1080p
input.aspect_ratioYes1:1, 2:3, 3:2, 16:9, 9:16, or auto
callback_urlNoOptional 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.

ResolutionReference price
480p2 credits/second
720p3 credits/second
1080p5 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"}}'
On this page

On this page