ToAPIs ToAPIs
Grok Imagine Video (Official)

Grok Imagine Video Extend (Official)

Extend generated videos with Grok Imagine Video Official

POST
/v1/videos/{video_id}/extend

Note for users in mainland China: Please use https://toapis.cn as the API endpoint (Base URL). Replace https://toapis.com with https://toapis.cn in the examples in this document.

  • Grok Imagine Video Official video extension
  • Extend the duration of existing videos by 2-10 seconds
  • Async task management, query results via task ID

Path Parameters

video_idstringpathrequired

Original video task ID

This is the task ID of a previously completed video generation task in the same region; its finished video is used as the extension source.

To extend an arbitrary video URL without a source task, use POST /v1/videos/extend and pass video_urls in the body instead of a path parameter. If an explicit video URL is also passed in the body, it takes precedence over looking up video_id.

Authentication

Authorizationstringheaderrequired

All API requests require Bearer Token authentication

Get API Key: Visit the API Key Management Page to obtain your API Key

Add to request headers:

Authorization: Bearer YOUR_API_KEY

Request Parameters

modelstringbodyrequireddefault: grok-imagine-video-official

Video extend model name

Example: "grok-imagine-video-official"

promptstringbodyrequired

Text description for video extension

durationintegerbodydefault: 6

Extension length in seconds

  • Supported range: 2–10 seconds (specifies only the newly generated segment appended from the source video's last frame, excluding the source clip's duration)
video_urlsstring[]body

Source video URL list. Required when using POST /v1/videos/extend without a task ID; optional when video_id is present in the path (video_list and metadata.video_url are also accepted).

  • Public http:///https:// URLs only
  • Source video limits (official spec): .mp4 container (H.264, H.265, or AV1), duration between 2 and 15 seconds
  • Output aspect ratio and resolution are inherited from the source video (up to 720p)

Pricing note: Extension bills the generated extension seconds plus the input source video duration per second. The input video duration is determined automatically by the platform; it does not need to be declared in the request.

Response Fields

idstring

Unique task identifier for querying task status

objectstring

Object type, always generation.task

modelstring

Model name used

statusstring

Task status

  • queued: Waiting to be processed
  • in_progress: Processing
  • completed: Successfully completed
  • failed: Failed
progressinteger

Task progress percentage (0-100)

created_atinteger

Task creation timestamp (Unix timestamp)

metadataobject

Task metadata

Request Example

curl --request POST \
  --url https://toapis.com/v1/videos/tsk_vid_01M59KNFZA2N4QFP0TMGACYH98/extend \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "grok-imagine-video-official",
    "prompt": "Continue the scene, make the dog run towards the horizon",
    "duration": 6
  }'
curl --request POST \
  --url https://toapis.com/v1/videos/extend \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "grok-imagine-video-official",
    "prompt": "Continue the scene, make the dog run towards the horizon",
    "duration": 6,
    "video_urls": ["https://example.com/source-video.mp4"]
  }'
import requests

video_id = "tsk_vid_01M59KNFZA2N4QFP0TMGACYH98"

response = requests.post(
    f"https://toapis.com/v1/videos/{video_id}/extend",
    headers={
        "Authorization": "Bearer your-ToAPIs-key",
        "Content-Type": "application/json"
    },
    json={
        "model": "grok-imagine-video-official",
        "prompt": "Continue the scene, make the dog run towards the horizon",
        "duration": 6
    }
)

task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const videoId = 'tsk_vid_01M59KNFZA2N4QFP0TMGACYH98';

const response = await fetch(`https://toapis.com/v1/videos/${videoId}/extend`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your-ToAPIs-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'grok-imagine-video-official',
    prompt: 'Continue the scene, make the dog run towards the horizon',
    duration: 6
  })
});

const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);

Response Example

{
  "id": "tsk_vid_01M59KTYQS81W0QENN56SEJ85S",
  "object": "generation.task",
  "model": "grok-imagine-video-official",
  "status": "queued",
  "progress": 0,
  "created_at": 1768380224,
  "metadata": {}
}