Seedance 2.5 is live — 30-second cinematic video with native audio & real-person references
rreAPI Docs

grok-imagine

Grok Imagine on reAPI — xAI's Grok Imagine image models at a flat rate per image: standard or high tier, up to 10 images per request, 1k/2k output, single-image editing.

xAI's Grok Imagine image models on reAPI at a flat price per image, in two quality tiers selected with the quality field (standard or high). Up to 10 images per request, fourteen aspect ratios, 1k or 2k output, and single-image editing on the same endpoint. Async-first: submit returns a task_id; poll until ready. See current pricing on the model page.

Quick example

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine",
    "prompt": "A product photo of a matte black wireless speaker on a concrete plinth, soft window light, shallow depth of field",
    "quality": "standard",
    "n": 4,
    "aspect_ratio": "1:1"
  }'
import requests

resp = requests.post(
    "https://reapi.ai/api/v1/images/generations",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "model": "grok-imagine",
        "prompt": "A product photo of a matte black wireless speaker on a concrete plinth, soft window light, shallow depth of field",
        "quality": "standard",
        "n": 4,
        "aspect_ratio": "1:1",
    },
    timeout=30,
)
print(resp.json())
const r = await fetch("https://reapi.ai/api/v1/images/generations", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "grok-imagine",
    prompt:
      "A product photo of a matte black wireless speaker on a concrete plinth, soft window light, shallow depth of field",
    quality: "standard",
    n: 4,
    aspect_ratio: "1:1",
  }),
});
console.log(await r.json());
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    body, _ := json.Marshal(map[string]any{
        "model":        "grok-imagine",
        "prompt":       "A product photo of a matte black wireless speaker on a concrete plinth, soft window light, shallow depth of field",
        "quality":      "standard",
        "n":            4,
        "aspect_ratio": "1:1",
    })
    req, _ := http.NewRequest("POST", "https://reapi.ai/api/v1/images/generations", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    out, _ := io.ReadAll(resp.Body)
    fmt.Println(string(out))
}

The response carries a task_id. Poll GET /api/v1/tasks/{task_id} until status is completed, then read result.images[].url.

Endpoint

POST https://reapi.ai/api/v1/images/generations

Headers: Authorization: Bearer YOUR_API_KEY, Content-Type: application/json. Accepts and returns JSON.

Request body

FieldTypeRequiredDefaultDescription
modelstringyesMust be grok-imagine.
promptstringyesImage description, rendered as written. Up to 10000 characters.
qualitystringnostandardQuality tier: standard or high. Selects which Grok Imagine model serves the request. The only billing dimension.
nintegerno1Images to return, 110. Each delivered image is billed.
aspect_ratiostringnoautoOutput framing — 14 values, listed below. Does not change the rate.
resolutionstringno1kPixel tier: 1k or 2k. Does not change the rate on either tier.
image_urlsstring[]noOne public http(s) image URL. Present ⇒ image editing (see below), billed at the same flat rate as a generation.

quality tiers

ValueWhat it is
standardThe volume tier — the lowest flat rate per image on the platform. Default.
highSpends more on each image for finer detail. Same request shape, same ratios, same batch size.

Both tiers are Grok Imagine models from xAI. Only quality changes the price; everything else is free to vary. The pricing table on the model page lists the current rate for each tier.

aspect_ratio values

auto, 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1.

auto (the default) lets the model pick the framing that suits the prompt. Values outside this list return 400 INVALID_REQUEST.

Output pixels follow the ratio and the resolution tier — a 1:1 request at 1k returns 1024×1024, a 16:9 request at 2k returns 2816×1584. Trust the returned image rather than assuming a fixed size from the ratio alone.

Image editing

Supplying image_urls with one public image URL switches the request to editing on the selected tier. Describe the change in prompt.

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine",
    "prompt": "Render this image as a pencil sketch with detailed shading",
    "quality": "high",
    "image_urls": ["https://example.com/photo.jpg"],
    "aspect_ratio": "1:1"
  }'

Reference images must be public http(s) URLs — base64 and data: URIs are rejected platform-wide. This surface takes exactly one reference image; multi-image compositing is available on grok-imagine-image-2-0.

Response

Submission returns the standard async envelope:

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
    }
  ]
}

Polled completion (GET /api/v1/tasks/{task_id}):

{
  "code": 200,
  "data": {
    "status": "completed",
    "result": {
      "images": [
        { "url": "https://cdn.reapi.ai/..." },
        { "url": "https://cdn.reapi.ai/..." }
      ]
    }
  }
}

result.images carries one entry per delivered image, so a request with n: 4 returns four entries. Image URLs are valid for 24 hours from completion — re-host the asset to your own storage if you need durable access.

Pricing

Grok Imagine bills a flat rate per delivered image on each tier, multiplied by n:

  • quality selects the tier and is the only dimension that moves the per-image rate.
  • aspect_ratio, resolution and n do not change the per-image rate — a 2k banner costs the same as a 1k square on the same tier.
  • Editing (one reference image) bills the same flat per-image rate as a generation.
credits = ceil(per_image_usd × n × 1000)

1 credit = $0.001. The rounding happens once on the aggregate, not per image. See the model page for the live rate of each tier.

Failed generations are refunded automatically — the reserved credits return to your balance when a task ends in failure.

Errors

grok-imagine shares the platform-wide error envelope.

  • prompt missing, empty, or whitespace-only → 400 INVALID_REQUEST.
  • prompt longer than 10000 characters → 400 INVALID_REQUEST.
  • quality set to anything other than standard / high400 INVALID_REQUEST.
  • n outside 110400 INVALID_REQUEST.
  • aspect_ratio outside its 14 values → 400 INVALID_REQUEST.
  • resolution set to anything other than 1k / 2k400 INVALID_REQUEST.
  • More than one entry in image_urls, or a non-http(s) URL → 400 INVALID_REQUEST.
  • Upstream rejection of the content → 80006 CONTENT_POLICY_VIOLATION; the task fails and is refunded.

Tips

  • Use standard with n up to 10 to explore, then re-run the winning prompt on high for the final asset — the request shape is identical.
  • Ask for the shape you will ship: generating 16:9 directly beats cropping a square, and on Grok Imagine it costs the same.
  • For edits, describe the change rather than the whole scene — the reference image already carries the composition.

Table of Contents