Skip to content

Grok image generation

Routes to xAI's Grok image API. Two operations — createImage and editImage — and a wide aspect-ratio menu (including extreme-wide and extreme-tall variants beyond what Google or OpenAI expose).

Prerequisites

Text-to-image (createImage)

http
POST https://orchestration.civitai.com/v2/consumer/workflows?wait=60
Authorization: Bearer <your-token>
Content-Type: application/json

{
  "steps": [{
    "$type": "imageGen",
    "input": {
      "engine": "grok",
      "operation": "createImage",
      "prompt": "A photorealistic portrait of a woman with flowers in her hair, golden hour lighting",
      "aspectRatio": "1:1",
      "quantity": 1
    }
  }]
}
POST/v2/consumer/workflows
Set your Civitai API token via the Token button in the navbar to enable Try It.
Request body — edit to customize (e.g. swap the image URL or prompt)
Valid JSON

Parameters

FieldRequiredDefaultNotes
operationcreateImage or editImage.
promptNatural-language.
aspectRatio1:1See the ratio table below.
quantity114.

Aspect ratios

Grok exposes a wider aspect-ratio menu than other commercial engines:

CategoryRatios
Ultra-wide2:1, 20:9, 19.5:9, 16:9
Landscape4:3, 3:2
Square1:1
Portrait2:3, 3:4
Vertical9:16, 9:19.5, 9:20, 1:2

Useful when you need phone-native vertical ratios (9:19.5 / 9:20 match modern flagship screens) or cinema-wide output (2:1, 20:9):

json
{
  "steps": [{
    "$type": "imageGen",
    "input": {
      "engine": "grok",
      "operation": "createImage",
      "prompt": "A sweeping cinematic view of a futuristic city skyline at dusk",
      "aspectRatio": "20:9",
      "quantity": 1
    }
  }]
}
POST/v2/consumer/workflows
Set your Civitai API token via the Token button in the navbar to enable Try It.
Request body — edit to customize (e.g. swap the image URL or prompt)
Valid JSON

21:9 isn't in the enum

Grok's list jumps from 20:9 to 16:921:9 (the common cinema label) isn't accepted. Use 20:9 as the closest cinematic-wide option.

Image editing (editImage)

Pass 1–3 reference images in images[]:

json
{
  "steps": [{
    "$type": "imageGen",
    "input": {
      "engine": "grok",
      "operation": "editImage",
      "prompt": "Make it a winter scene with snow falling",
      "images": [
        "https://image.civitai.com/.../source.jpeg"
      ]
    }
  }]
}
POST/v2/consumer/workflows
Set your Civitai API token via the Token button in the navbar to enable Try It.
Request body — edit to customize (e.g. swap the image URL or prompt)
Valid JSON

Edit operations don't take an aspectRatio — the output resolution follows the source(s).

Reading the result

Standard imageGen output — an images[] array, one per quantity:

json
{
  "status": "succeeded",
  "steps": [{
    "name": "0",
    "$type": "imageGen",
    "status": "succeeded",
    "output": {
      "images": [
        { "id": "blob_...", "url": "https://.../signed.png" }
      ]
    }
  }]
}

Blob URLs are signed and expire — refetch the workflow or call GetBlob for a fresh URL.

Runtime

xAI's API queue is the dominant factor. Typical wall time 10–30 s per image. wait=60 is comfortable for quantity ≤ 2; higher batches or busy periods warrant wait=0 + polling.

Cost

Billed in Buzz on the workflow's transactions. Use whatif=true for an exact preview; see Payments (Buzz) for currency selection.

Flat per-image pricing by operation:

total = base × quantity
OperationBase (per image)
createImage~26
editImage~29

Examples:

  • createImage, quantity: 1~26 Buzz
  • createImage, quantity: 4 → ~104 Buzz
  • editImage with 1 reference, quantity: 1~29 Buzz

Aspect ratio and reference count don't affect Grok's Buzz price — the provider charges flat per-image.

Troubleshooting

SymptomLikely causeFix
400 with "aspectRatio must be one of"Ratio outside the accepted enum (e.g. 21:9)Pick a close equivalent from the table above — 20:9 is the closest cinematic wide.
400 with "images minItems" on editEmpty images[] on editImageInclude 1–3 source images.
400 with "images maxItems"More than 3 source imagesTrim to 3.
400 with "quantity must be ≤ 4"Requested more than 4 in one callSplit into multiple submissions or use a different engine with a higher cap (Flux / OpenAI gpt-image-1 / Seedream go up to 10–12).
Request timed out (wait expired)Large quantity or busy xAI queueResubmit with wait=0 and poll.
Step failed, reason = "blocked"xAI content filterDon't retry the same input — see Errors & retries → Step-level failures.

Civitai Developer Documentation