> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifically.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok Imagine Image

> Generate and edit images with xAI Grok Imagine

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

| Parameter         | Type      | Required | Default | Description                                   |
| ----------------- | --------- | -------- | ------- | --------------------------------------------- |
| `prompt`          | string    | Yes      | —       | Text description or edit instruction          |
| `aspect_ratio`    | string    | No       | `"1:1"` | `"1:1"`, `"2:3"`, `"3:2"`, `"9:16"`, `"16:9"` |
| `image_urls`      | string\[] | No       | `null`  | 1–5 reference image URLs (triggers edit mode) |
| `enable_pro`      | boolean   | No       | `false` | Enable pro mode for higher quality results    |
| `upsample_prompt` | boolean   | No       | `false` | Let AI enhance your prompt for better results |
| `enable_nsfw`     | boolean   | No       | `false` | Enable 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

```bash theme={null}
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

```bash theme={null}
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"
      ]
    }
  }'
```

Image editing typically returns a single `image_url`; text-to-image returns `image_urls` (array).

## Response (Text to Image)

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

## Response (Image Editing)

```json theme={null}
{
  "code": 200,
  "success": true,
  "data": {
    "task_id": "abc123def456",
    "status": "completed",
    "output": {
      "image_url": "https://files.unifically.com/image/92116e95-8dd4-4cbb-b53f-ee643e1045d8.jpg"
    }
  }
}
```
