Grok Imagine
Image and video generation powered by xAI's official Grok Imagine API. Text-to-image returns instantly. Video jobs are async — poll for results.
POST
/api/v1/models/grok-imagineSubmit a Grok Imagine generation job (image or video)
Processing
Images: Sync / Video: Async
Provider
xAI (api.x.ai)
Credits
8–150 per request
Image generation returns instantly with the result URL. Video generation returns a
jobId — poll /api/v1/jobs/{jobId} to get the video URL once processing completes.Sub-models & Credit Costs
text-to-video
150 creditsGenerate 1-15s videos from text prompts. Default 6 seconds at $0.05/sec upstream.
text-to-image
8 creditsGenerate images from text. Uses grok-imagine-image ($0.02/image upstream).
image-to-video
150 creditsAnimate a still image into video by providing image_url.
Request Body
| Name | Type | Description |
|---|---|---|
promptrequired | string | Text description for generation. Required for text-to-video and text-to-image (max 5000 chars). |
model | stringDefault: text-to-video | Sub-model: text-to-video (default), text-to-image, image-to-video. |
image_url | string | Image URL. Required for image-to-video. Optional for text-to-image (enables editing). |
aspect_ratio | string | Output aspect ratio: 16:9, 9:16, 4:3, 3:4, 1:1, 3:2, 2:3. |
duration | number | Video duration in seconds (1-15). Only for video models. |
Examples
Video Generation (Async)
Request
{
"prompt": "Slow dolly through a neon-drenched Tokyo alley with rain reflections, 4K cinematic",
"model": "text-to-video"
}Response (202)
{
"jobId": "job_12345",
"status": "pending",
"message": "Grok Imagine video job created. Poll /api/v1/jobs/{jobId} for status.",
"creditsCharged": 150,
"externalJobId": "aa87081b-1a29-d8a6-e5bf-5807e3a7a561",
"input": {
"model": "text-to-video",
"prompt": "Slow dolly through a neon-drenched Tokyo alley with rain reflections, 4K cinematic"
}
}Image Generation (Sync)
Request
{
"prompt": "A majestic dragon flying over a neon-lit cyberpunk city",
"model": "text-to-image"
}Response (200)
{
"jobId": "job_67890",
"status": "completed",
"message": "Image generated successfully.",
"creditsCharged": 8,
"imageUrl": "https://api.x.ai/...",
"resultUrls": ["https://api.x.ai/..."]
}cURL Examples
"text">-purple-600">curl "text-blue-600">-X POST https://vydra.ai/api/v1/models/grok"text-blue-600">-imagine \
"text-blue-600">-H "Authorization: Bearer YOUR_API_KEY" \
"text-blue-600">-H "Content">-Type: application/json" \
"text-blue-600">-d '{
"prompt": "Slow dolly through a neon">-drenched Tokyo alley",
"model": "text">-to">-video",
"aspect_ratio": "9:16",
"duration": 6
}'Video Polling Result
For video jobs, poll /api/v1/jobs/{jobId} until status is completed:
{
"id": "job_12345",
"status": "completed",
"output": {
"videoUrl": "https://api.x.ai/.../video.mp4",
"resultUrls": ["https://api.x.ai/.../video.mp4"],
"duration": 6
},
"creditsCharged": 150,
"workflowSlug": "grok-imagine-generate"
}