Grok Imagine Image 2.0 API

1K–2K image & 3-ref editing · Up to 10/call

POST /v1/images/generations · https://api.callmodels.dev/v1/images/generations
Try in Playground

Pricing & specification tiers

Fixed per-image pricing (3.75–7.5 Credits × n delivered images). Each reference image in image_urls (1–3) adds +0.9375 Credits once per request (not multiplied by n).

SpecificationPrice (USD)Credits ($1 = 100)Per $10 Est.
1K · low quality · Per output image$0.03753.750000 Credits~266 images
1K · medium quality (default) · Per output image$0.05635.625000 Credits~177 images
2K · low quality · Per output image$0.05635.625000 Credits~177 images
2K · medium quality · Per output image$0.07507.500000 Credits~133 images
Reference image surcharge (each image in image_urls, 1–3, once per request)+$0.00938+0.937500 Credits / refPer ref (once/call)

Request parameters

Local reference assets: upload via POST /v1/files/uploads (0 Credits) for a 24h signed URL.
ParameterType & DefaultConstraints
Authorization
RequiredHeader
string
Bearer sk-... server-side API key from your account.
Idempotency-Key
OptionalHeader
stringDefault: recommended
1 to 255 ASCII chars. Prevents duplicate submissions and charges for 24h.
model
Required
"grok-imagine-image-2.0"
Stable public model ID for xAI Grok Imagine Image 2.0.
prompt
Required
string
1 to 5,000 UTF-8 characters describing the scene or edit.
resolution
Optional
"1K" | "2K"Default: "1K"
Output resolution tier.
quality
Optional
"low" | "medium"Default: "medium"
Rendering quality tier combined with resolution.
size
Optional
"auto" | 13 aspect ratiosDefault: "auto"
Supports "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", and "9:20".
n
Optional
integer (1..10)Default: 1
Number of images to generate in one call; settles strictly on delivered count.
image_urls
Optional
string[] (1..3)Default: omitted
Optional 1–3 HTTPS reference images (+0.9375 Credits per reference image, once per request).

Code examples

# Set CALLMODELS_OPERATION_ID once per job and keep it for retries.
: "${CALLMODELS_OPERATION_ID:?Set a stable job ID}"
curl --silent --show-error --fail-with-body --max-time 15 "https://api.callmodels.dev/v1/images/generations" \
  -H "Authorization: Bearer $CALLMODELS_API_KEY" \
  -H "Idempotency-Key: $CALLMODELS_OPERATION_ID" \
  -H "Content-Type: application/json" \
  --data-binary '{
  "model": "grok-imagine-image-2.0",
  "prompt": "Brushed silver grand tourer coupe parked on a misty coastal cliff road at dawn",
  "size": "16:9",
  "resolution": "1K",
  "quality": "medium"
}'

# Set TASK_ID to the id from the response, then poll until terminal.
if [ -n "${TASK_ID:-}" ]; then
  curl --silent --show-error --fail-with-body --max-time 15 "https://api.callmodels.dev/v1/tasks/$TASK_ID" \
    -H "Authorization: Bearer $CALLMODELS_API_KEY"
fi

Task responses

On completed, read results[0].url (30-day signed link, no auth header) and usage.cost_credits.

HTTP/1.1 202 Accepted
X-Request-Id: req_example
Cache-Control: no-store

{
  "id": "task_01e561ba-859e-47fe-be79-60bc6f1d6499",
  "model": "grok-imagine-image-2.0",
  "object": "image.generation.task",
  "created_at": "2026-11-21T00:00:00.000Z",
  "status": "pending"
}

Error codes

HTTP / Error CodeCause & HandlingBilling
400 invalid_parameter400 model_not_found
Use the model ID and parameters documented for the endpoint. Correct the JSON before sending again.0 Credits for this rejection
401 invalid_api_keyCheck the server-side Bearer key, expiration and revocation status.0 Credits for this rejection
402 insufficient_balance402 key_quota_exceeded
Check available account credits and the key’s total and daily limits with GET /v1/credits.0 Credits for this rejection
403 model_access_denied403 account_disabled
Check the model allowlist and account status.0 Credits for this rejection
404 not_foundCheck the task ID or original Idempotency-Key and the account that submitted it.0 Credits for this rejection
409 idempotency_key_conflictUse the original JSON for this job. Assign a fresh key only to a new job.0 Credits for this rejection
413 body_too_large415 unsupported_media_type
Send application/json with a request body no larger than 128 KiB.0 Credits for this rejection
500 internal_error503 service_unavailable503 model_unavailable
On a timeout or transient error, look up the original job and retry only with its original key and body.Check the task record
Task: delivery_failedTask: submission_unknownTask: submission_rejectedTask: upstream_failedTask: timeout
The task ended. Its hold was released. Review error.code before creating a separate generation job.0 Credits charged