# xAI Grok Imagine Image 2.0 API

> 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.

Source: https://www.sandbase.ai/models/x-ai/grok-imagine-image-2.0
API reference: https://www.sandbase.ai/models/x-ai/grok-imagine-image-2.0#api

## Facts

- Provider: xAI
- Type: Image model
- Model ID: `x-ai/grok-imagine-image-2.0`
- Price: From $0.04 per run
- Capabilities: text to image, image to image
- Billing: pay per use from one SandBase balance; no provider account or subscription needed

## Call it

- Unified Run API: `POST https://api.sandbase.ai/v1/run`

```bash
curl -X POST https://api.sandbase.ai/v1/run \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "x-ai/grok-imagine-image-2.0",
  "n": 1,
  "prompt": "A red fox standing in fresh snow at sunrise, soft golden light, shallow depth of field",
  "quality": "auto",
  "resolution": "1k",
  "aspect_ratio": "auto"
}'
```

The response returns a run id; poll `GET https://api.sandbase.ai/v1/run/{id}` until the status is `completed` or `failed`.

## FAQ

### How do I call xAI Grok Imagine Image 2.0 through SandBase?

Create a SandBase API key, then send requests with the model ID "x-ai/grok-imagine-image-2.0" to Unified Run API (/v1/run) at https://api.sandbase.ai. The request examples on this page show the exact payload.

### Do I need a separate xAI account?

No. One SandBase API key and balance gives you access to xAI Grok Imagine Image 2.0 and the other models in the catalog; you do not need to sign up with xAI separately.

## README

### Grok Imagine Image 2.0

[Grok Imagine Image 2.0](https://docs.x.ai/docs/models/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.

| Field | Type | Default | Notes |
|---|---|---|---|
| `prompt` | string, required | — | What to draw, or what to change. |
| `images` | image list, up to 5 | — | Images to edit or combine. Refer to them in the prompt in order. |
| `n` | integer 1–10 | 1 | Images to generate. |
| `aspect_ratio` | `auto` / `1:1` / `16:9` / `9:16` / `4:3` / `3:4` / `3:2` / `2:3` / `2:1` / `1:2` / `19.5:9` / `9:19.5` / `20:9` / `9:20` / `21:9` / `5:2` | `auto` | Output shape. |
| `resolution` | `1k` / `1.5k` / `2k` | `1k` | Output size. |
| `quality` | `low` / `medium` / `auto` | `auto` | `auto` 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](https://docs.x.ai/docs/guides/image-generations) 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.

| | xAI | SandBase |
|---|---|---|
| Base URL | `https://api.x.ai/v1` | `https://api.sandbase.ai/grok/v1` |
| Generate | `POST /images/generations` | `POST /images/generations` |
| Edit | `POST /images/edits` | `POST /images/edits` |
| Deferred result | `GET /images/{request_id}` | `GET /images/{request_id}` |
| `model` | `grok-imagine-image-2.0` | `grok-imagine-image-2.0` |

```bash
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 image | 1k | 1.5k | 2k |
|---|---|---|---|
| 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

- [Grok Imagine Image 2.0 Text to Image](/models/x-ai/grok-imagine-image/2.0/text-to-image)
- [Grok Imagine Image 2.0 Edit](/models/x-ai/grok-imagine-image/2.0/edit)

#### Learn more

- [xAI image generation guide](https://docs.x.ai/docs/guides/image-generations): the official request and response reference.
- [Grok Imagine Image (previous version)](/models/x-ai/grok-imagine-image): $0.02 per image.
