Video Generation
Grok Imagine Video
Generate videos from text prompts and reference images using xAI's Grok Imagine Video model.
POST /v2/videos/generate — model: "grok-imagine-video"
Generate videos from text prompts, optionally guided by up to 7 reference images. Resolution is fixed at 720p.
See Video Generation overview for common request fields, response format, and error codes.
Model-specific parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
grokImagineVideoParams.duration | number | No | 6 | Video duration in seconds: 6, 10, or 15 |
grokImagineVideoParams.aspect_ratio | string | No | "16:9" | Aspect ratio: "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3" |
grokImagineVideoParams.reference_images | string[] | No | — | Array of image URLs for image-to-video generation (max 7) |
Credit cost
| Variant | Credits |
|---|---|
6s | 10 |
10s | 15 |
15s | 25 |
Code examples
curl -X POST https://api.apiframe.ai/v2/videos/generate \
-H "X-API-Key: afk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "a futuristic city skyline at sunset with flying cars",
"model": "grok-imagine-video",
"grokImagineVideoParams": {
"duration": 10,
"aspect_ratio": "16:9"
}
}'import requests
response = requests.post(
"https://api.apiframe.ai/v2/videos/generate",
headers={
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
json={
"prompt": "a futuristic city skyline at sunset with flying cars",
"model": "grok-imagine-video",
"grokImagineVideoParams": {
"duration": 10,
"aspect_ratio": "16:9",
},
},
)
print(response.json())const response = await fetch("https://api.apiframe.ai/v2/videos/generate", {
method: "POST",
headers: {
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "a futuristic city skyline at sunset with flying cars",
model: "grok-imagine-video",
grokImagineVideoParams: {
duration: 10,
aspect_ratio: "16:9",
},
}),
});
console.log(await response.json());body := `{
"prompt": "a futuristic city skyline at sunset with flying cars",
"model": "grok-imagine-video",
"grokImagineVideoParams": {
"duration": 10,
"aspect_ratio": "16:9"
}
}`
req, _ := http.NewRequest("POST", "https://api.apiframe.ai/v2/videos/generate",
strings.NewReader(body))
req.Header.Set("X-API-Key", "afk_your_api_key_here")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)Image-to-video example
curl -X POST https://api.apiframe.ai/v2/videos/generate \
-H "X-API-Key: afk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "animate this scene with gentle camera movement",
"model": "grok-imagine-video",
"grokImagineVideoParams": {
"duration": 6,
"reference_images": ["https://example.com/scene.jpg"]
}
}'Try it
POST
/v2/videos/generateTry it