# xAI Grok Imagine Image API

> Grok Imagine Image by xAI generates images from a prompt or edits up to 5 input images, at $0.02 per image. 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
API reference: https://www.sandbase.ai/models/x-ai/grok-imagine-image#api

## Facts

- Provider: xAI
- Type: Image model
- Model ID: `x-ai/grok-imagine-image`
- Price: From $0.02 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",
  "n": 1,
  "prompt": "A red fox standing in fresh snow at sunrise, soft golden light, shallow depth of field",
  "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 through SandBase?

Create a SandBase API key, then send requests with the model ID "x-ai/grok-imagine-image" 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 and the other models in the catalog; you do not need to sign up with xAI separately.

## README

### Grok Imagine Image

Grok Imagine Image is xAI's previous image model, at $0.02 per image. It generates images from a prompt, or edits and combines up to 5 input images. For better quality and 1.5K output, use [Grok Imagine Image 2.0](/models/x-ai/grok-imagine-image-2.0).

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

#### Inputs

| 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. Leave empty to generate. |
| `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` / `2k` | `1k` | Output size; the price is the same. |

#### 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` | `grok-imagine-image` |

```bash
curl https://api.sandbase.ai/grok/v1/images/edits \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-image",
    "prompt": "Turn this photo into a watercolor painting",
    "image": {"url": "https://example.com/photo.jpg"},
    "response_format": "url"
  }'
```

`quality` and `resolution: 1.5k` are only available on Grok Imagine Image 2.0 and return 400 here, as they do at xAI.

#### Billing

$0.02 per image. Editing adds $0.002 per input image. Failed runs are not billed.

| Request | Price |
|---|---|
| Generate 1 image | $0.02 |
| Generate 4 images | $0.08 |
| Edit 1 input image | $0.022 |

#### One mode at a time

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

#### Learn more

- [xAI image generation guide](https://docs.x.ai/docs/guides/image-generations): the official request and response reference.
