Skip to main content
Grok Imagine Image 2.0 is xAI’s current image model. Text-to-image and reference editing both use the OpenAI-compatible Images endpoints, and one request can return several images. On LaoZhang API the model ID is 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
The model is made by xAI. Public pricing as of September 24, 2026, verified on October 14, 2026; see the model and pricing catalog. xAI’s prices are from its model page, verified October 13, 2026.
A cinematic lighthouse at sunrise with ocean reflections, generated by Grok Imagine Image 2.0

Output of the generate example below: 2K, 16:9, medium

Parameters and limits

Editing accepts OpenAI-compatible file uploads, not the JSON image objects shown in xAI’s documentation. Requests with four or five references fail, so enforce the three-image limit in your client and don’t retry an over-limit request.

Choose a Grok Imagine model

  • grok-imagine-image: withdrawn on October 30, 2026; calls now return 503. Change model to grok-imagine-image-2.0; aspect_ratio and 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 by grok-imagine-image-2.0 at low quality (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 set quality explicitly.

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 at medium quality and writes the response to grok-generation.json:
A successful response returns HTTP 200 with one item in data:

Save the result

The URL is temporary, so download the image right away. Save this script as save_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
The script prints a line such as 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 pass aspect_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 local product-photo.png in the current directory, then run:
Reference editing regenerates the scene; it isn’t pixel-level mask inpainting. Check the subject, color, text, and composition in the saved image.

Edit with two or three references

Repeat the image[] field for each reference. This request supplies the subject, the scene, and the style as three separate files:
Upload order maps to image 1, image 2, and image 3 in the prompt. A successful request returns one image; with 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:
For multiple references, start with the cURL form above to confirm how your HTTP client serializes repeated multipart fields.

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" or resolution="4k".
Responses don’t report which quality tier was used. Set 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

  1. Generate one 1k, low image with the production key.
  2. Save the result and check its real format and dimensions.
  3. Test the exact resolution, quality, aspect ratio, and n values you plan to use.
  4. For edits, use distinct, non-sensitive references and confirm that each one affects the output.
  5. Enforce the three-reference limit in your client.
  6. Set a timeout of at least 60 seconds for 1k low requests and 120–180 seconds for medium or 2k.
  7. 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?

Use grok-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.
Lighthouse on a rocky coast at sunrise with sunlight reflecting on the sea, generated by Grok Imagine Image 2.0 at 1K low

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

Lighthouse on a rocky coast at sunrise with detailed clouds and waves, generated by Grok Imagine Image 2.0 at 2K medium

2K, medium, 16:9: 71 s, $0.055

A request that returns a non-200 error and no image isn’t billed per image. A client timeout isn’t the same as a failure, though: the server may have finished and charged for the image, so check the call record before you resend. Call records are the final billing source.

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’s images.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 without aspect_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 the image, 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. Use b64_json when the image must arrive inside the API response.