At a glance
The Grok Image API runs Grok Image Quality and 2 other variants through Mage at POST https://api.mage.space/v1/grok_image/generate. A request at the default settings costs 75 Gems (about $0.075), with no subscription. Grok Image takes saved characters, references by @handle in the prompt.
Image
Output
3
Variants
75
Gems per image, default
$0.075
About, in USD
Overview
What the Grok Image API does
xAI's Grok Imagine image model in three quality tiers. Generates or edits from up to 3 reference images while keeping the source's details intact. xAI's safety filter applies.
xAI's Grok Imagine image models in three quality tiers, for generation and edits from reference images. xAI's safety filter applies.
It accepts image, additional_images as inputs.
Quick start
Call the Grok Image API
Set MAGE_API_KEY, submit to /grok_image/generate, and poll status_url until the request completes.
cURL
STATUS_URL=$(curl --request POST 'https://api.mage.space/v1/grok_image/generate' \
--header "Authorization: Bearer $MAGE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "1:1",
"model_id": "grok-imagine-image-quality"
}' | jq -r '.status_url')
# Repeat until status is "completed"; result.url is the file
curl "$STATUS_URL" --header "Authorization: Bearer $MAGE_API_KEY"Python
import os, time, requests
headers = {"Authorization": f"Bearer {os.environ['MAGE_API_KEY']}"}
request = requests.post(
"https://api.mage.space/v1/grok_image/generate",
headers=headers,
json={
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "1:1",
"model_id": "grok-imagine-image-quality"
},
).json()
while request["status"] in ("queued", "in_progress"):
time.sleep(3)
request = requests.get(request["status_url"], headers=headers).json()
print(request["status"], request["result"] and request["result"]["url"])JavaScript
const headers = {
Authorization: `Bearer ${process.env.MAGE_API_KEY}`,
'Content-Type': 'application/json',
};
let request = await fetch('https://api.mage.space/v1/grok_image/generate', {
method: 'POST',
headers,
body: JSON.stringify({
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "1:1",
"model_id": "grok-imagine-image-quality"
}),
}).then((response) => response.json());
while (['queued', 'in_progress'].includes(request.status)) {
await new Promise((resolve) => setTimeout(resolve, 3000));
request = await fetch(request.status_url, { headers }).then((r) => r.json());
}
console.log(request.status, request.result?.url);Models
Grok Image model_id values
Send model_id to pick a variant. A request without one runs the default.
| model_id | Name | Default |
|---|---|---|
| grok-imagine-image | Grok Image | |
| grok-imagine-image-quality | Grok Image Quality | Yes |
| grok-imagine-image-2.0 | Grok Image 2.0 |
Options
Grok Image parameters
Allowed values across all variants; a variant may offer fewer. The docs list the options per variant.
| Field | Values |
|---|---|
| aspect_ratio | 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20 |
| resolution | 1k, 2k |
Inputs
Media inputs Grok Image accepts
Send each as an https URL, a data URL, or an upload of up to 100 MB.
| Field | Role |
|---|---|
| image | The reference image. |
| additional_images | Additional reference images. |
More image models
Other image generation APIs on Mage
Image · from 37 Gems
Guava API
Photorealism that passes for a photograph
Image · from 20 Gems
HiDream API
Fast and versatile, with negative prompts
Image · from 20 Gems
Krea 2 API
Gorgeous aesthetics in seconds
Image · from 135 Gems
Mango API
Our flagship image family
Image · from 68 Gems
Nano Banana 2 API
Crisp, readable text, up to 4K
Image · from 15 Gems
SDXL Plus API
SDXL with faces and hands fixed
FAQ
Frequently asked questions
How much does the Grok Image API cost?
A Grok Image request at the default settings (Grok Image Quality) costs 75 Gems, about $0.075. Other resolutions, durations, and variants change the price; the response reports the exact charge. A generation that fails is refunded; one Mage's content policy blocks is not.
What is the Grok Image API endpoint?
POST https://api.mage.space/v1/grok_image/generate with an Authorization: Bearer header carrying your Mage API key. The response includes a status_url to poll for the result.
Which Grok Image models can I call?
grok-imagine-image (Grok Image), grok-imagine-image-quality (Grok Image Quality), grok-imagine-image-2.0 (Grok Image 2.0). The default is Grok Image Quality.
Does Grok Image support reference images or characters?
Grok Image accepts image, additional_images. Grok Image takes saved characters, references by @handle in the prompt.
Can I use Grok Image from Claude or ChatGPT?
Yes. Connect the Mage MCP server to Claude, ChatGPT, Claude Code, Grok, or Cursor and ask for Grok Image by name. Your assistant reads its options with get_model and quotes the price before it generates.
How long are Grok Image results kept?
Results and inputs are kept for 30 days. Download anything you want to keep to your own storage.
Start building with Mage
One account, one Gems balance, every model. Pay only for what you generate.