xAI logo
xAI

Grok Imagine Image Quality

xAI flagship image generation and editing model (Quality mode) with text-to-image, single/multi reference-image editing, selectable aspect ratios, and 1K/2K resolutions

Category Image Model ID grok-imagine-image-quality
Model TypeImage generation and editing
Input / OutputText and image input, image output
API EndpointsSupports Image API generations and edits

Pricing & Specs

💰 Pricing

Price$0.05 / image (1K)

⚙️ Specs

Model TypeImage generation and editing
Input / OutputText and image input, image output
API EndpointsSupports Image API generations and edits
EditingSingle reference image via the image object, multiple references via the images array, blending subjects and styles across images
Resolutionresolution accepts 1k / 2k
Aspect Ratioaspect_ratio accepts auto, 1:1, 16:9, 9:16, 3:2, 2:3, and more
Output FormatUse response_format b64_json; results are in data[].b64_json
Standard Pricing$0.05 per image at 1K resolution, $0.07 per image at 2K, $0.01 per input reference image for edits
ReleasexAI released the Grok Imagine image generation API in January 2026; Quality mode is positioned by xAI as its most advanced image generation model, with enhanced detail and stronger text rendering
Doc StatusUpdated from xAI's official model page and the XAI Router image endpoint docs

API Examples

Python

from openai import OpenAI
import base64

client = OpenAI(
    base_url="https://api.xairouter.com/v1",
    api_key="your-api-key"
)

result = client.images.generate(
    model="grok-imagine-image-quality",
    prompt="An orange cat wearing an astronaut helmet, cinematic lighting",
    n=1,
    response_format="b64_json",
    extra_body={"aspect_ratio": "1:1", "resolution": "1k"},
)

with open("grok-image.jpg", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))

cURL

# Text-to-image
curl --fail-with-body -sS https://api.xairouter.com/v1/images/generations \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "grok-imagine-image-quality",
    "prompt": "An orange cat wearing an astronaut helmet, cinematic lighting",
    "n": 1,
    "aspect_ratio": "1:1",
    "resolution": "1k",
    "response_format": "b64_json"
  }' > grok-image-response.json

jq -er '.data[0].b64_json' grok-image-response.json \
  | base64 --decode > grok-image.jpg

# Image editing (single reference image via the image object)
REFERENCE_B64="$(base64 < reference.jpg | tr -d '\r\n')"

curl --fail-with-body -sS https://api.xairouter.com/v1/images/edits \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary @- <<JSON > grok-edit-response.json
{
  "model": "grok-imagine-image-quality",
  "prompt": "Keep the subject and composition, change the background to a rainy neon street at night",
  "n": 1,
  "resolution": "1k",
  "response_format": "b64_json",
  "image": {
    "url": "data:image/jpeg;base64,${REFERENCE_B64}"
  }
}
JSON

jq -er '.data[0].b64_json' grok-edit-response.json \
  | base64 --decode > grok-edited.jpg