# Grok Imagine Video API Complete API reference for Grok Imagine Video generation models by xAI. ## Model Variants This API supports two model variants: | Model | ID | Description | |-------|-----|-------------| | **Grok Imagine Text to Video** | `grok-imagine-text-to-video` | Text-to-video generation | | **Grok Imagine Image to Video** | `grok-imagine-image-to-video` | Reference-image-guided video animation | ## Quick Comparison | Feature | Text to Video | Image to Video | |---------|---------------|----------------| | Input | Text prompt | Reference image array + Text prompt | | Reference Images | Not supported | Required (`images`) | ## Grok Imagine Text to Video ### Endpoint ``` POST /api/v1/video/task ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"grok-imagine-text-to-video"` | | `prompt` | string | Video generation prompt | #### Optional | Parameter | Type | Description | |-----------|------|-------------| | `duration` | number | Video duration in seconds: `6` or `10` | | `resolution` | string | Output resolution: `"480p"` or `"720p"` | | `aspect_ratio` | string | Video aspect ratio: `"16:9"`, `"1:1"`, or `"9:16"` | ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/video/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'grok-imagine-text-to-video', prompt: 'A robot walking through a futuristic city', duration: 6, resolution: '720p', aspect_ratio: '16:9' }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Grok Imagine Image to Video ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"grok-imagine-image-to-video"` | | `prompt` | string | Video generation prompt | | `images` | string[] | Reference image URL array for the animation input | #### Optional | Parameter | Type | Description | |-----------|------|-------------| | `duration` | number | Video duration in seconds: `6` or `10` | | `resolution` | string | Output resolution: `"480p"` or `"720p"` | ### Example Request ```javascript { model_name: 'grok-imagine-image-to-video', images: ['https://example.com/reference.jpg'], prompt: 'Camera slowly zooms in on the subject', duration: 6, resolution: '720p' } ``` ## Response Format ### Initial Response Both models return a `task_id` for polling: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "submitted" } } ``` ### Polling Response Poll `GET /api/v1/video/{taskId}` to check status: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "succeed", "task_status_msg": null, "task_result": { "credit": 0.2, "videos": [ { "url": "https://example.com/generated-video.mp4" } ] } } } ``` ### Status Values - `submitted`: Task accepted and waiting to be processed - `processing`: Video generation in progress - `succeed`: Video generation completed - `failed`: Video generation failed ## Processing Time Typical processing time: 2-5 minutes. ## Best Practices 1. **Creative Prompts**: Grok Imagine Video excels with imaginative, detailed scene descriptions 2. **Motion Description**: Include camera movement and subject motion in prompts 3. **Image Quality**: For image-to-video, use high-quality input images