Skip to main content
POST
Text-to-image · async jobs. Submit POST /v1/images/generations, then poll Get task status.
Model name is fixed grok-imagine-2.0-ext. Not supported: reference images, stream, or response_format values other than url.
Do not put API keys in browser bundles (VITE_* / NEXT_PUBLIC_*, LocalStorage, etc.). Prefer calling your own BFF from the browser; keep the APIMart key on the server.

Capabilities and limits

string
required
Bearer token. Get a key from the API Key page.

Request parameters

string
required
Fixed value: grok-imagine-2.0-ext
string
required
Prompt. Must be non-empty after trim. Trim before submit.
integer
default:"1"
Image count: 112. Explicit 0 errors. Omit for 1.
string
Aspect ratio. Prefer ratio strings (UI should only show ratios):Pixel aliases: 1024x1024 (1:1), 1024x1792 (2:3), 1792x1024 (3:2), 720x1280 (9:16), 1280x720 (16:9).Values outside the whitelist return 400 invalid_size (e.g. 1:2, 2:1, 4:5, auto).
Actual pixels for a given ratio may differ from the alias table (e.g. 1:1 may return 1408×1408). Trust the returned image; do not rewrite size from measured pixels.
string
Quality-mode field. Verified value: quality.
  • Omit (model is quality-mode by default), or
  • Pass resolution: "quality" explicitly
Not a 1K / 2K / 4K pixel tier; framing is controlled by size.
Do not send a public quality field — you get 400 invalid_quality. Use resolution.
string
default:"url"
Only url is allowed. May be omitted. b64_json / base64400 invalid_response_format.
string
Optional public HTTPS base URL. On terminal status the platform POSTs {webhook}/callback. Server-side only — see Webhook.

Unsupported parameters

Build requests with a whitelist; do not forward a generic image-form object from other models.

Request examples

Minimal

Submit response

Prefer X-APIMart-Response-Version: 2026-07-27. Success is HTTP 202; task id is data.id (do not rely on legacy data[0].task_id). Persist:
  • data.id for polling
  • request_id for gateway debugging
  • the Idempotency-Key for safe retries when outcome is unknown
  • original request params for UI / support

Idempotency and safe retries

Image generation is billable — strongly recommend Idempotency-Key (1–191 printable ASCII chars; UUID is easiest; retained ~24 hours). On POST network timeout when you cannot tell if the server accepted the job, do not immediately create a new key — retry with the same key / body / response version.

Poll tasks

Optional language: zh / en / ko / ja (failure message localization only). See Get task status.

Statuses

Poll about every 2 seconds; cap near 10 minutes or 120 attempts. Honor Retry-After on 429. Tasks are kept ~3 days by default — keep the task id if the client times out.

Completed example

Parsing url and image_ids

  1. Use url[] for display; when n>1, walk all entries
  2. Pair by index only if image_ids.length === url.length
  3. Missing image_ids still allows display
  4. Links last 72 hours — download promptly; also trust expires_at

Billing

Base price $0.08 per image (successful deliveries):
  • Pre-submit UI should say “estimate”; final USD is data.cost
  • data.credits_cost is the credits view (currently ~ USD × 10)
  • Pre-charge by requested count; settle on successful count (partial refunds if partial failure)
  • Full failure: cost=0, pre-charge refunded
  • Do not build price keys from resolution; this model is flat per image

Webhook (optional)

  • Provide a base URL; the platform calls {base}/callback
  • Must be public and pass SSRF checks
  • If webhook_secret is set, signature is hex(HMAC-SHA256(secret, raw_body)) over raw bytes
  • Callback body matches task query data (no extra {code,data} wrapper)
  • Still keep low-frequency polling as a fallback

Common errors

Prefer error.message for UI. Do not surface raw auth internals to end users.

Differences from 1.5 (summary)