Skip to content
Sign Up Free
Grok

Grok Imagine video API: text-to-video and image-to-video

Connect to Grok Imagine Video and Grok Imagine Video 1.5 with a BetterToken API Key and choose fields, media and generation methods by Model ID and operation.

Generate 16:9 video with audio from text, or generate video from a first-frame image. grok-imagine-video-1.5 supports text-to-video and image-to-video at up to 1080p. grok-imagine-video supports text-to-video at up to 720p.

Prepare your BetterToken API Key. The Base URL is https://bettertoken.ai/v1, with Authorization: Bearer YOUR_API_KEY for authentication. Copy the Model ID exactly, including capitalization.

Every request.json below follows the same workflow: quote, confirm creation, poll and download. A quote does not start generation; creating a task submits a paid request. See current costs in the model plaza.

Models and operations

The table below lists available values by operation. See each subsection for field defaults, media counts and combination constraints. Media sizes use 1 MB = 1048576 bytes.

Model IDOperationDuration (seconds)Output levelAspect ratioAudioMedia roles
grok-imagine-videotext_to_video1–15, step 1480p, 720p16:9onNone
grok-imagine-video-1.5image_to_video1–15, step 1480p, 720p, 1080pomitonfirst_frame
grok-imagine-video-1.5text_to_video1–15, step 1480p, 720p, 1080p16:9onNone

Both models generate videos with audio, which is fixed to on. Omit output.aspect_ratio for image-to-video. The output aspect ratio follows the first-frame image.

Sample media

The image-to-video example uses a blue ceramic mug on a white table. Keep the sample image to try the example, or first replace it with a public HTTPS image that you have the right to use and that meets this page’s limits. The sample image is square, so the image-to-video example also produces a square video.

Video generation reference: a blue ceramic mug on a white table

Text-to-video

grok-imagine-video

Use this operation when you have only a text description and a resolution of up to 720p is enough.

Set model to this subsection’s Model ID and operation to text_to_video. Use only the generation fields listed below.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoonon
duration.modestringNofixedfixed
duration.secondsintegerNo1–15, step 1 s; only for fixed duration8
output.aspect_ratiostringNo16:916:9
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p480p
promptstringYesstringNone
watermarkbooleanNofalsefalse

Media requirements

This operation does not accept media.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "grok-imagine-video",
"operation": "text_to_video",
"prompt": "A blue ceramic mug on a white table. Slowly move the camera closer in soft daylight.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "16:9"
}
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds as required by this subsection’s combination constraints.

grok-imagine-video-1.5

Use this operation when you have only a text description and need 1080p.

Set model to this subsection’s Model ID and operation to text_to_video. Use only the generation fields listed below.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoonon
duration.modestringNofixedfixed
duration.secondsintegerNo1–15, step 1 s; only for fixed duration8
output.aspect_ratiostringNo16:916:9
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p480p
promptstringYesstringNone
watermarkbooleanNofalsefalse

Media requirements

This operation does not accept media.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "grok-imagine-video-1.5",
"operation": "text_to_video",
"prompt": "A blue ceramic mug on a white table. Slowly move the camera closer in soft daylight.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "1080p",
"aspect_ratio": "16:9"
}
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds as required by this subsection’s combination constraints.

Image-to-video

grok-imagine-video-1.5

Use this operation to set the opening frame with a single image.

Set model to this subsection’s Model ID and operation to image_to_video. Use only the generation fields listed below. Put the first-frame image in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoonon
duration.modestringNofixedfixed
duration.secondsintegerNo1–15, step 1 s; only for fixed duration8
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p480p
promptstringYesstringNone
watermarkbooleanNofalsefalse

Media requirements

Media roleType and countFormatsPer-file limits
first_frameimage, 1 (required)jpg, jpeg, png, webpsize at most 20 MB; width 1–16384 px; height 1–16384 px

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Provide exactly one first_frame image. Omit output.aspect_ratio because the output aspect ratio follows the first-frame image.

Image-to-video is billed for the first-frame image in addition to the video duration. Check the amount in the quote before you create the task.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "grok-imagine-video-1.5",
"operation": "image_to_video",
"prompt": "Slowly move the camera closer to the blue ceramic mug. Preserve its shape and the white table.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p"
},
"media": [
{
"id": "first",
"type": "image",
"role": "first_frame",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table, such as output.aspect_ratio.
requiresAdd seconds or a first-frame image as required by this subsection’s combination constraints.
count / media_roleSend only one first_frame image as shown in this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

Official resources

When calling BetterToken, use this page’s fields and the corresponding operation in the live model catalog.