NezhaGateNezhaGate
grok-imagine-image-quality

Grok Imagine Image Quality · API

POST https://nezhagate.com/v1/images/generations

Image generation (async, job-based) backed by xAI Grok Imagine Image Quality, the higher-quality tier: detail, composition and in-image lettering hold up better than on Standard. Text-to-image needs only a prompt; for an edit put the references in image or images (a URL, a data: URI or base64), or call /v1/images/edits; edits render at the ratio you choose. Submitting returns a job id at once (HTTP 202); poll GET /v1/images/jobs/{id} for the image. Seven aspect ratios and two resolutions, 1K and 2K (send resolution: "2K" or a 2048-class size for 2K, rendered natively; 4K is not offered and is refused at submit). 1K and 2K cost the same; failed requests are not charged.

Try in Playground →

Authentication

Header
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Create an API Key in the console to start.

Request body

ParameterTypeRequiredDescription
model string Yes Model ID, here grok-imagine-image-quality.
prompt string Yes Text prompt describing the image.
size string No Output aspect ratio. Recommended: pass a ratio — 1:1, 3:4, 2:3, 9:16, 4:3, 3:2, 16:9 — and the model renders natively at that ratio with no subject cropping. Pixel sizes (e.g. 1024x1024, 1024x1536, 1536x1024) are also accepted. Default 1:1 (square).
n integer No Number of images, default 1.
image string No Image-to-image: a reference image as a public URL, a data: URI, or raw base64. When present the request runs true identity-preserving image-to-image at the chosen size/ratio — equivalent to calling /v1/images/edits.
images array No Multi-image reference (up to 8; ≤4 recommended for subject consistency): pass an array of strings, or an array of [{"image_url": "..."}] objects; each item a public URL, a data: URI, or base64. Runs multi-reference image-to-image (fusing the subjects and style of several references) - equivalent to multi-image input of /v1/images/edits. For a single reference the image field above also works.
resolution string No Resolution: 1K (default) or 2K, at the same price. A 2048-class pixel size in size also selects 2K. 4K is not offered and is refused.

Request example

cURL
# 1) submit -> 202 {"id":"img_...","status":"queued"}
curl https://nezhagate.com/v1/images/generations -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{"model": "grok-imagine-image-quality", "prompt": "a serene ink-wash poster, lots of negative space", "size": "1024x1536"}'
# 2) poll until status=succeeded
curl https://nezhagate.com/v1/images/jobs/img_3f9a...c2 -H 'Authorization: Bearer YOUR_API_KEY'

Response

200 · JSON
{
  "id": "img_3f9a...c2",
  "object": "image.generation.job",
  "status": "queued",
  "model": "grok-imagine-image-quality"
}

Image-to-Image

Image-to-image: put the reference in `image` (a public URL, a data: URI, or raw base64) to run true identity-preserving i2i — the model regenerates from it at the chosen size/ratio. Equivalent to calling /v1/images/edits.

curl · Image-to-Image
curl https://nezhagate.com/v1/images/generations -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "grok-imagine-image-quality", "prompt": "replace the background with a starry sky", "image": "https://example.com/ref.png", "size": "3:4"}'

Image jobs (submit → poll for the result)

Image rendering usually takes 1–3 minutes, so the image endpoints are job-only: submitting a request returns a job id immediately (HTTP 202); poll for the result with that id — the server keeps rendering across restarts, so the image is never lost. Same for text-to-image and image-to-image. (The old "async": true field is no longer needed; it is accepted but ignored.)

curl · Step 1 · Submit the job (returns a job id right away, HTTP 202)
curl https://nezhagate.com/v1/images/generations -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{"model": "grok-imagine-image-quality", "prompt": "an ink-wash poster with lots of negative space", "size": "3:4"}'
Response Example
{ "id": "img_3f9a...c2", "object": "image.generation.job", "status": "queued", "model": "grok-imagine-image-quality" }
curl · Step 2 · Poll for the result (every 2–3s until status is succeeded)
curl https://nezhagate.com/v1/images/jobs/img_3f9a...c2 -H 'Authorization: Bearer YOUR_API_KEY'
Response Example
{
  "id": "img_3f9a...c2",
  "object": "image.generation.job",
  "status": "succeeded",
  "model": "grok-imagine-image-quality",
  "data": [{ "url": "https://img.nezhagate.com/i/9f86d081a8....png" }]
}

🕑 data[0].url is a link on our image host that is kept for 60 days and then deleted automatically; to keep using it, download it and store it on your own storage or CDN.

status is one of queued / processing / succeeded / failed. On success the response carries data[].url. A job can only be polled by the account that created it. Image endpoints are always async — submit returns a job id; "async": true is accepted only for backward compatibility and ignored.

Error codes

Every error body carries error.message / error.type / error.code / error.param - branch on code; the full list is in the integration guide.

HTTPcodeDescription
401invalid_api_keyAPI Key missing or invalid
402insufficient_quotaInsufficient balance or Key over quota
400invalid_requestUnsupported model or parameter
429rate_limit_exceededUpstream rate limit
502upstream_errorAll upstream routes failed