THU, APRIL 16, 2026
Independent · In‑Depth · Unsponsored
✎ General

Grok Imagine API (2026): Access, Pricing, API Key & How to Use

Text-to-image at $0.02/image. Text-to-video with native audio at $4.20/minute. Get your API key from console.x.ai, use the free Playground to test, and follow the working Python and cURL examples for all four endpoints — image generation, video generation, image-to-video, and video editing.

By AIToolsRecap April 16, 2026 9 min read 10 views
Home Articles General Grok Imagine API (2026) — Access, Pricing, Key ...
Grok Imagine API (2026): Access, Pricing, API Key & How to Use

xAI launched the Grok Imagine API on January 28, 2026, giving developers programmatic access to the same image and video generation engine that powers the Grok app. The API covers four distinct capabilities: text-to-image, text-to-video, image-to-video animation, and video editing — all through a single API key from console.x.ai. On the day of launch, Grok Imagine ranked first on Artificial Analysis's text-to-video benchmark, and first on the LMArena Image/Video leaderboard for image-to-video quality. The pricing — $4.20 per minute for video including native audio — undercuts Sora and Veo at comparable quality levels.

This guide covers everything a developer needs to go from zero to first generation: API key setup, every endpoint with request parameters, pricing breakdown, the free Playground, working code examples, and an honest comparison against competing APIs.

What Is the Grok Imagine API?

The Grok Imagine API is a unified bundle of creative generation APIs from xAI. It is separate from the Grok chat API (api.x.ai/v1/messages) and specifically covers visual and audio generation. The API offers four endpoints:

Text-to-image — Generate static images from a text prompt using the grok-imagine-image model (Aurora). POST to https://api.x.ai/v1/images/generations. Returns a URL to the generated image. Priced at $0.02 per image.

Text-to-video — Generate video clips from a text prompt using the grok-imagine-video model. POST to https://api.x.ai/v1/videos/generations. Supports durations from 5 to 15 seconds, 720p resolution, 16:9 or 9:16 aspect ratios, with native audio generation included. Priced at $4.20 per minute of generated video (audio included).

Image-to-video — Animate a still image into a video clip. Same endpoint as text-to-video (https://api.x.ai/v1/videos/generations), with an added image parameter containing the source image URL. Same $4.20/minute pricing.

Video editing — Edit an existing video clip using natural language instructions. Pass your video URL and a prompt describing the change — Grok edits what you asked for while preserving the rest of the scene. Same endpoint, same pricing structure.

All four capabilities are available through a single xAI API key. Video generation is asynchronous: you submit a request and receive a request_id, then poll the status endpoint until the video is ready. Image generation is synchronous and returns immediately. Video URLs returned by the API are temporary — download or process them promptly.

How to Get Your Grok Imagine API Key

API access goes through the xAI developer console at console.x.ai. Here are the steps:

1. Go to console.x.ai and sign in with your xAI account. If you do not have an xAI account, create one at x.ai — you do not need an X (Twitter) account, though you can use one to sign in.

2. In the console dashboard, navigate to API Keys in the left sidebar. Click Create API Key. Give it a descriptive name (e.g., "imagine-dev").

3. Copy the key immediately and store it securely. xAI displays the full key only once. If you lose it, you must generate a new one. Never commit API keys to version control or include them in client-side code.

4. Go to Billing in the console and add a payment method. API usage is billed on consumption — you need a payment method attached before your requests will process beyond the free trial credits.

5. Free credits on signup: New accounts receive $25 in promotional API credits automatically. An additional $150/month in credits is available through xAI's data sharing program — navigate to Settings → Data Sharing in the console and enable "Share API Inputs for Model Training" to activate this. Credits from the data sharing program refresh monthly and can be used for any xAI API endpoint including Imagine.

Set the API key as an environment variable — do not hard-code it:

export XAI_API_KEY="your-key-here"

Grok Imagine API Pricing

Image generation: $0.02 per image, regardless of style, resolution, or complexity. At this price, 1,000 images cost $20. There is no separate pricing for different styles or quality levels — the Aurora model is the same for all image requests.

Video generation (text-to-video, image-to-video, video editing): $4.20 per minute of generated video. Native audio is included in this price — you are not charged separately for audio generation alongside video. At this rate:

A 5-second clip costs approximately $0.35. A 10-second clip costs approximately $0.70. A 15-second clip (the maximum duration) costs approximately $1.05. Generating 100 fifteen-second clips costs approximately $105.

Competitive context: At the time of launch, Sora (OpenAI) and Veo (Google) were priced significantly higher for comparable quality and duration. Independent reporting at launch cited Grok Imagine's video pricing as the most aggressive in the market at that quality tier. The $4.20/minute figure was highlighted by AI industry analysts as a deliberate positioning choice — xAI is competing on cost as well as quality.

No separate charge for audio: Unlike some competitors that charge separately for video-with-audio versus video-without-audio, Grok Imagine's video pricing includes native audio in every generation. This is a meaningful cost advantage for applications that need synchronized audio output.

Subscription vs. API: If you use Grok Imagine through the Grok app (not the API), generation limits are governed by your subscription tier. SuperGrok at $30/month provides expanded image and video generation quotas via Imagine 1.0. The API is pay-per-generation and has no monthly ceiling — costs scale linearly with usage.

The API Playground

xAI provides a free API Playground at console.x.ai where developers can test all Imagine API endpoints without writing code. The Playground lets you:

Submit text-to-image, text-to-video, and image-to-video requests through a browser interface. Adjust parameters (duration, aspect ratio, resolution) using dropdowns. See the raw request JSON that the Playground is sending — useful for copying into your own implementation. View generated images and videos inline within the browser. Test different prompts rapidly before building a production workflow.

Playground requests count against your API credits, so they are not truly "free" — but the $25 new account credits are enough to run dozens of test generations. The Playground does not require any code setup, making it the fastest way to evaluate whether Grok Imagine fits your use case before investing integration time.

How to Use the Grok Imagine API — Code Examples

Text-to-Image

The image endpoint is synchronous. Submit a prompt and receive an image URL in the response.

cURL:

curl -X POST https://api.x.ai/v1/images/generations   -H "Content-Type: application/json"   -H "Authorization: Bearer $XAI_API_KEY"   -d '{"model": "grok-imagine-image", "prompt": "A neon-lit Tokyo street at 3am, rain on the pavement, cinematic"}'

Python (xAI SDK):

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.image.generate(
    prompt="A neon-lit Tokyo street at 3am, rain on the pavement, cinematic",
    model="grok-imagine-image"
)

print(response.image.url)

Text-to-Video

Video generation is asynchronous. Submit a request to get a request_id, then poll the status endpoint until status is done.

cURL (submit):

curl -X POST https://api.x.ai/v1/videos/generations   -H "Content-Type: application/json"   -H "Authorization: Bearer $XAI_API_KEY"   -d '{
    "model": "grok-imagine-video",
    "prompt": "A glowing crystal-powered rocket launching from Mars, ruins lighting up in the background",
    "duration": 10,
    "aspect_ratio": "16:9",
    "resolution": "720p"
  }'

