Unode
User GuideAPI ReferenceHelp & SupportBusiness Cooperation

Grok Video Generation

xAI's Grok Imagine provides video generation models. This document describes the API interface for using Grok video models for video generation. All video generation calls use the same /v1/video/generations endpoint, with different parameters depending on the use case.


Supported Models

Currently supported models include:

ModelDescription
grok-imagine-videoGrok Imagine video generation model (text-to-video, image-to-video, reference-to-video)

Overview

The Grok video generation feature provides an asynchronous task processing mechanism:

  1. Submit Task: Send a text prompt (and optionally one or more images) to create a video task
  2. Query Status: Query generation progress and status through task ID
  3. Get Results: Retrieve the generated video file after task completion

The same /v1/video/generations endpoint serves three use cases, selected by whether images is present and by metadata.imageMode: no images performs text-to-video; images with metadata.imageMode omitted or set to "keyframe" (the default) performs image-to-video, using only the first image; images with metadata.imageMode set to "reference" performs reference-to-video.

Task Status Flow

queued → in_progress → completed
                ↓
            failed
  • queued: Task has been submitted and is waiting to be processed
  • in_progress: Task is being processed
  • completed: Task completed successfully, video has been generated
  • failed: Task failed

Note: Grok video does not support push callbacks. Poll 2. Query Task Status until the task reaches a terminal status.


API List

MethodPathDescription
POST/v1/video/generationsSubmit video generation task
GET/v1/video/generations/{task_id}Query task status

1. Submit Video Generation Task (/v1/video/generations)

Choose the example that matches how you want to generate the video, then adjust its request body for your scenario.

Usage Examples

Text-to-video uses prompt and model only—no images. Optional top-level fields include duration and size. aspect_ratio is set via metadata.

Request body:

{
  "prompt": "A glowing crystal-powered rocket launching from the red dunes of Mars",
  "model": "grok-imagine-video",
  "duration": 10,
  "size": "720p",
  "metadata": {
    "aspect_ratio": "16:9"
  }
}

Request parameters:

Provide one or more image URLs (or base64 data URIs) in images with metadata.imageMode omitted or set to "keyframe" (the default). Only the first image in the array is used—it becomes the video's locked first frame; any additional images are ignored.

Request body:

{
  "prompt": "The rocket's engines ignite and it lifts off in a cloud of dust",
  "model": "grok-imagine-video",
  "images": ["https://example.com/rocket-on-launchpad.jpg"],
  "duration": 8,
  "size": "720p",
  "metadata": {
    "aspect_ratio": "16:9"
  }
}

Request parameters:

Note: Image-to-video does not support a separate last-frame image. To use multiple images without locking a frame, choose the Reference-to-video tab.

Set metadata.imageMode to "reference" so every URL in images is treated as a reference image that influences the video without locking any frame. Reference images by position in the prompt with tags such as <IMAGE_1>, <IMAGE_2>, … in the same order as images.

Request body:

{
  "prompt": "The model from <IMAGE_1> walks the runway wearing the shirt from <IMAGE_2>",
  "model": "grok-imagine-video",
  "images": [
    "https://example.com/model-reference.jpg",
    "https://example.com/shirt-reference.jpg"
  ],
  "duration": 10,
  "size": "720p",
  "metadata": {
    "imageMode": "reference",
    "aspect_ratio": "16:9"
  }
}

Request parameters:

Complete Request:

curl -X POST "https://www.unodetech.xyz/v1/video/generations" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer API_KEY" \
  -d @request-body.json

Endpoint:

POST /v1/video/generations

Request Headers:

Response Example:

{
  "id": "TASK_ID",
  "task_id": "TASK_ID",
  "object": "video",
  "model": "grok-imagine-video",
  "status": "queued",
  "progress": 0,
  "created_at": 1776717808
}

Response Body Fields:

2. Query Task Status (/v1/video/generations/{task_id})

Complete Request:

curl -X GET "https://www.unodetech.xyz/v1/video/generations/TASK_ID" \
  -H "Authorization: Bearer API_KEY"

Endpoint:

GET /v1/video/generations/{task_id}

Request Headers:

Path Parameters:

Response Examples:

{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "<TASK_ID>",
    "action": "generate",
    "status": "IN_PROGRESS",
    "fail_reason": "",
    "submit_time": 1776717808,
    "start_time": 1776717809,
    "finish_time": 0,
    "progress": "50%",
    "data": {
      "status": "pending",
      "model": "grok-imagine-video"
    }
  }
}

Note: When the task succeeds, data.fail_reason contains the video download URL instead of an error message. Prefer data.data.video.url when retrieving the generated video.

{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "<TASK_ID>",
    "action": "generate",
    "status": "SUCCESS",
    "fail_reason": "<VIDEO_URL>",
    "submit_time": 1776717808,
    "start_time": 1776717809,
    "finish_time": 1776717962,
    "progress": "100%",
    "data": {
      "status": "done",
      "model": "grok-imagine-video",
      "video": {
        "url": "<VIDEO_URL>",
        "duration": 8,
        "respect_moderation": true
      },
      "usage": {
        "cost_in_usd_ticks": 2500000000
      }
    }
  }
}

Response Body Fields:

Last updated on