ninteger
Images to generate (1-10). Each image is billed.
Default: 1
Minimum: 1
Maximum: 10
x-ai/grok-imagine-imageGrok 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.
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 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.
Use the form on this page, call x-ai/ through /v1/run, or call the xAI API below with model: grok-imagine-image. Both bill the same as xAI.
| 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 | auto1:116:99:164:33:43:22:32:11:219.5:99:19.520:99:2021:95:2 | auto | Output shape. |
resolution | 1k / 2k | 1k | Output size; the price is the same. |
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 | grok-imagine-image |
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.
$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 |
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",
"n": 1,
"prompt": "A red fox standing in fresh snow at sunrise, soft golden light, shallow depth of field",
"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.
resolutionstringOutput size: 1k or 2k.
Default: "1k"
Possible values: "1k", "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",
"n": 1,
"prompt": "A red fox standing in fresh snow at sunrise, soft golden light, shallow depth of field",
"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.