Grok Imagine API
How to get a Grok Imagine API key and what a clip costs: the 6 and 10 second prices next to xAI’s per-second rate, the modes and aspect ratios it takes, and the call that makes one.
Grok Imagine API price per clip
| Clip | Here | Per second | xAI at $0.050 a second | Less |
|---|---|---|---|---|
| 6 seconds | $0.2093 | $0.0349 | $0.30 | 30% |
| 10 seconds | $0.2791 | $0.0279 | $0.50 | 44% |
USD per clip. Here: live from GET /v1/catalog/media, any aspect ratio and mode. xAI: its grok-imagine-video rate on docs.x.ai (Imagine Pricing), read 2026-10-19, times the clip length.
One price per clip length, set when the request is accepted. The aspect ratio, the mode and a reference image change nothing. xAI bills the same model by the second, so its price for a clip is $0.05 times the duration; a 6-second clip is $0.30 there and $0.2093 here. Prices on this page are read from the catalog when the page is built, at most five minutes old, and a top-up locks your rate for 30 days.
Grok Imagine API key: two ways to get one
The API runs on xAI's own cloud or through a provider that resells the model. Both bill per clip. The difference is which models the key reaches and how you pay.
From xAI
- Create an account at the xAI console and set up billing.
- Open API keys and create one.
- Start a clip with
POST /v1/videos/generationsonapi.x.ai, then readGET /v1/videos/{request_id}until its status isdone.
export XAI_API_KEY="xai-..."
# xAI's own base URL and video endpoint:
# POST https://api.x.ai/v1/videos/generations, then GET https://api.x.ai/v1/videos/{request_id}Endpoints from xAI's video generation guide, read 2026-10-19; its prices are on the models page.
One key for Grok Imagine and every other model
- Sign in to the console and add credit, from $10. There is no subscription.
- Create a key. It calls
grok-imagine-video, every other video, image, speech and 3D model, and every chat model. - Send the model and its settings to
POST /v1/generationson our base URL, below.
export UPLINK_API_KEY="sk-uplink-live-..."
# one base URL for Grok Imagine and every other model:
# https://api.uplinkswitch.com/v1Which Grok Imagine model this key serves
xAI sells six Imagine models by API. This key serves one of them, Grok Imagine Video, the video model in the table above. The rest are listed so you know what you are and are not getting.
| xAI model id | xAI price | On this key |
|---|---|---|
grok-imagine-video | $0.050 per second | yes, $0.2093 per 6 s |
grok-imagine-video-1.5 | $0.080 per second | no |
grok-imagine-video-1.5-lite | $0.020 per second | no |
grok-imagine-image | $0.02 per image | no |
grok-imagine-image-2.0 | $0.04 per image | no |
grok-imagine-image-quality | $0.05 per image | no |
xAI's own prices from docs.x.ai (Imagine Pricing), read 2026-10-19. The right column is the catalog today; new models show up at GET /v1/catalog/media before they show up here.
For still images on this key, the Nano Banana and Seedream guides have the per-image prices, and the text-to-image list has every model.
Make a Grok Imagine clip
Send the model and its input to POST /v1/generations. The answer comes back at once, 202, with the generation id and the price. duration is required; everything else has a default.
curl https://api.uplinkswitch.com/v1/generations \
-H "Authorization: Bearer $UPLINK_API_KEY" \
-H "Content-Type: application/json" \
-H "HTTP-Referer: https://uplinkswitch.ai" \
-H "X-Title: your app name" \
-d '{
"model": "grok-imagine-video",
"input": {
"prompt": "A red kite turning slowly over a wheat field at golden hour, camera tracking from below",
"duration": 6,
"aspect_ratio": "16:9",
"mode": "normal"
}
}'
# 202 with the generation id and the price already set:
# {"id": "gen_...", "status": "queued", "model": "grok-imagine-video", "charge": {"amount_usd": "...", "units": 1, "unit": "generation"}}Poll the generation until its status is succeeded or failed; it passes through running and finalizing on the way, usually within a few minutes. A finished one lists its file URL in outputs.
curl https://api.uplinkswitch.com/v1/generations/gen_... \
-H "Authorization: Bearer $UPLINK_API_KEY" \
-H "HTTP-Referer: https://uplinkswitch.ai" \
-H "X-Title: your app name"
# "status" moves queued -> running -> finalizing -> succeeded (or failed, which is refunded);
# a finished clip is the first entry in "outputs":
# {"id": "gen_...", "status": "succeeded", "outputs": [{"url": "https://api.uplinkswitch.com/v1/files/media/...", "content_type": "video/mp4", "bytes": 1234567}]}Grok Imagine API in Python
The generations endpoint is plain JSON over HTTPS, so requests is all you need. Start the clip, sleep, read it back until it is done.
import os, time, requests
BASE = "https://api.uplinkswitch.com/v1"
HEADERS = {
"Authorization": f"Bearer {os.environ['UPLINK_API_KEY']}",
"HTTP-Referer": "https://uplinkswitch.ai",
"X-Title": "your app name",
}
gen = requests.post(
f"{BASE}/generations",
headers=HEADERS,
json={
"model": "grok-imagine-video",
"input": {
"prompt": "A paper lantern rising past a pagoda roof at night, soft rain",
"duration": 10,
"aspect_ratio": "9:16",
"mode": "fun",
},
},
).json()
print("charged", gen["charge"]["amount_usd"])
while gen["status"] not in ("succeeded", "failed"):
time.sleep(5)
gen = requests.get(f"{BASE}/generations/{gen['id']}", headers=HEADERS).json()
if gen["status"] == "succeeded":
print(gen["outputs"][0]["url"]) # the clip, served from https://api.uplinkswitch.com/v1 for 30 days
else:
print("failed and refunded:", gen)The same two calls work from any language: one POST, then GETs five seconds apart. The media guide has the endpoint in full, including the hourly sweep that finishes clips nobody polls.
Settings: duration, aspect ratio, mode
| Setting | Values | Notes |
|---|---|---|
duration | 6 or 10 | Seconds. Required; it sets the price. |
aspect_ratio | 1:1, 2:3, 3:2, 16:9, 9:16 | 16:9 for landscape, 9:16 for shorts and reels, 2:3 and 3:2 for portrait and photo frames. |
mode | fun, normal, spicy | One per request. Same price in every mode. |
image_urls | up to 1 image | A still to animate. Public JPEG or PNG URL. |
prompt | text | Required. Describe the subject, the motion and the camera. |
Read from GET /v1/catalog/media when the page was built. An unknown setting or value is refused before anything runs, and nothing is charged.
There is no resolution setting on this model: the catalog lists none, and the price does not change with the frame size.
Animate a still image
Put the image in image_urls and write the prompt as the motion you want. The frame sets the subject; the prompt sets what happens to it. The price is the clip price, nothing extra for the image.
curl https://api.uplinkswitch.com/v1/generations \
-H "Authorization: Bearer $UPLINK_API_KEY" \
-H "Content-Type: application/json" \
-H "HTTP-Referer: https://uplinkswitch.ai" \
-H "X-Title: your app name" \
-d '{
"model": "grok-imagine-video",
"input": {
"prompt": "The model turns toward the camera and smiles; wind in the hair",
"image_urls": ["https://example.com/portrait.jpg"],
"duration": 6,
"aspect_ratio": "2:3"
}
}'A product shot, a portrait or a frame made by an image model on the same key all work. Make the still with Nano Banana or Seedream in one call, pass its URL here in the next, and the whole pair is billed on one statement.
What Grok Imagine clips cost at volume
| Clip | 10 clips | 100 clips | 1,000 clips |
|---|---|---|---|
| 6 seconds | $2.09 | $20.93 | $209.30 |
| 10 seconds | $2.79 | $27.91 | $279.10 |
USD, our live price per clip times the count. Each request makes one clip.
A $10 top-up is 47 6-second clips or 35 10-second ones. The 10-second clip is the better buy per second: $0.0279 against $0.0349.
Grok Imagine next to other video models
The same key calls every video model below. Each is shown as one short clip at its lowest resolution without sound, so the per-second column compares like with like; longer clips, 1080p, 4k and audio are on the model pages.
| Model | Clip | Per clip | Per second |
|---|---|---|---|
| Seedance 1.5 Pro | 8 s, 720p, no audio | $0.20 | $0.025 |
| Grok Imagine Video | 10 s, any aspect ratio | $0.2791 | $0.0279 |
| Veo 3.1 Lite | 8 s, 720p | $0.24 | $0.03 |
| Grok Imagine Video | 6 s, any aspect ratio | $0.2093 | $0.0349 |
| Hailuo 2.3 | 6 s, 768p | $0.2188 | $0.0365 |
| Kling 2.1 Standard | 5 s | $0.1875 | $0.0375 |
| Kling 2.5 Turbo Pro | 5 s | $0.2625 | $0.0525 |
| Veo 3.1 Fast | 8 s, 720p | $0.48 | $0.06 |
| Seedance 1.0 Pro | 5 s, 720p | $0.3706 | $0.0741 |
USD, live from GET /v1/catalog/media, sorted by our price per second.
Veo 3.1 clips carry sound and 8 seconds at 720p; the Veo 3.1 guide has Google's price next to ours. The text-to-video list has every video model and setting.
Timing and errors
POST /v1/generationsanswers at once with the price set. A clip is usually ready within a few minutes; poll every five seconds or so.- A request without
duration, or with a value other than 6 or 10, is refused with a 400 before anything runs. So is an unknown mode or aspect ratio. - 401 is a missing or revoked key. 402 is an empty balance or a key at its monthly spend limit, so top up or raise the limit in the console. 429 is a limit on the key or on how many requests the account runs at once, or a busy model; the response says which, and a busy model is worth a retry in a minute.
- A clip that fails is refunded in full, and one still unfinished after 6 hours is marked failed and refunded.
- The file is an .mp4 on
api.uplinkswitch.com, kept 30 days. Download what you want to keep.
Keep the key safe
Anyone holding the key spends your credit. Keep it in an environment variable or a secrets manager, out of git and out of code that runs in a browser: start the clip from your server and hand the finished URL to the page. A key can carry a monthly spend limit and a list of the models it may call, set in the console. If it leaks, revoke it there and create a new one.
Billing, receipts and the daily check
The price is charged when the request is accepted and refunded in full if the clip fails. Every charge sits on a signed receipt and a monthly statement you can check at /statements/verify. Whether the model answered today is public at /proof, which calls every model on the list once a day. Every setting and both prices are on the model page and at GET /v1/catalog/media, and the Grok API pricing page covers xAI's chat models on the same key.