Python (poll until done):

import os
import time
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {os.environ['XAI_API_KEY']}",
}

response = requests.post(
    "https://api.x.ai/v1/videos/generations",
    headers=headers,
    json={
        "model": "grok-imagine-video",
        "prompt": "A glowing crystal-powered rocket launching from Mars",
        "duration": 10,
        "aspect_ratio": "16:9",
        "resolution": "720p",
    },
)

request_id = response.json()["request_id"]

while True:
    result = requests.get(
        f"https://api.x.ai/v1/videos/{request_id}",
        headers={"Authorization": headers["Authorization"]},
    )
    data = result.json()
    if data["status"] == "done":
        print(data["video"]["url"])
        break
    elif data["status"] == "error":
        print("Generation failed")
        break
    time.sleep(3)

xAI SDK (cleaner syntax):

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="A glowing crystal-powered rocket launching from Mars",
    model="grok-imagine-video",
    duration=10,
    aspect_ratio="16:9",
    resolution="720p",
)

print(response.url)

Image-to-Video

Pass a source image URL alongside your prompt. The model animates the image content based on your instructions.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="Generate a slow and serene time-lapse of the stars moving",
    model="grok-imagine-video",
    image_url="https://your-image-host.com/milkyway-still.png",
    duration=12,
)

print(response.url)

Video Editing

Pass an existing video URL and a prompt describing what to change. Grok edits only what you specify while preserving the rest of the scene.

import os
import xai_sdk

client = xai_sdk.Client(api_key=os.getenv("XAI_API_KEY"))

response = client.video.generate(
    prompt="Give the woman a silver necklace",
    model="grok-imagine-video",
    video_url="https://your-video-host.com/portrait-wave.mp4",
)

print(response.url)

Key Parameters Reference

model (required) — Use grok-imagine-image for images, grok-imagine-video for all video operations.

prompt (required) — Natural language description of what to generate or how to edit. Grok Imagine has best-in-class instruction following — prompts that specify scene detail, lighting, mood, and motion direction produce significantly better results than vague prompts.

duration (video only, optional) — Video duration in seconds. Range: 5 to 15 seconds. Defaults to 8 seconds if not specified.

aspect_ratio (video only, optional) — "16:9" (landscape, default) or "9:16" (portrait/vertical, for social media formats).

resolution (video only, optional) — "720p" (default). Higher resolutions may become available as the API develops.

image_url (image-to-video only) — URL of the source image to animate. Must be publicly accessible.

