Grok Imagine API Tutorial
Grok Imagine is an AI video generation model available on UniAll AI for creating short videos from text prompts or a single reference image. The public model id is `grok-imagine`.
It supports asynchronous video generation, text-to-video, and image-to-video workflows, with output durations from 1 to 15 seconds and resolution options of 480p or 720p.
What Grok Imagine can do
Use Grok Imagine when you need fast short-form video generation for:
- Product reveal clips
- Social media video drafts
- Creative concept visualization
- Motion tests from a still image
- Marketing storyboards
- AI-generated cinematic shots
Supported generation modes:
| Mode | Use case | Required inputs | |---|---|---| | `text_to_video` | Generate a video from a written prompt | `prompt` | | `image_to_video` | Animate or extend a still reference image | `prompt`, `image_url` |
Key parameters
The API endpoint is:
```http POST /v1/videos/generations ```
The request is asynchronous, so your application should submit a generation job and then poll or retrieve the result according to your UniAll AI workflow.
Common parameters:
| Parameter | Type | Notes | |---|---|---| | `model` | string | Use `grok-imagine` | | `generation_mode` | string | `text_to_video` or `image_to_video` | | `prompt` | string | Describe the subject, motion, scene, and style | | `image_url` | string | Required for image-to-video; PNG, JPEG, or WebP supported | | `duration` | integer | 1–15 seconds | | `aspect_ratio` | string | Supports `16:9`, `4:3`, `3:2`, `1:1`, `2:3`, `3:4`, `9:16` | | `resolution` | string | `480p` or `720p` | | `video_count` | integer | Fixed at 1 video per generation |
Text-to-video example
```bash curl -X POST "https://api.uniall.ai/v1/videos/generations" \ -H "Authorization: Bearer $UNIALL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine", "generation_mode": "text_to_video", "prompt": "A cinematic drone shot over a futuristic coastal city at sunset, smooth camera movement, realistic lighting.", "duration": 6, "aspect_ratio": "16:9", "resolution": "720p", "video_count": 1 }' ```
Image-to-video example
```bash curl -X POST "https://api.uniall.ai/v1/videos/generations" \ -H "Authorization: Bearer $UNIALL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine", "generation_mode": "image_to_video", "prompt": "A cinematic product reveal, soft studio lighting, slow push-in camera movement, premium commercial style.", "image_url": "https://example.com/reference.png", "duration": 6, "aspect_ratio": "16:9", "resolution": "720p", "video_count": 1 }' ```
Prompting tips
For better results, include four elements in your prompt:
1. **Subject**: what appears in the video 2. **Motion**: camera movement or subject movement 3. **Style**: cinematic, realistic, anime, commercial, documentary, etc. 4. **Lighting and composition**: studio lighting, golden hour, close-up, wide shot
Example:
```text A close-up of a luxury smartwatch on a reflective black surface, slow rotating camera move, dramatic studio lighting, premium product commercial, sharp details. ```
Pricing angle
Grok Imagine is billed per second of generated video on UniAll AI. Pricing depends on resolution:
- 480p: lower-cost option for drafts, testing, and workflow automation
- 720p: better for higher-quality previews and production-ready short clips
Because billing is duration-based, a 15-second clip costs more than a 6-second clip at the same resolution. For cost control, test prompts at shorter durations before generating longer clips.
Who should use Grok Imagine
Grok Imagine is useful for developers, marketers, creators, and product teams that want to add AI video generation to applications or internal workflows. It is especially suitable for teams that need an API-based way to generate short videos from prompts or reference images without building video infrastructure from scratch.
Implementation checklist
- Use `model: "grok-imagine"`
- Choose `generation_mode` based on your workflow
- Provide `image_url` only when using image-to-video
- Keep duration between 1 and 15 seconds
- Select an aspect ratio that matches your target channel
- Use 480p for testing and 720p for better output quality
- Handle the request as an asynchronous generation job
Best-fit use cases
- Social video prototyping
- Product marketing clips
- E-commerce motion previews
- Creative ad concepts
- Storyboard generation
- Automated video content pipelines
常见问题
What is the public model id for Grok Imagine on UniAll AI?
The public model id is `grok-imagine`. Use this value in the `model` field when calling the video generation endpoint.
Does Grok Imagine support both text-to-video and image-to-video?
Yes. Use `generation_mode: "text_to_video"` with a prompt, or `generation_mode: "image_to_video"` with both a prompt and an `image_url`.
How is Grok Imagine priced?
Grok Imagine is billed per second of generated video. The cost depends on the selected resolution, with 480p priced lower than 720p.