models/xAI/Grok Imagine Image 2.0 (Text To Image)
xAI

Grok Imagine Image 2.0 (Text To Image)

image
Compare

Generate images from text using xAi's Grok Imagine 2.0 model.

MODALITIES
image
PER IMAGE
$0.060

Grok Imagine Image 2.0 (Text To Image) (xai/grok-imagine-image-2.0) is a image model from xAI. Pricing via AIgateway: $0.060 per image. Call it via https://api.aigateway.sh/v1/images/generations — set model="xai/grok-imagine-image-2.0".

model · xai/grok-imagine-image-2.0

Use this model

model: xai/grok-imagine-image-2.0
curl https://api.aigateway.sh/v1/images/generations \
  -H "Authorization: Bearer $AIGATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"xai/grok-imagine-image-2.0","prompt":"a serene cyberpunk city at dusk"}'
API schema

Call Grok Imagine Image 2.0 (Text To Image) from any OpenAI SDK

POST https://api.aigateway.sh/v1/images/generations·Content-Type: application/json·Auth: Bearer sk-aig-...

Request body

json
{
  "model": "xai/grok-imagine-image-2.0",
  "prompt": "A cyberpunk cat at sunset, cinematic lighting",
  "n": 1,
  "size": "1024x1024",
  "response_format": "url"   // or "b64_json"
}

Response

json
{
  "created": 1776947082,
  "data": [
    { "url": "https://media.aigateway.sh/img/abc123.png" }
    // or { "b64_json": "iVBORw0KGgoAAAANSUhEU..." }
  ]
}

Quickstart

from openai import OpenAI
client = OpenAI(base_url="https://api.aigateway.sh/v1", api_key="sk-aig-...")

r = client.images.generate(
    model="xai/grok-imagine-image-2.0",
    prompt="a cyberpunk cat at sunset",
    size="1024x1024",
)
print(r.data[0].url)

Errors

401authentication_errorInvalid or missing API key
402insufficient_creditsWallet empty (PAYG only)
404not_foundUnknown model or endpoint
429rate_limit_errorOver per-minute limit — see Retry-After header
500server_errorUpstream provider failed (retryable)
503service_unavailableUpstream saturated (retryable)
Full docs →API reference →OpenAPI spec →llms.txt →

Frequently asked questions

What is Grok Imagine Image 2.0 (Text To Image)?
Generate images from text using xAi's Grok Imagine 2.0 model. It is a image model from xAI, accessible via AIgateway's OpenAI-compatible API at slug xai/grok-imagine-image-2.0.
How much does Grok Imagine Image 2.0 (Text To Image) cost via AIgateway?
$0.0600 per image, billed pass-through.
How do I call Grok Imagine Image 2.0 (Text To Image) from my code?
Point the OpenAI SDK at https://api.aigateway.sh/v1 with your AIgateway key and set model to "xai/grok-imagine-image-2.0". The request and response shapes match OpenAI exactly.
Does Grok Imagine Image 2.0 (Text To Image) support streaming, tool calling, vision, and JSON mode?
Streaming — no. Tool calling — no. Vision — no. JSON mode — no. Prompt caching — no.
Can I bring my own xAI API key (BYOK)?
Yes. Attach a xAI key in your AIgateway dashboard and this model flips to pass-through — you pay xAI directly and AIgateway adds no platform fee on those calls.