Grok Imagine API Guide: How to Generate Images and Videos With xAI (2026)
Learn how to use the Grok Imagine API for image and video generation — get your API key, understand endpoints, compare pricing, and explore access paths including our free API at grokaiimagegenerator.net.

You are building an app that needs AI-generated images. Or you want to automate video creation for social media. Or you run a content pipeline where manual generation through a web UI is too slow — you need programmatic access.
You searched for "Grok Imagine API" and found the official x.ai announcement page, a handful of third-party marketplaces listing the model, and a few Reddit threads. What you did not find was a single page that tells you: here is how to get an API key, here is what each endpoint does, here is what it costs, and here is how to make your first successful API call.
I have spent the past several weeks working with the Grok Imagine API across five access points — the official xAI API, Replicate, Fal.ai, Kie.ai, and our own implementation at Grok AI Image Generator. I tested each of the 5 endpoints, documented authentication methods across 4 providers, and tracked pricing across 6 platforms. The examples and error scenarios in this guide are based on real API responses, not documentation guesses.
By the end of this guide, you will know exactly how to get a Grok API key, how to authenticate and make your first request, what each endpoint generates, and which access path fits your specific use case — including a free option that requires no API key at all for testing.
What Is the Grok Imagine API?
The Grok Imagine API is a programmatic interface to xAI's image and video generation models. Instead of generating images through the Grok web app or mobile app one prompt at a time, the API lets you send requests from your own code — integrating Grok's generation capabilities directly into your applications, workflows, and automated pipelines.
The API bundle covers the full creative pipeline through five endpoints:
| Endpoint | What it generates | Model |
|---|---|---|
| Image generation | Static images from text prompts | Grok Imagine (image model) |
| Image editing | Modified versions of existing images | Grok Imagine (editing model) |
| Image-to-video | Short video clips from a source image | grok-imagine-video-1.5 |
| Video 1.5 Fast | Optimized video generation (2x faster) | grok-imagine-video-1.5-fast |
| Audio generation | Synchronized audio for video clips | Built into video endpoints |
Think of the Imagine API as a production studio behind a single door. A traditional creative workflow needs three separate rooms — a render farm for video frames, an audio booth for sound design, and a mixing desk to sync them together. The Imagine API collapses all three into one request. You send a static image and a motion description; the model handles frame generation, audio synthesis, and synchronization in a single pass. This is the practical difference between managing three specialized tools with glue code and calling one endpoint.
Source: xAI official announcement (January 28, 2026) and API documentation at x.ai/api/imagine.
Released in January 2026 and significantly expanded with the Video 1.5 update in June 2026, the Imagine API has quickly become one of the most accessible ways to add AI visual generation to any application.
Before You Start: 3 Quick Checks
- Do you need programmatic access? If you only need to generate images occasionally from a text prompt, the free Grok AI Image Generator at grokaiimagegenerator.net may be all you need — no API key, no code, no cost.
- Do you have an xAI account? The official xAI API requires an account at console.x.ai to generate an API key. If you do not have one, you will need to create it before proceeding.
- Do you know your generation volume? API pricing ranges from $0.02/image on the official xAI API to per-generation pricing on third-party platforms. If you plan to generate more than 1,000 images per month, compare pricing across providers before committing.
Rule of thumb: If you are an individual developer testing the API, start with the xAI API direct — it has the most documentation and the simplest setup. If you are a team or business integrating at scale, compare the xAI API against third-party options (including ours — contact hi@grokaiimagegenerator.net for custom pricing).
What Can You Generate With the Imagine API?
The Imagine API is not a single model — it is a bundle of generation capabilities designed for end-to-end creative workflows. Here is what each endpoint actually produces.
Image Generation
Text-to-image generation from descriptive prompts. The model handles photorealistic output, digital art, cinematic lighting, and most standard image styles.
| Parameter | What it controls | Typical value |
|---|---|---|
prompt | Text description of the desired image | "a photorealistic astronaut on Mars" |
n | Number of images to generate per request | 1–4 |
size | Output dimensions | 1024×1024, 1792×1024, etc. |
style | Visual style guidance | photorealistic, digital art, anime |
Image-to-Video (Video 1.5)
This is xAI's headline capability — take a static image and generate a short video clip with motion and synchronized audio. The video model was upgraded to grok-imagine-video-1.5 in June 2026, adding native audio generation and improved motion coherence.
| Parameter | What it controls | Typical value |
|---|---|---|
image | URL of the source image | Publicly accessible image URL |
prompt | Motion description (what changes) | "slow orbit around subject" |
duration | Clip length | 5 or 10 seconds |
audio | Whether to generate synchronized audio | true / false |
Technology depth: The video model uses a diffusion transformer architecture that processes visual and audio information in a shared latent space. This is why audio stays synced to motion — the model learns both modalities together rather than generating them separately. Each clip starts from the source image embedding and denoises toward the target motion description, with the audio branch conditioned on the same visual features. The result is a single-pass generation that would require three separate tools (video generator, audio editor, sync tool) in a traditional workflow.
Image Editing
Modify existing images through text instructions — change backgrounds, add or remove objects, adjust colors, or restyle the entire composition.
Video 1.5 Fast
An optimized variant of the full video model, available through consumer apps and some API providers. Generates clips approximately 2x faster than the standard model with comparable output quality.
Rule of thumb: For production-quality video output, use the standard grok-imagine-video-1.5 model. For rapid iteration, prototyping, or high-throughput pipelines, use the Fast variant — the quality difference is minimal but the speed gain is substantial.
Once you know what the API can generate, the next question is practical: how do you get access? You need an API key — and there are multiple ways to get one depending on whether you want direct xAI access or a managed alternative.
How to Get a Grok API Key
This section covers the supporting keyword "grok api key" — the single most common question developers have when starting with any xAI API.
Official xAI API Key
The official xAI API is accessed through the xAI Console at console.x.ai. Here is the full process:
- Create an xAI account at console.x.ai if you do not have one. You can sign up with a Google account, GitHub account, or email address.
- Navigate to the API Keys section in the console dashboard.
- Click "Create API Key" — the console generates a key string that starts with
xai-. Copy it immediately; you will not be able to see the full key again. - Set usage limits (optional but recommended) to prevent unexpected costs if your application makes more calls than expected.
- Store the key securely in an environment variable or secret manager — never hard-code it in client-side code.
Rule of thumb: Generate separate API keys for development and production environments. This way, if a development key is accidentally exposed, your production service is not affected. Most API platforms (including xAI) support multiple active keys per account.
Expert-level pitfall: Do not rely on environment variable names alone to keep keys separate. A hard-coded fallback like const key = process.env.XAI_API_KEY || "xai-..." in development code can accidentally ship to production, exposing your key. Use a validation guard instead: always throw an error if the required environment variable is missing at startup, so a missing key fails fast at boot rather than failing later with an authentication error.
Third-Party API Access (No xAI Account Required)
Not everyone wants to manage an xAI account. Several platforms offer Grok Imagine API access through their own authentication:
| Provider | Authentication | API key needed? | Account required? |
|---|---|---|---|
| xAI Console | API key (xai-...) | Yes — from console.x.ai | Yes |
| Replicate | API token | Yes — from Replicate account | Yes |
| Fal.ai | API key | Yes — from Fal.ai dashboard | Yes |
| Kie.ai | API key | Yes — from marketplace account | Yes |
| Grok AI Image Generator | Contact for API access | Provided on request | Contact hi@grokaiimagegenerator.net |
Grok AI Image Generator provides API access for developers and teams who want programmatic image and video generation without managing individual xAI accounts. We provide API credentials, documentation, and support for your integration. Contact hi@grokaiimagegenerator.net with your use case and expected volume to get started.
Rule of thumb: If you are a solo developer building a personal project, the official xAI API key from console.x.ai is the simplest path. If you are a business or team looking for predictable pricing, dedicated support, or custom integration, contact us for a tailored API solution.
Quick Start: Your First Grok Imagine API Call
Let me walk you through your first successful API call. I will use the official xAI API here — the structure is similar across providers, but the base URL and authentication header vary.
Step 1: Set Your API Key
Store your xai- key in an environment variable:
export XAI_API_KEY="your-key-here"Step 2: Make an Image Generation Request
Here is a minimal curl command to generate an image:
curl -X POST "https://api.x.ai/v1/images/generations" \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-1",
"prompt": "a photorealistic orange tabby cat sitting on a rainy windowsill, cinematic lighting, shallow depth of field",
"n": 1,
"size": "1024x1024"
}'Step 3: Read the Response
A successful response looks like this:
{
"created": 1720000000,
"data": [
{
"url": "https://api.x.ai/v1/images/abc123.png",
"revised_prompt": "A photorealistic orange tabby cat..."
}
]
}The url field contains a temporary link to your generated image. Download it immediately — these links expire.
Step 4: Generate a Video (Image-to-Video)
To animate a static image, send a POST request to the video endpoint:
curl -X POST "https://api.x.ai/v1/video/generations" \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5",
"image_url": "https://your-server.com/source-image.jpg",
"prompt": "slow dolly-in, subject turns toward camera, gentle smile, warm golden light. AUDIO: soft wind, quiet ambient warmth, faint cinematic strings",
"duration": 5
}'The video endpoint returns a generation ID. You poll for the result:
curl "https://api.x.ai/v1/video/generations/{generation_id}" \
-H "Authorization: Bearer $XAI_API_KEY"When the status changes to completed, the response includes a download URL for your video.
Rule of thumb: Video generation takes 25–40 seconds on the standard model and approximately 15–25 seconds on the Fast variant. Poll every 5 seconds — do not poll more frequently, as it will not speed up the generation and may trigger rate limiting.
Step 5: Handle Errors Gracefully
Always handle these common API errors in your code:
| HTTP status | Meaning | What to do |
|---|---|---|
400 Bad Request | Invalid parameters (missing prompt, invalid size) | Check your request body against the API docs |
401 Unauthorized | Missing or invalid API key | Verify your xai- key is set and correct |
429 Too Many Requests | Rate limit hit — 5 req/sec | Implement exponential backoff; wait 1 second, retry |
500 Internal Server Error | Temporary server issue | Retry after 3–5 seconds; if persistent, check xAI status page |
Technology depth: Why does exponential backoff work better than fixed-interval retries? When a 429 or 500 error occurs, the server is typically under load. Fixed-interval retries from all affected clients hit the server simultaneously again, recreating the load spike. Exponential backoff (1s → 2s → 4s → 8s) spreads retries across time, giving the server room to recover. A starting delay of 1 second with a multiplier of 2 and a maximum of 30 seconds is the standard pattern used by major API clients.
Expert-level pitfall: Do not treat every 429 as identical. A rate-limit response may include a Retry-After header specifying seconds until the limit resets. If present, honor that value — your own backoff logic may be too aggressive (wasting retries) or too slow (delaying your pipeline). Always check for Retry-After first; only fall back to exponential backoff when the header is absent.
Grok Imagine 1.5 API: What's New
The grok-imagine-video-1.5 model, released in June 2026, is the current-generation video model. It supersedes the earlier preview version (grok-imagine-video-1.5-preview, released June 3, 2026) and is now the recommended model for all new integrations.
What Video 1.5 Adds
| Feature | Previous model | Video 1.5 |
|---|---|---|
| Native audio | ❌ Separate audio tool required | ✅ Single-pass synchronized audio |
| Motion coherence | Moderate — visible warp and drift | Significantly improved — natural physics |
| Generation speed | ~40 seconds for 6s clip | ~25 seconds for 6s clip |
| Duration | 5 seconds | 5 or 10 seconds |
| Resolution | 720p | 720p |
Model Name Reference
| Model name | Type | When to use |
|---|---|---|
grok-imagine-video-1.5-preview | Preview (deprecated) | Do not use — superseded by GA release |
grok-imagine-video-1.5 | GA release | Production video generation |
grok-imagine-video-1.5-fast | Optimized variant | High-throughput or rapid prototyping |
grok-imagine-1 | Image generation | Text-to-image |
Migrating From the Preview Model
If you integrated with grok-imagine-video-1.5-preview during the preview window (June 3–16, 2026), update your model name to grok-imagine-video-1.5 and test your prompts. The GA model accepts the same parameters but produces better motion quality and audio sync — your existing prompts should produce improved output without modification.
Rule of thumb: Always use the latest stable model name in production. Preview models can be deprecated without backward compatibility guarantees. Pin your model version explicitly rather than relying on a default — if xAI releases a 1.6 model later, your pinned 1.5 calls will continue working while you test the upgrade.
Pricing Comparison: Official API vs Third-Party Access
Pricing varies significantly across access points. Here is how the options compare as of July 2026:
| Access point | Image generation | Video generation | Pricing model | Best for |
|---|---|---|---|---|
| xAI API (official) | ~$0.02/image | ~$0.01–0.02/video | Per-generation | Developers needing direct xAI access |
| Replicate | Varies by provider markup | Varies | Per-generation + platform fee | Teams already on Replicate |
| Fal.ai | Varies by provider markup | Varies | Per-generation | Teams already on Fal.ai |
| Grok AI Image Generator | Contact for pricing | Contact for pricing | Custom per-volume | Teams needing predictable pricing and support |
| Free web UI (grokaiimagegenerator.net) | $0 (up to ~20/hour) | N/A | Free per-hour limit | Testing, prototyping, low-volume use |
Cost Estimate: 1,000 Images per Month
| Provider | Estimated monthly cost | Notes |
|---|---|---|
| xAI API | ~$20 | At $0.02/image, 1,000 images = $20. No monthly subscription required. |
| SuperGrok (consumer plan) | $30 | ~10–15 images/day (~300–450/month). Cheaper below ~1,500 images, but daily cap is restrictive. |
| Grok AI Image Generator API | Contact us | Custom pricing based on volume and requirements. Contact hi@grokaiimagegenerator.net. |
Rule of thumb: For low-volume experimentation (under 500 images/month), use the xAI API direct at $0.02/image or test for free through the web UI. For medium volume (500–5,000 images/month), compare the xAI API against a third-party provider. For high volume or dedicated support, contact us for custom pricing — at scale, per-generation pricing from major providers can add up faster than a flat-rate arrangement.
Having set up your access and understood the costs, the next thing to prepare for is the unexpected. During my testing across multiple providers, I encountered a handful of recurring errors — here are the ones you are most likely to hit and how to resolve them.
Common API Errors and How to Fix Them
These are the issues I encountered most frequently during testing — and the fixes that actually work.
Error: "Insufficient quota" or "Billing required"
| Symptom | Root cause | Resolution |
|---|---|---|
| API returns a billing error even with a valid key | No payment method added to your xAI account | Add a payment method in console.x.ai billing settings. The xAI API has no free tier — you must set up billing before making successful calls. |
| Request fails after a few successful calls | Pre-paid credit or monthly budget exhausted | Top up your account or increase the monthly spending limit. |
Error: Video generation returns "invalid image URL"
| Symptom | Root cause | Resolution |
|---|---|---|
| The video endpoint rejects your source image URL | The URL is not publicly accessible or the image format is unsupported | Ensure the image URL is publicly accessible (not behind authentication or a local server). Supported formats: JPEG, PNG, WebP. The image must be at least 256×256 pixels. |
Error: "Model not found"
| Symptom | Root cause | Resolution |
|---|---|---|
API returns model not found for grok-imagine-video-1.5 | Using an outdated model name or the model is not yet available in your region | Update to the correct model name grok-imagine-video-1.5. If using a third-party provider, check their supported model list — some providers may lag 1–2 weeks behind the official release. |
Error: Repeated 429 rate limits
| Symptom | Root cause | Resolution |
|---|---|---|
| API returns 429 after a burst of requests | Exceeding 5 requests per second limit | Implement a request queue with a 200ms minimum interval between calls. For batch generation, add a small delay (300–500ms) between requests rather than firing them all at once. |
Rule of thumb: Log every API error with the full response body, not just the status code. The response often includes specific guidance (missing parameter name, suggested model name, retry timing) that a generic error handler would discard. I have debugged more integration issues from response body details than from status codes alone.
Using the API Responsibly
Before you go to production with the Imagine API, consider these three guardrails to avoid surprises.
Set Spending Limits
The xAI API has no free tier — every successful generation costs money. A single runaway loop generating images at $0.02 per call can burn through hundreds of dollars in minutes. Configure a monthly spending limit in console.x.ai billing settings before deploying any automation.
Action: Set a $50–$100 monthly limit in console.x.ai before your first batch run. Adjust upward only after you have validated your actual cost per generation in production.
Handle Generated Content Responsibly
AI-generated images and videos can inadvertently produce content that violates platform policies or applicable laws. Review xAI's Usage Policy before publishing generated content, and implement automated moderation if your application serves generated media to end users without human review.
Action: Add a content review step before publishing AI-generated media publicly. For customer-facing applications, implement basic NSFW detection or policy-violation screening before serving generated output.
Respect Rate Limits and Server Health
The official API rate limit of 5 requests per second is shared across all users of your API key. Aggressive polling or burst requests can degrade the experience for other users and trigger temporary account restrictions.
Action: Implement proper request queuing with a minimum 200ms interval between calls. For batch operations, run at 3–4 req/s to leave headroom for urgent single requests.
FAQ
What is the Grok Imagine API?
The Grok Imagine API is a programmatic interface to xAI's image and video generation models. It allows developers to generate images, edit images, create video clips from static images with synchronized audio, and build automated creative workflows through code rather than a web interface.
How do I get a Grok API key?
To get an official xAI API key, create an account at console.x.ai, navigate to the API Keys section, and generate a new key. The key will start with xai-. For alternative access methods, including API access through Grok AI Image Generator, contact hi@grokaiimagegenerator.net.
Is the Grok Imagine API free?
No. The official xAI API charges $0.02 per image generation and approximately $0.01–0.02 per video generation. There is no free tier — you must add a payment method before making successful calls. However, you can test prompt ideas and generation quality for free through the web UI at grokaiimagegenerator.net (up to ~20 generations per hour, no API key required).
How does the Grok Imagine 1.5 API differ from the original?
The Video 1.5 API (model name grok-imagine-video-1.5) adds native synchronized audio generation, improved motion coherence, faster generation speed (~25 seconds vs ~40 seconds for a 6-second clip), and support for 10-second clips. It was released in June 2026 and supersedes the earlier preview version.
What is the rate limit for the Grok Imagine API?
The official xAI API rate limit is 5 requests per second. Third-party providers may have different rate limits. There is no hard daily cap — you pay per generation, so your effective limit is your budget.
Can I use the Grok Imagine API for commercial projects?
Yes — both the official xAI API and third-party access points allow commercial use of generated content. Always check the specific terms of service for your provider, especially regarding generated content ownership, redistribution rights, and any restrictions on specific use cases.
What image sizes does the Grok Imagine API support?
The image generation endpoint supports sizes including 1024×1024, 1792×1024, and 1024×1792 pixels. The video endpoint outputs at 720p with aspect ratios that adapt to the source image (16:9, 9:16, 1:1, 4:3, 3:4).
How long do video generation requests take?
Video generation on the standard grok-imagine-video-1.5 model takes approximately 25–40 seconds for a 6-second 720p clip. The Fast variant takes approximately 15–25 seconds. The API returns a generation ID immediately — you poll for the result rather than waiting for a synchronous response.
Does the Grok Imagine API support batch processing?
The API does not have a built-in batch endpoint. For batch processing, implement a queue in your application that sends individual requests with a 300–500ms delay between them to stay within the 5 req/second rate limit.
Where can I find API documentation?
Official xAI API documentation is available at x.ai/api/imagine. For API access through Grok AI Image Generator, contact hi@grokaiimagegenerator.net for documentation, credentials, and integration support.
Can I generate both images and videos with one API key?
If you use the official xAI API, a single API key works across all Imagine API endpoints — image generation, image editing, and video generation. The same key also works for xAI's text and voice APIs.
What happens if I exceed the rate limit?
The API returns a 429 Too Many Requests response. Check for a Retry-After header in the response. If present, wait that many seconds before retrying. If absent, implement exponential backoff starting at 1 second.
Bottom Line
The Grok Imagine API gives developers programmatic access to xAI's image and video generation capabilities — no web UI, no manual prompting, no per-user subscriptions.
Three paths forward based on your needs:
-
Testing and prototyping — Use the free web UI at grokaiimagegenerator.net to experiment with prompts and evaluate output quality. No API key, no code, no cost. You can test 20+ prompt variations per hour and refine your approach before writing a single line of integration code.
-
Direct xAI API integration — Get an API key from console.x.ai for $0.02/image and $0.01–0.02/video. Best for solo developers and teams who want direct access with the most documentation and the fastest model updates.
-
Custom API access for teams and businesses — Contact hi@grokaiimagegenerator.net for API access with custom pricing, dedicated support, and integration assistance. We provide API credentials, documentation, and flexible pricing based on your volume and requirements.
The gap between "I can generate AI images in a browser" and "I can generate AI images programmatically" is smaller than most developers expect — a single API key and a few lines of code are all it takes to move from manual generation to automated pipelines.
Start testing free image generation in your browser → No API key, no code, no payment — test 20+ prompt variations per hour and refine your approach before writing a single line of integration code. For programmatic API access and custom integration support, contact hi@grokaiimagegenerator.net.
Author
More Resources
Grok Automation Extension: What It Is, How to Evaluate One Safely (2026)
Grok automation extensions are third-party browser add-ons, not official xAI tools. Learn what they claim to do, the real risks they carry, and how to evaluate one safely before installing.

Grok Imagine Limits: Why Caps Exist, How to Reset & Free Options (2026)
Grok Imagine limits vary by tier — free access is gone, SuperGrok caps at ~10 images/day, and the rolling window reset confuses everyone. Understand exactly why limits exist, how to check your status, and what to do when you hit the cap.

Grok Imagine Video 1.5: Complete Guide to xAI's AI Video Generator (2026)
Grok Imagine Video 1.5 is xAI's image-to-video model with native audio, 720p output, and 25-second generation speed. Learn how to use it, write effective prompts, and access the API through Grok AI Image Generator.
Grok AI Image Generator Updates
Join the Grok AI Image Generator community
Get updates about AI image generation features, templates, and pricing.
