altrouter.ai
Models/xAI/Grok Imagine
GK

xAI: Grok Imagine

Imagegrok-imagine

xAI's Grok Imagine: image generation and editing.

API docs
Playgroundgrok-imagine
Reference image
Aspect ratio
Pro quality
Latency10.4 s
24hnow
Specifications
Authorxai
ModalityImage
Price$0.030 / image$0.037 / image
Savings20%
Quick start
from openai import OpenAI

client = OpenAI(
    base_url="https://api.altrouter.ai/v1",
    api_key="ar-...",
)

img = client.images.generate(
    model="grok-imagine",
    prompt="a red fox in the snow",
)
print(img.data[0].url)

Same OpenAI-compatible endpoint — just swap base_url and key.

API

OpenAI-compatible image generation endpoint. The result is re-hosted on our CDN and returned as a URL.

POST/v1/images/generations
Body parameters
modelstringrequired"grok-imagine"
The model id.
promptstringrequired
The text description of the image.
imagestringURL or base64
Reference images for editing.
aspect_ratioenum1:1 · 16:9 · 9:16 · 2:3 · 3:2default 1:1
Output aspect ratio.
enable_probooleandefault false
Pro mode: higher quality, costs more.
Response
createdinteger
Unix creation time (seconds).
dataarray
Images. Each: url (our CDN), b64_json, revised_prompt.
Example
cURLPythonJSON
curl https://api.altrouter.ai/v1/images/generations \
  -H "Authorization: Bearer ar-..." \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine",
  "prompt": "a red fox in the snow",
  "aspect_ratio": "1:1"
}'
Errors
400Invalid request.
401Missing or invalid API key.
402Insufficient credits, or the key’s spending cap is exhausted.
404Model not found.
429Rate limit exceeded.
More from xAI
Grok 4.5
grok-4.5
Grok 4.3
grok-4.3