Rivya AI Docs

Grok Imagine API Integration

Use Grok Imagine through Rivya Public API v1 with model id grok-imagine, supported inputs, parameters, Files API rules, credits, and response examples.

Available via APIText or URL ready; reference modes use Files APIImage
API model id

grok-imagine

Inputs

text, file

Files API

Required for reference modes

Base credits

4

Capability

Image

Billing

FIXED

Prompt limit

5000 characters

Request contract

Send the model id at the top level. Model-specific controls belong in params.

KeyTypeRequiredDefaultDescription
modelstringYesgrok-imagineUse the grok-imagine API model id.
promptstringYes-Maximum 5000 characters for this model.
paramsobjectNo-Model-specific parameter object. Use the rows below for allowed keys.
client_request_idstringNo-Optional client-side id for tracing requests in your system.

Model parameters

KeyTypeRequiredDefaultRangeOptionsDescription
aspect_ratioselectNo1:1-1:1, 2:3, 3:2, 16:9, 9:16Aspect ratio
enable_proselectNofalse-false, trueThis is the Grok Imagine quality toggle for text-to-image only. Standard is cheaper, while Quality leans toward more detail; the current image-edit path does not use it.

Upload policy

Upload reference files first, then place the returned URL and duration token inside params.referenceMediaItems.

Reference rule

Reference image: Upload up to 1 image file for image projects.

Max files

1

Accepted file kinds

image

Duration token

Video and audio references should carry durationToken from /api/v1/files when duration verification is required.

kindMax sizeMIME types
image10 MBimage/jpeg, image/png, image/webp

Minimal request

{
  "model": "grok-imagine",
  "prompt": "A clean editorial product image on a soft studio background",
  "params": {
    "aspect_ratio": "1:1",
    "enable_pro": "false"
  }
}

Reference-file request

{
  "model": "grok-imagine",
  "prompt": "A clean editorial product image on a soft studio background",
  "params": {
    "aspect_ratio": "1:1",
    "enable_pro": "false",
    "referenceMediaItems": [
      {
        "url": "https://cdn.example.com/reference-image.png",
        "kind": "image",
        "name": "reference-image.png",
        "mimeType": "image/png"
      }
    ]
  }
}

Create response

The create endpoint returns a public task id. Poll the status endpoint until the task succeeds or fails.

{
  "id": "task_grok_imagine_example",
  "status": "queued",
  "model": "grok-imagine",
  "reserved_credits": 4,
  "final_credits": 0,
  "created_at": "2026-05-11T00:00:00.000Z",
  "updated_at": "2026-05-11T00:00:00.000Z",
  "result": null,
  "error": null
}

Common errors

validation_failed, insufficient_credits, idempotency_conflict, rate_limited, not_found

Some modes require Files API reference uploads.