Mage API · Image model
Grok Image API
Grok Imagine, in two tiers
POST https://api.mage.space/v1/grok_image/generateAt a glance
The Grok Image API runs Grok Image 2.0 and 1 other variant through Mage at POST https://api.mage.space/v1/grok_image/generate. A request at the default settings costs 90 Gems (about $0.09), with no subscription. Grok Image takes saved characters, references by @handle in the prompt.
- ImageOutput
- 2Variants
- 90Gems per image, default
- $0.09About, in USD
Overview
What the Grok Image API does
xAI's Grok Imagine image model in two 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 two tiers, for generation and edits from reference images: Grok Image 2.0 (`grok-imagine-image-2.0`), the default, and Grok Image (`grok-imagine-image`) for cheap drafts. xAI retired Grok Image Quality (`grok-imagine-image-quality`) on November 2, 2026, and a request that names it is refused. 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-2.0"
}' | jq -r '.status_url')
# Repeat until status is "completed"; result.url is the file
curl "$STATUS_URL" --header "Authorization: Bearer $MAGE_API_KEY"TypeScript
// npm install @mage-space/sdk
import Mage from '@mage-space/sdk';
const mage = new Mage(); // reads MAGE_API_KEY
const request = await mage.run('grok_image', {
prompt: 'Editorial portrait in soft daylight, 35mm film look',
aspect_ratio: '1:1',
model_id: 'grok-imagine-image-2.0',
});
console.log(request.result.url);Python
# pip install mage-space
from mage_space import Mage
mage = Mage() # reads MAGE_API_KEY
request = mage.run("grok_image", {
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "1:1",
"model_id": "grok-imagine-image-2.0",
})
print(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-2.0 | Grok Image 2.0 | Yes |
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
Guava API
Photorealism that passes for a photograph
HiDream API
Fast and versatile, with negative prompts
Krea 2 API
Gorgeous aesthetics in seconds
Mango API
Our flagship image family
MOSS-Image API
Long prompts and bilingual text, open weights
Nano Banana 2 API
Crisp, readable text, up to 4K
FAQ
Frequently asked questions
How much does the Grok Image API cost?
What is the Grok Image API endpoint?
Which Grok Image models can I call?
Does Grok Image support reference images or characters?
Can I use Grok Image from Claude or ChatGPT?
How long are Grok Image results kept?
Start building with Mage
One account, one Gems balance, every model. Pay only for what you generate.