Skip to main content
As of September 3, 2026, LaoZhang API provides grok-imagine-image-2.0 to eligible API-key groups. Use /v1/images/generations for text-to-image and the OpenAI-compatible multipart/form-data /v1/images/edits endpoint for one to three reference images. The current price is $0.055 per successfully returned image, and batch requests are billed by the number of outputs returned.
This is the complete LaoZhang integration guide for Grok Imagine image models. grok-imagine-image-2.0 is an exact model ID. The legacy grok-imagine-image and grok-imagine-image-quality IDs remain separate models.

Create an API key

Create a token and confirm its balance, visible models, and eligible group

Check current model pricing

Recheck the live price and call records before a large batch

Current integration scope

LaoZhang currently accepts OpenAI-compatible file uploads for editing, not the JSON image objects shown in xAI’s documentation. Four- and five-reference requests currently fail. Limit the client to three references and do not automatically retry the same over-limit request.

Choose among the three models

Test grok-imagine-image-2.0 first for new integrations. Existing workloads do not need to migrate immediately. Compare one image from each relevant model with the same prompt, ratio, and resolution before switching.

Before you call the API

1

Create and protect a token

Create an API key in Token Management. Keep it in a server-side environment variable, never in browser code, a public repository, or logs.
2

Confirm the model and price

Open model pricing, verify that the token can see grok-imagine-image-2.0, and confirm that the current price is still $0.055.
3

Accept one real image first

Start with n=1. Download the output and inspect its pixels, content, and call record before increasing resolution, output count, or concurrency.

Text-to-image quick start

This request creates one 2K, 16:9, Medium image:
A successful response is HTTP 200 with a readable item in data:
The URL is temporary. Download it into your own object storage promptly. Set response_format to b64_json when you need the image bytes in the response.

Python SDK

The OpenAI Python SDK does not expose every Grok image option as a first-class parameter. Put aspect_ratio, resolution, and quality in extra_body.

Aspect ratio, resolution, and quality

LaoZhang verified these fixed grok-imagine-image-2.0 aspect ratios: Omit aspect_ratio to let the model choose. Pass an explicit value when the layout must be predictable.
  • resolution="1k" is faster and fits drafts, thumbnails, and batch candidates;
  • resolution="2k" creates larger files with longer latency for final assets and cropping;
  • quality="low" prioritizes speed;
  • quality="medium" prioritizes detail;
  • do not send quality="high" or resolution="4k".
Successful responses do not expose the quality tier actually served. Production requests should explicitly use low or medium instead of relying on auto for cost, latency, or quality expectations.

Edit one reference image

Editing requires a file upload. Do not put an xAI-style JSON image object in the request body:
After HTTP 200, download the image and inspect the subject, color, text, and composition. Reference editing regenerates the scene; it is not pixel-level mask inpainting.

Edit with two or three references

Repeat image[] for multi-image editing. This three-image request provides the subject, scene, and style separately:
Upload order maps to image 1, image 2, and image 3 in the prompt. LaoZhang verified a three-reference request on api2.laozhang.ai that returned a 1248×832 JPEG on September 3, 2026.
The current limit is three references. Four- and five-image requests return an upstream service error. Count files locally and reject the request before sending it instead of retrying a known input-boundary failure.

Python SDK editing

The OpenAI SDK works for single-image editing. For multiple references, start with the curl form above to verify how your HTTP framework serializes repeated multipart fields.

Parameters

Pricing and billing

grok-imagine-image-2.0 currently costs $0.055 per successfully returned image: LaoZhang currently uses the same public price for 1K/2K and Low/Medium. LaoZhang pricing and xAI list pricing are separate billing contracts. Recheck the console before large batches and use call records as the final billing source.

Error handling

Use jittered exponential backoff for valid requests that hit 429, network errors, or clearly temporary 5xx failures. After a client timeout, check the call record before resubmitting to avoid duplicate generation and billing.

Production acceptance checklist

  1. Generate one 1K Low image with the production token;
  2. download the URL or decode Base64 and inspect the real MIME type and dimensions;
  3. test the exact 2K, Medium, ratio, and n values used in production;
  4. use distinct, non-sensitive references and verify that each subject affects the output;
  5. enforce the three-reference edit limit;
  6. use at least a 60-second timeout for 1K Low and 120–180 seconds for Medium and 2K;
  7. reconcile success rate, latency, output count, and call records before increasing concurrency.

Frequently asked questions

What is the exact new model ID?

Use grok-imagine-image-2.0, including the final .0. The legacy grok-imagine-image and grok-imagine-image-quality IDs remain separate models.

Is pricing per request or per output image?

It is per successfully returned image. A successful n=10 response with ten images costs 0.550,notasingle0.550, not a single 0.055 charge.

How many reference images can I upload?

grok-imagine-image-2.0 currently accepts up to three references through multipart file upload. Four and five references are not supported.

Can I use xAI’s JSON image-editing request format?

Not currently. LaoZhang has verified OpenAI-compatible multipart uploads. JSON image objects return HTTP 400; wait for a future compatibility update if your application requires that contract.

Do 1K, 2K, Low, and Medium have the same LaoZhang price?

Yes, the current public price is $0.055 per successfully returned image. Latency and upstream cost vary by tier, so recheck the console before a large batch.

How should I store generated results?

Download URL responses promptly into your own storage. Use b64_json when the image must travel in the API response. Do not assume temporary URLs remain available indefinitely.