ninteger
Images to generate (1-10). Each image is billed.
Default: 1
Minimum: 1
Maximum: 10
x-ai/grok-imagine-image-2.0Grok 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
PNG, JPEG, WebP, or GIF · 20 MiB maximum each · up to 5
Your output will appear here
Complete the inputs, then click Run.
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/ through /v1/run, or call the xAI API below with model: grok-imagine-image-2.0. Both bill the same as xAI.
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 | auto1:116:99:164:33:43:22:32:11:219.5:99:19.520:99:2021:95:2 | auto | Output shape. |
resolution | 1k1.5k2k | 1k | Output size. |
quality | lowmediumauto | auto | auto lets xAI choose; it bills as low when generating and as medium when editing. |
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.
| 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 |
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.
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 |
Start building
Submit this model through the SandBase Unified Run API.
# The quoted heredoc keeps Unicode and shell metacharacters unchanged.
result=$(curl --fail-with-body --silent \
-X POST "https://api.sandbase.ai/v1/run" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'SANDBASE_JSON'
{
"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"
}
SANDBASE_JSON
)
run_id=$(printf '%s' "$result" | jq -r .id)
for attempt in $(seq 1 120); do
status=$(printf '%s' "$result" | jq -r .status)
case "$status" in completed|failed|timeout) break ;; esac
sleep 2
result=$(curl --fail-with-body --silent \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
"https://api.sandbase.ai/v1/run/$run_id")
done
status=$(printf '%s' "$result" | jq -r .status)
[ "$status" = completed ] || { echo "Generation ended: $status" >&2; exit 1; }
printf '%s\n' "$result"Create a SandBase API key and set it in your server environment. All requests use Bearer authentication.
export SANDBASE_API_KEY="YOUR_API_KEY"Keep the key on your server. Do not expose it in browser code or commit it to a repository.
POST to /v1/run with this model ID and its inputs. The request example above includes submission and polling.
Use the returned run ID to poll until the status is completed, failed or timeout. Read output only after completed.
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"Pass a publicly accessible file URL in the model’s image, video or audio field. Supported formats and limits are shown beside each Playground input.
Use the upload or replace control on supported image fields in the Playground. Video URL fields accept a hosted driving video; they do not imply video-upload support.
nintegerImages to generate (1-10). Each image is billed.
Default: 1
Minimum: 1
Maximum: 10
imagesarrayUp to 5 images to edit or combine (upload or public HTTPS URL). Leave empty to generate from the prompt.
promptstringrequiredDescribe the image, or the change to make to the input images.
qualitystringauto lets xAI choose (billed as low when generating, medium when editing).
Default: "auto"
Possible values: "auto", "low", "medium"
resolutionstringOutput size: 1k, 1.5k or 2k.
Default: "1k"
Possible values: "1k", "1.5k", "2k"
aspect_ratiostringOutput aspect ratio. auto picks one from the prompt or the first input image.
Default: "auto"
Possible values: "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"
{
"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"
}A completed run exposes its result in output. The following is the model’s saved example, not a new generation.
No example output has been published yet. Use Playground → Result → JSON after a completed run to inspect your response.