video_url (video editing only) — URL of the source video to edit. Must be publicly accessible.

Important: Video URLs returned by the API are temporary. They are hosted on xAI's infrastructure (vidgen.x.ai) and are not guaranteed to remain accessible indefinitely. If you need to keep a generated video, download it immediately after generation completes.

Grok Imagine vs. Sora vs. Veo vs. Runway

Quality benchmarks: On the day of launch, Grok Imagine ranked first on Artificial Analysis's independent text-to-video benchmark and first on LMArena's image-to-video leaderboard. These rankings reflect quality evaluations as of January 28, 2026. Rankings in generative video are volatile — Runway, Sora, and Veo all update their models regularly.

Pricing comparison: Grok Imagine at $4.20/minute (audio included) was the lowest published API price at comparable quality at launch. Sora (OpenAI) and Veo (Google) were priced meaningfully higher for similar durations. Runway Gen-4.5 is priced per second with audio as a separate consideration. For high-volume video generation with audio requirements, Grok Imagine's all-inclusive pricing is the most cost-effective option available at quality parity.

Latency: xAI benchmarked P50 latency at 720p for 8-second videos against competitors using a 1-second polling interval. The methodology was disclosed — Grok Imagine was measured via the xAI API directly while Veo was measured via Vertex API and Sora via the OpenAI API. Independent latency at scale may vary from benchmarks. For iteration-heavy workflows where round-trip time affects developer productivity, Grok Imagine's latency advantage is a real workflow consideration.

Native audio: Grok Imagine generates audio natively alongside video — it is not a separate post-processing step. Sora and some Veo configurations do not generate synchronized audio by default. For applications requiring video with audio (ads, social content, product demos), Grok Imagine's native audio generation removes an entire production step.

Instruction following: xAI highlights instruction following as a specific design focus — the ability to restyle scenes, add or remove specific objects, and control motion direction through prompts. Early developer feedback cited by xAI partners (ComfyUI team, HeyGen) supports this, particularly for styles like retro anime, cyberpunk, and photorealistic product shots.

Partner platforms: In addition to the xAI API directly, Grok Imagine is available through fal.ai (day-0 launch partner with endpoints for all four generation types) and HeyGen (video agent integration). If you are already using fal.ai for other video models, you can access Grok Imagine through your existing fal.ai setup without a separate xAI account.

Common Issues and Fixes

401 Unauthorized. Your API key is missing, incorrect, or expired. Verify that your key is set correctly in the Authorization header as Bearer YOUR_KEY. Check console.x.ai to confirm the key is active.

402 Payment Required. Your account has no billing method attached or your free credits have been exhausted. Go to console.x.ai → Billing and add a payment method.

Video generation stuck at "processing". Video generation can take 30-90 seconds depending on duration and server load. Poll with a 3-second interval minimum. If status does not change after 5 minutes, the request may have failed silently — submit a new request.

Generated video URL returns 404. Video URLs are temporary. If you receive a URL but wait too long to access it, the file may have expired. Download the video immediately after status shows "done." For production applications, build download-and-store logic into your polling loop rather than relying on the xAI-hosted URL.

Image prompt returns blocked content. Grok Imagine's content filter is enforced on the API. Prompts that reference real people, explicit content, or graphic violence will be blocked. The filter is the same one applied in the Grok app. If a prompt is blocked, the API returns an error with a moderation reason.

Frequently Asked Questions

Is there a free tier for the Grok Imagine API? There is no ongoing free tier for API usage. New accounts receive $25 in promotional credits automatically, and an additional $150/month is available through the data sharing program at console.x.ai. These credits cover approximately 1,250 text-to-image generations or approximately 35 minutes of video at the current pricing.

Do I need a SuperGrok or X Premium subscription to use the API? No. API access is completely separate from subscription plans. You only need an xAI developer account at console.x.ai with a billing method attached. SuperGrok and X Premium subscriptions give you access to Grok Imagine through the Grok app, not through the API.

What is the maximum video duration? 15 seconds per generation via the API. For longer videos, you can chain multiple generations and concatenate the outputs.

What happened to the free tier in the Grok app? The free tier for Grok Imagine in the consumer Grok app was removed on March 19, 2026, following restrictions applied in January 2026 after a deepfake controversy. As of mid-2026, image and video generation in the Grok app requires a SuperGrok subscription ($30/month). API access is independent of this and remains available on a pay-per-generation basis.

Can I use Grok Imagine output commercially? Check xAI's current Terms of Service at x.ai/legal for the full commercial use policy. Generally, AI-generated content policies from major providers allow commercial use of outputs subject to the platform's content policies and applicable law. Verify before building a commercial product on top of generated content.

Tags
GrokAI agentsCoding AIVideo GenerationAI GuideAI News2026Generative AI