grok-imagine-image-2.0, and each image costs $0.055 at 1K or 2K, with no xAI account needed.
What grok-imagine-image-2.0 supports
xAI prices by resolution and quality; on LaoZhang API each of these tiers is $0.055 per image, with no input charge for edits:
- 1K medium or 2K low: $0.06 at xAI
- 2K medium: $0.08 at xAI
- Edits: xAI adds $0.01 per input image

Output of the generate example below: 2K, 16:9, medium
Parameters and limits
Choose a Grok Imagine model
grok-imagine-image: withdrawn on October 30, 2026; calls now return 503. Changemodeltogrok-imagine-image-2.0;aspect_ratioand multi-reference edits work the same way. See the withdrawal notice.grok-imagine-image-quality: xAI announced the retirement of this model from November 2, 2026, with its requests served bygrok-imagine-image-2.0atlowquality (xAI migration guide). As of November 3, 2026, it is still callable on LaoZhang API at $0.045 per successfully returned image, billed the same way as 2.0. For new integrations, use 2.0 and setqualityexplicitly.
Before you call the API
1
Create and protect an API key
Create a key in the
default group in Token management and set Billing mode (计费模式) to Usage first (按量优先, recommended) or Per-call (按次计费). A Usage first key can call both per-call and usage-based models; a Per-call key calls only per-call models.Keep the key in a server-side environment variable, never in browser code, a public repository, or logs.2
Confirm model access and price
In Models and pricing, check that the key can use
grok-imagine-image-2.0 and review the current price.3
Set up your environment
Export the key and install the OpenAI Python SDK, which the Python examples use:
Generate and edit images
Generate an image
This request creates one 2K, 16:9 image atmedium quality and writes the response to grok-generation.json:
data:
Save the result
The URL is temporary, so download the image right away. Save this script assave_images.py. It writes every image in a response to disk, whether the response contains url or b64_json, and picks the file extension from the image data:
save_images.py
Saved grok-lighthouse-1.jpg. Open the file and check the subject, text, and composition. To receive the image bytes in the response instead of a URL, set response_format to b64_json.
Generate with the Python SDK
The OpenAI Python SDK doesn’t expose every Grok image option as a named parameter, so passaspect_ratio, resolution, and quality in extra_body. This example requests Base64 output and saves the decoded image:
Edit one reference image
Editing requires a file upload. Put a localproduct-photo.png in the current directory, then run:
Edit with two or three references
Repeat theimage[] field for each reference. This request supplies the subject, the scene, and the style as three separate files:
aspect_ratio=3:2, expect a landscape result such as 1248×832.
Edit with the Python SDK
The OpenAI SDK works for single-image edits. This example returns a URL and downloads the image immediately:Aspect ratio, resolution, and quality
grok-imagine-image-2.0 accepts these 15 fixed aspect ratios:
Omit
aspect_ratio to let the model choose, or pass a value when the layout must be predictable.
resolution="1k"is faster and suits drafts, thumbnails, and batch candidates.resolution="2k"produces larger files with longer latency, for final assets and cropping.quality="low"favors speed;quality="medium"favors detail.- Don’t send
quality="high"orresolution="4k".
quality to low or medium explicitly rather than relying on auto, so latency and output quality stay predictable.
Pricing and billing
Billing counts the images a request actually returns:
LaoZhang API charges the same price for
1k and 2k and for low and medium. The comparison with xAI’s prices by resolution and quality is in the price note at the top of this page.
Check the console before a large batch, and treat call records as the final billing source.
Parameters, errors, and launch checks
Parameters
Error handling
Retry valid requests that hit 429, network errors, or clearly temporary 5xx errors with jittered exponential backoff. After a client timeout, check the call record before you resubmit, so you don’t generate and pay for the same image twice.
Before you go to production
- Generate one
1k,lowimage with the production key. - Save the result and check its real format and dimensions.
- Test the exact resolution, quality, aspect ratio, and
nvalues you plan to use. - For edits, use distinct, non-sensitive references and confirm that each one affects the output.
- Enforce the three-reference limit in your client.
- Set a timeout of at least 60 seconds for
1klowrequests and 120–180 seconds formediumor2k. - Reconcile success rate, latency, output count, and call records before raising concurrency.
Frequently asked questions
Can I call Grok Imagine without an xAI account?
Yes. You need only a LaoZhang API key, not an xAI account. Generation and editing both use the OpenAI-compatible Images endpoints, billed per successfully returned image.What is the exact model ID?
Usegrok-imagine-image-2.0, including the final .0. The earlier grok-imagine-image was withdrawn on October 30, 2026; grok-imagine-image-quality is a separate earlier model that xAI announced it would retire from November 2; use 2.0 for new integrations.
Am I billed per image? Do resolution and quality change the price?
Per successfully returned image.1k, 2k, low, and medium currently share one per-image price; see Pricing and billing for examples. Latency differs by tier, so plan timeouts accordingly: on October 14, 2026 the quick-start prompt took 16 s at 1K low and 71 s at 2K medium, and each call was logged at $0.055.

1K, low, 16:9: 16 s, $0.055

2K, medium, 16:9: 71 s, $0.055
Can I edit with xAI’s JSON format or send four or five references?
No to both. Editing accepts only multipart file uploads, with up to three references, as the table at the top of this page shows. xAI’s JSON image objects return HTTP 400. xAI’s documentation says the OpenAI SDK’simages.edit() doesn’t work for Grok editing; that applies to xAI’s own JSON-only API.
On LaoZhang API, images.edit() works for single-image edits, as shown in Edit with the Python SDK. For several references, start with the cURL image[] form.
What aspect ratio does an edit return?
According to xAI, an edit withoutaspect_ratio follows the first reference image’s aspect ratio. To fix the frame, add aspect_ratio to the edit request; the three-reference example uses aspect_ratio=3:2 and returns a 1248×832 image.
Can I keep editing the previous result?
Yes. Download the previous result, upload it as theimage, and describe only this round’s change in the prompt, such as “Keep everything the same and add a gold border.” Each round is a new edit request, billed for the images it returns.
How should I store generated images?
Download URL results promptly into your own storage; xAI also describes the returned URLs as temporary. Useb64_json when the image must arrive inside the API response.
Sources and related documentation
- Grok Imagine Image 2.0 launch announcement: availability and the three-reference editing scope
- xAI Grok Imagine Image 2.0 model: official model ID and upstream pricing by resolution and quality
- xAI image generation: official ratios, resolution, quality, batching, and response formats
- xAI image editing: the upstream JSON editing format, which differs from LaoZhang API’s multipart interface
- xAI multi-image editing: how to write multi-image edit prompts; LaoZhang API accepts up to three references per edit
- Images API reference: shared request and response structure
- Choose an image generation API: compare Grok Imagine with other image models
- Models and pricing in the console: models, groups, prices, and call records for your account