Overview
Grok Imagine Official is the official channel for xAI’s image models: requests are relayed by APIYI to the official xAI API, pricing matches xAI’s list price, billing follows resolution and quality tier, and parameter validation is the same as upstream. Three models are available: the standardgrok-imagine-image, the high-quality grok-imagine-image-quality, and the newer grok-imagine-image-2.0 (with low / medium quality tiers).
grok-imagine-image-2.0 at medium quality and 2K takes about 60–80 seconds in our tests, so give this model a generous timeout. See Image API Notes & Best Practices.Text-to-Image API
Grok Imagine Video
GrokOfficial group — text-to-video and image-to-video, billed per second.Let an AI Agent Integrate It
Copy this prompt and paste it into Codex / Claude Code / Cursor
It fetches the plain-text version of this page first (append .md to any docs URL), then writes code for your stack — timeouts, saving URL results right away, using resolution instead of size, and one image per call are already baked into the requirements.
Integrate / troubleshoot Grok Imagine Official text-to-image in this project.
Read the docs before writing code: fetch https://docs.apiyi.com/en/api-capabilities/grok-imagine-image-official/overview.md for the plain-text version of this page; …
- Pick one model:
grok-imagine-image,grok-imagine-image-quality, orgrok-imagine-image-2.0…
8 requirements in total — use the button below to copy the full version
Models & Pricing
Pricing matches xAI’s list price and is charged per image; the tier is set byresolution (plus quality for 2.0):
- Defaults:
resolutiondefaults to1k;grok-imagine-image-2.0defaults toquality: low, i.e. $0.04 per image. - Per image, one per call: keep
n=1on this channel and call concurrently when you need more images. - Failed requests are not billed: parameter errors (422 / 400), missing group access (503), and other error responses are free.
- Do not reconcile with
usage:prompt_tokensis always1000 × image count, a placeholder; the console billing records are authoritative. - Tiered top-up bonuses apply on top; high-volume business customers can contact sales about dedicated pricing.
Official vs reverse
APIYI offers both an official and a reverse channel for Grok Imagine. They differ in group, billing, and capabilities:Group Setup
Who can get access
How to apply
Contact WeCom support
GrokOfficial (Grok Imagine Official).Describe your use case and moderation controls
Switch your Token group once approved
GrokOfficial on your account. Go to the Token page in the console, switch the Token you use for this channel to GrokOfficial, and set the billing mode to Pay-as-you-go Priority or Pay-as-you-go.GrokOfficial group returns 503 (no available channel in the current group). Retrying will not help — the group has to be enabled first.Do not use the Pay-per-request billing mode: this channel is metered, so a pay-per-request Token cannot be routed and also returns 503.Technical Specs
Key Parameters
resolution and aspect_ratio (output size)
Together they determine the output pixels. Some measured results:
resolution: "4k" or aspect_ratio: "5:7" return 422 and are not billed. When you see a 422, check the spelling of these two parameters first (all lowercase: 1k / 1.5k / 2k).quality (grok-imagine-image-2.0 only)
high returns 400 (This model only supports the following quality value(s): low, medium, auto). Send only low or medium — do not send auto. grok-imagine-image and grok-imagine-image-quality take no quality; the model itself sets the fidelity.
n (image count)
Always send n=1 on this channel. For several images at once, send several requests concurrently — latency is steady, so concurrency scales linearly.
Best Practices
Explore at 1k, finish at 2k
1k to pick a direction, then render the final at 2k. grok-imagine-image-2.0 at medium and 2K takes over a minute, which makes it a poor fit for trial and error.Set the client timeout to 360 seconds
medium, and requests cut off by the client are still billed.Use aspect_ratio for framing, not the prompt
aspect_ratio: "16:9" is far more reliable than writing “landscape composition” in the prompt.Save URL results right away
Switch to the reverse channel for editing
/v1/images/edits on Grok Imagine Reverse.Error Codes & Retries
400 / 422 are deterministic errors — retrying is pointless, alert on them instead. Only 429 and network-level timeouts are worth retrying, with exponential backoff and at most 3 attempts. Error responses are not billed.FAQ
Every call returns 503 — is the channel down?
Every call returns 503 — is the channel down?
- The Token group lacks
GrokOfficial: this channel is granted on application; see Group Setup. - The Token’s billing mode is pay-per-request: this channel is metered and cannot be routed from a pay-per-request Token. Switch the billing mode to
Pay-as-you-go PriorityorPay-as-you-go.
I passed size: 2048x2048 — why is the output still 1K?
I passed size: 2048x2048 — why is the output still 1K?
size to a resolution tier, so the image is generated and billed at the default 1k. Use resolution: "2k" instead and control framing with aspect_ratio.Can I edit images or pass a reference image?
Can I edit images or pass a reference image?
/v1/images/generations raises no error, but the reference is ignored and a new image is generated from the prompt alone.For editing or multi-image fusion, get access to Grok Imagine Reverse, whose /v1/images/edits accepts 1–4 reference images.Why n=1? How do I get several images at once?
Why n=1? How do I get several images at once?
n=1 each. If your workflow genuinely depends on several images per call, use Grok Imagine Reverse (n up to 10).How does grok-imagine-image-2.0 differ from the other two?
How does grok-imagine-image-2.0 differ from the other two?
grok-imagine-image-2.0 is xAI’s newer image model and adds a quality tier (low / medium); medium has finer detail but is slower (about 60–80 seconds at 2K). grok-imagine-image is the cheapest and costs the same at every resolution; grok-imagine-image-quality has higher fidelity with tiered pricing by resolution.Get your pipeline working on grok-imagine-image or 2.0 low first, then move up a tier as quality needs dictate.Can I reconcile my bill with the token counts in usage?
Can I reconcile my bill with the token counts in usage?
usage.prompt_tokens is always 1000 × image count, a placeholder unrelated to actual charges. This channel bills per image by resolution and quality tier; the console billing records are authoritative.Can I use the official OpenAI SDK?
Can I use the official OpenAI SDK?
base_url at https://api.apiyi.com/v1 and put non-standard fields in extra_body:Related Docs
- Grok Imagine Official Text-to-Image API - API reference with Playground
- Grok Imagine Video - same group, text-to-video and image-to-video
- Grok Imagine Reverse - flat per-image pricing, with editing and multiple images per call
- Image API Notes & Best Practices - general advice on timeouts, disconnects, and compression
- Top-up Bonuses