Sand AISand AI MAGI-2MAGI-2 is now on SandBase: 1080p video with native audioTry it now
Text to ImagexAI

Grok Imagine Image 2.0

API docs
x-ai/grok-imagine-image-2.0

Grok Imagine Image 2.0 by xAI generates images from a prompt or edits up to 5 input images at 1K, 1.5K or 2K. Call it from this page, through /v1/run, or with the xAI Images API at SandBase.

Try the model

Playground

Open playground
Input
Describe the image, or the change to make to the input images.

PNG, JPEG, WebP, or GIF · 20 MiB maximum each · up to 5

Up to 5 images to edit or combine (upload or public HTTPS URL). Leave empty to generate from the prompt.
Output aspect ratio. auto picks one from the prompt or the first input image.
Output size: 1k, 1.5k or 2k.
auto lets xAI choose (billed as low when generating, medium when editing).
Advanced settings
110
Images to generate (1-10). Each image is billed. Range: 1 to 10.

Fill in prompt to run

Per run$0.04
Result
Idle

Your output will appear here

Complete the inputs, then click Run.

Grok Imagine Image 2.0

Grok Imagine Image 2.0 is xAI's current image model. It generates images from a prompt, or edits and combines up to 5 input images, at 1K, 1.5K or 2K.

Use the form on this page, call x-ai/grok-imagine-image-2.0 through /v1/run, or call the xAI API below with model: grok-imagine-image-2.0. Both bill the same as xAI.

Inputs

Leave images empty to generate from the prompt; add images to edit them.

FieldTypeDefaultNotes
promptstring, required—What to draw, or what to change.
imagesimage list, up to 5—Images to edit or combine. Refer to them in the prompt in order.
ninteger 1–101Images to generate.
aspect_ratioauto1:116:99:164:33:43:22:32:11:219.5:99:19.520:99:2021:95:2autoOutput shape.
resolution1k1.5k2k1kOutput size.
qualitylowmediumautoautoauto lets xAI choose; it bills as low when generating and as medium when editing.

xAI API

SandBase implements xAI's Images and Videos API under https://api.sandbase.ai/grok/v1. Requests and responses match xAI's API reference field by field, so the xAI SDK or any OpenAI-style HTTP client works after you change the base URL and use your SandBase API key.

xAISandBase
Base URLhttps://api.x.ai/v1https://api.sandbase.ai/grok/v1
GeneratePOST /images/generationsPOST /images/generations
EditPOST /images/editsPOST /images/edits
Deferred resultGET /images/{request_id}GET /images/{request_id}
modelgrok-imagine-image-2.0grok-imagine-image-2.0
curl https://api.sandbase.ai/grok/v1/images/generations \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-image-2.0",
    "prompt": "A red fox standing in fresh snow at sunrise",
    "aspect_ratio": "16:9",
    "resolution": "2k",
    "quality": "medium",
    "response_format": "url"
  }'

To edit, post to /images/edits with "image": {"url": "https://..."} or "images": [{"url": "..."}, ...]. The response is {"data": [{"url": "...", "mime_type": "image/jpeg"}], "usage": {"cost_in_usd_ticks": ...}}, where cost_in_usd_ticks is the charge in units of 1/10,000,000,000 USD. response_format can be url or b64_json; add "deferred": true to get a request_id and fetch the result later. output and storage_options are not supported.

Billing

Per image: $0.04, plus $0.02 for medium quality, plus $0.01 at 1.5K or $0.02 at 2K. Editing adds $0.01 per input image. Failed runs are not billed.

Request, 1 image1k1.5k2k
Generate, low or auto$0.04$0.05$0.06
Generate, medium$0.06$0.07$0.08
Edit 1 image, low$0.05$0.06$0.07
Edit 1 image, medium or auto$0.07$0.08$0.09

One mode at a time

Learn more