
Set quality on grok-imagine-image-2.0
Set quality on grok-imagine-image-2.0
On grok-imagine-image-2.0, pass optional quality: low, medium, or auto. When omitted, the default is auto. Auto currently uses low for image generation and medium for image editing. You are billed at the quality that was served. The parameter is unsupported on other Imagine image model slugs.
Pin low or medium
curl -X POST https://api.x.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XAI_API_KEY" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "A watercolor painting of a lighthouse at dawn",
"quality": "medium"
}'
import xai_sdk
client = xai_sdk.Client()
response = client.image.sample(
prompt="A watercolor painting of a lighthouse at dawn",
model="grok-imagine-image-2.0",
quality="medium",
)
print(response.url)
OpenAI-compatible clients often need extra_body={"quality": "medium"}.
Leave auto
Omit quality (or pass "auto") when you want the service to choose. Check the billed quality against Pricing if cost variance matters.
Pair with resolution and aspect ratio
resolution accepts 1k (default) or 2k. aspect_ratio defaults to auto; explicit values include 16:9, 21:9, 5:2, and the other ratios listed in the Image Generation docs.
Pitfalls
- Setting
qualityongrok-imagine-image(1.0) or the retiringgrok-imagine-image-qualityslug — only 2.0 accepts it. - Assuming
autoalways meansmedium— generation currently lands onlow. - Forcing a Quality-era slug instead of migrating — see Migrate from grok-imagine-image-quality before November 2.