Mage API · Video model

Grok Video API

Grok Imagine, in motion

Get an API keyTry Grok Video in the playground
POST https://api.mage.space/v1/grok_video/generate

At a glance

The Grok Video API runs Grok Video through Mage at POST https://api.mage.space/v1/grok_video/generate. A request at the default settings costs 375 Gems (about $0.375), with no subscription. Grok Video takes saved characters, references by @handle in the prompt.

Overview

What the Grok Video API does

xAI's Grok Imagine for video, from text, up to 5 references, or a short source clip. 1 to 15 seconds at up to 720p. xAI's safety filter applies.

xAI's Grok Imagine for video, from text, reference images, or a source video to edit. xAI's safety filter applies.

It accepts image, additional_images, video as inputs.

Quick start

Call the Grok Video API

Set MAGE_API_KEY, submit to /grok_video/generate, and poll status_url until the request completes.

cURL
STATUS_URL=$(curl --request POST 'https://api.mage.space/v1/grok_video/generate' \
  --header "Authorization: Bearer $MAGE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "A slow push-in on a lighthouse at dusk, waves breaking below",
  "aspect_ratio": "16:9",
  "duration": "5",
  "model_id": "grok-imagine-video"
}' | jq -r '.status_url')

# Repeat until status is "completed"; result.url is the file
curl "$STATUS_URL" --header "Authorization: Bearer $MAGE_API_KEY"
Python
import os, time, requests

headers = {"Authorization": f"Bearer {os.environ['MAGE_API_KEY']}"}
request = requests.post(
    "https://api.mage.space/v1/grok_video/generate",
    headers=headers,
    json={
      "prompt": "A slow push-in on a lighthouse at dusk, waves breaking below",
      "aspect_ratio": "16:9",
      "duration": "5",
      "model_id": "grok-imagine-video"
    },
).json()

while request["status"] in ("queued", "in_progress"):
    time.sleep(3)
    request = requests.get(request["status_url"], headers=headers).json()

print(request["status"], request["result"] and request["result"]["url"])
JavaScript
const headers = {
  Authorization: `Bearer ${process.env.MAGE_API_KEY}`,
  'Content-Type': 'application/json',
};
let request = await fetch('https://api.mage.space/v1/grok_video/generate', {
  method: 'POST',
  headers,
  body: JSON.stringify({
    "prompt": "A slow push-in on a lighthouse at dusk, waves breaking below",
    "aspect_ratio": "16:9",
    "duration": "5",
    "model_id": "grok-imagine-video"
  }),
}).then((response) => response.json());

while (['queued', 'in_progress'].includes(request.status)) {
  await new Promise((resolve) => setTimeout(resolve, 3000));
  request = await fetch(request.status_url, { headers }).then((r) => r.json());
}

console.log(request.status, request.result?.url);

Models

Grok Video model_id values

Send model_id to pick a variant. A request without one runs the default.

model_idNameDefault
grok-imagine-videoGrok VideoYes

Options

Grok Video parameters

Allowed values across all variants; a variant may offer fewer. The docs list the options per variant.

FieldValues
aspect_ratio1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3
resolution480p, 720p
duration1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

Inputs

Media inputs Grok Video accepts

Send each as an https URL, a data URL, or an upload of up to 100 MB.

FieldRole
imageThe reference image.
additional_imagesAdditional reference images.
videoThe source video.

Rules

What the Grok Video API enforces

More video models

Other video generation APIs on Mage

Video · from 270 Gems

Kiwi API

Everyday video, zero setup

Video · from 245 Gems

Lemon API

Every video feature, at a friendlier price

Video · from 20 Gems

LTX Video API

Fast open-weights video for iteration

Video · from 147 Gems

Melon API

Anime in motion, with optional audio

Video · from 30 Gems

MiniMax-H3 API

Fast open video with stereo sound

Video · from 338 Gems

Plum API

Sound on every clip, up to 2K

FAQ

Frequently asked questions

How much does the Grok Video API cost?

A Grok Video request at the default settings (Grok Video) costs 375 Gems, about $0.375. Other resolutions, durations, and variants change the price; the response reports the exact charge. A generation that fails is refunded; one Mage's content policy blocks is not.

What is the Grok Video API endpoint?

POST https://api.mage.space/v1/grok_video/generate with an Authorization: Bearer header carrying your Mage API key. The response includes a status_url to poll for the result.

Which Grok Video models can I call?

grok-imagine-video (Grok Video). The default is Grok Video.

Does Grok Video support reference images or characters?

Grok Video accepts image, additional_images, video. Grok Video takes saved characters, references by @handle in the prompt.

Can I use Grok Video from Claude or ChatGPT?

Yes. Connect the Mage MCP server to Claude, ChatGPT, Claude Code, Grok, or Cursor and ask for Grok Video by name. Your assistant reads its options with get_model and quotes the price before it generates.

How long are Grok Video results kept?

Results and inputs are kept for 30 days. Download anything you want to keep to your own storage.

Start building with Mage

One account, one Gems balance, every model. Pay only for what you generate.

Get an API keyTry Grok Video in the playground

Related