Generate and edit images using xAI’s Grok Imagine model. Supports text-to-image generation and reference-based image editing.

Model

xai/grok-imagine-image

Parameters

ParameterTypeRequiredDefaultDescription
promptstringYesText description or edit instruction
aspect_ratiostringNo"1:1""1:1", "2:3", "3:2", "9:16", "16:9"
image_urlsstring[]Nonull1–5 reference image URLs (triggers edit mode)
enable_probooleanNofalseEnable pro mode for higher quality results
upsample_promptbooleanNofalseLet AI enhance your prompt for better results
enable_nsfwbooleanNofalseEnable NSFW content generation
When image_urls is provided, the model runs in edit mode — it merges or edits the reference images based on your prompt. Otherwise it generates a new image from the prompt.

Example Request

Text to Image

curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "xai/grok-imagine-image",
    "input": {
      "prompt": "A robot dancing in a field of sunflowers",
      "aspect_ratio": "16:9"
    }
  }'

Image Editing

curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "xai/grok-imagine-image",
    "input": {
      "prompt": "Merge these images into one scene",
      "image_urls": [
        "https://example.com/img1.jpg",
        "https://example.com/img2.jpg"
      ]
    }
  }'
Text-to-image returns 6 images as image_urls. Image editing returns a single image_url.

Response (Text to Image)

{
  "code": 200,
  "success": true,
  "data": {
    "task_id": "abc123def456",
    "status": "completed",
    "output": {
      "image_urls": [
        "https://files.storagecdn.online/image/92116e95-8dd4-4cbb-b53f-ee643e1045d8.jpg",
        "https://files.storagecdn.online/image/42eaa39a-a305-4d5d-a542-a6579dc5514d.jpg",
        "https://files.storagecdn.online/image/974167b1-4a7a-4258-ab01-dd46064ae036.jpg",
        "https://files.storagecdn.online/image/aa7765bd-ce24-46a6-8be9-cc9e281f7e87.jpg",
        "https://files.storagecdn.online/image/5c3a7e12-1f8b-4d9a-bc2e-7f6d4e3a1b09.jpg",
        "https://files.storagecdn.online/image/d8e2f1a4-6b3c-4a7e-9d5f-2c8b1e4a7f03.jpg"
      ]
    }
  }
}

Response (Image Editing)

{
  "code": 200,
  "success": true,
  "data": {
    "task_id": "abc123def456",
    "status": "completed",
    "output": {
      "image_url": "https://files.storagecdn.online/image/92116e95-8dd4-4cbb-b53f-ee643e1045d8.jpg"
    }
  }
}