Grok Imagine Image 2.0 API reference
Everything you need to call Grok Imagine Image 2.0 from your code. Base URL https://cheapergen.com/api/v1. Try it first in the playground.
Authentication
Create a key in Dashboard → API keys and send it as a bearer token. Keep keys server-side.
export CHEAPERGEN_API_KEY="cg_live_…"
# every request
Authorization: Bearer $CHEAPERGEN_API_KEYGrok Imagine Image 2.0 Text to Image API
/api/v1/run/xai/grok-imagine-image/text-to-imageSubmits an asynchronous job and returns 202 with a generation id. Poll GET /api/v1/generations/{id} or pass webhook_url. See job lifecycle.
Input parameters
| Name | Type | Description | Affects price |
|---|---|---|---|
promptrequired | string | Describe the shot: subject, action, camera movement, lighting and style. | No |
aspect_ratio | string (enum) | Output image shape. Values: 1:1 · 3:4 · 4:3 · 9:16 · 16:9 · 2:3 · 3:2 · 1:2 · 2:1 · 9:19.5 · 19.5:9 · 9:20 · 20:9 Default: 1:1 | Yes |
resolution | string (enum) | 1K ≈ 1 MP, 2K ≈ 4 MP. Values: 1K · 2K Default: 1K | Yes |
quality | string (enum) | Low is faster and cheaper; medium has more detail. (Edits always run at medium.) Values: low · medium Default: medium | Yes |
webhook_url | string (URL) | Optional. We POST the finished generation here, signed with your webhook secret. Webhooks | No |
Request
curl -X POST https://cheapergen.com/api/v1/run/xai/grok-imagine-image/text-to-image \
-H "Authorization: Bearer $CHEAPERGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Fashion editorial: a model in a sculptural orange coat on a salt flat at noon, harsh shadows, medium format",
"aspect_ratio": "1:1",
"resolution": "1K",
"quality": "medium"
}'Response
{
"id": "gen_8c2QmX1nq0k4",
"object": "generation",
"model": "xai/grok-imagine-image",
"endpoint": "xai/grok-imagine-image/text-to-image",
"mode": "text-to-image",
"status": "queued",
"input": {
"prompt": "Fashion editorial: a model in a sculptural orange coat on a salt flat at noon, harsh shadows, medium format",
"aspect_ratio": "1:1",
"resolution": "1K",
"quality": "medium"
},
"output": null,
"error": null,
"cost": {
"amount_usd": 0.2255,
"currency": "usd",
"estimated": true,
"official_usd": null,
"saved_usd": null
},
"source": "api",
"started_at": null,
"completed_at": null,
"urls": {
"get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4",
"cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4/cancel"
},
"created_at": "2026-10-15T09:21:04Z"
}Grok Imagine Image 2.0 Image Edit API
/api/v1/run/xai/grok-imagine-image/editSubmits an asynchronous job and returns 202 with a generation id. Poll GET /api/v1/generations/{id} or pass webhook_url. See job lifecycle.
Input parameters
| Name | Type | Description | Affects price |
|---|---|---|---|
promptrequired | string | Describe the shot: subject, action, camera movement, lighting and style. | No |
image_urlsrequired | string[] (URLs) | 1–3 images to edit or combine. Refer to them as "image 1", "image 2"… in the prompt. Max items: 3 | No |
aspect_ratio | string (enum) | Output image shape. Values: 1:1 · 3:4 · 4:3 · 9:16 · 16:9 · 2:3 · 3:2 · 1:2 · 2:1 · 9:19.5 · 19.5:9 · 9:20 · 20:9 Default: 1:1 | Yes |
resolution | string (enum) | 1K ≈ 1 MP, 2K ≈ 4 MP. Values: 1K · 2K Default: 1K | Yes |
webhook_url | string (URL) | Optional. We POST the finished generation here, signed with your webhook secret. Webhooks | No |
Request
curl -X POST https://cheapergen.com/api/v1/run/xai/grok-imagine-image/edit \
-H "Authorization: Bearer $CHEAPERGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Put the person from image 1 in the jacket from image 2 on a rainy Tokyo street at night",
"image_urls": [
"https://cdn.cheapergen.ai/samples/portrait.jpg"
],
"aspect_ratio": "1:1",
"resolution": "1K"
}'Response
{
"id": "gen_8c2QmX1nq0k4",
"object": "generation",
"model": "xai/grok-imagine-image",
"endpoint": "xai/grok-imagine-image/edit",
"mode": "edit",
"status": "queued",
"input": {
"prompt": "Put the person from image 1 in the jacket from image 2 on a rainy Tokyo street at night",
"image_urls": [
"https://cdn.cheapergen.ai/samples/portrait.jpg"
],
"aspect_ratio": "1:1",
"resolution": "1K"
},
"output": null,
"error": null,
"cost": {
"amount_usd": 0.2255,
"currency": "usd",
"estimated": true,
"official_usd": null,
"saved_usd": null
},
"source": "api",
"started_at": null,
"completed_at": null,
"urls": {
"get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4",
"cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4/cancel"
},
"created_at": "2026-10-15T09:21:04Z"
}Get the result
Generations are asynchronous. Poll until status is succeeded, failed or canceled — or pass webhook_url when you submit. Failed generations are refunded automatically.
curl https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4 \
-H "Authorization: Bearer $CHEAPERGEN_API_KEY"More: job lifecycle · webhooks · errors
Grok Imagine Image 2.0 pricing
Pay per image. No subscription. Failed generations are refunded automatically.
| Tier | Official price | Cheaper Gen. | You save |
|---|---|---|---|
1K · low | $0.035/img | −12% | |
1K · medium | $0.053/img | −12% | |
2K · low | $0.053/img | −12% | |
2K · medium | $0.07/img | −12% |
- Official price: xAI API list price for grok-imagine-image-2.0 (1K $0.04 low / $0.06 medium, 2K $0.06 / $0.08; $0.01 per input image). Prices verified 2026-10-16.
- Edits are billed at medium quality plus $0.01 per input image (before our discount).