Generate images using xAI's Grok Imagine model. Sibling to Grok Imagine Video, sharing the same underlying Grok Imagine architecture for fast text-to-image generation.
Test this model instantly in the Console Playground โ no code required
Copy usage instructions for Claude, ChatGPT, or other AI
curl -X POST "https://api.core.today/v1/predictions" \
-H "Content-Type: application/json" \
-H "X-API-Key: cdt_your_api_key" \
-d '{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "A futuristic city skyline at sunset, flying vehicles, neon reflections on glass towers",
"aspect_ratio": "16:9"
}
}'| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | - | Text prompt for image generation or editing |
image | string | No | - | Input image for editing. When provided, the model edits this image based on the prompt. Supports jpg, jpeg, png, webp. |
aspect_ratio | string | No | 1:1 | Aspect ratio of the generated image. Ignored when editing an image. 1:116:99:164:33:43:22:32:11:219.5:99:19.520:99:20auto |
There are 3 ways to provide files for the image parameter:
Attach files directly to POST /v1/predictions/upload. No separate upload step needed.
curl -X POST "https://api.core.today/v1/predictions/upload" \
-H "X-API-Key: cdt_your_api_key" \
-F "model=xai/grok-imagine-image" \
-F 'input={"prompt":"your prompt here"}' \
-F "file:image=@your_file.png"Pass a publicly accessible URL directly. You can also use file_url from the Storage API.
{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "your prompt here",
"image": "https://example.com/image.jpg"
}
}Common parameters used when calling POST /v1/predictions.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | - | Model identifier |
input | object | Yes | - | Object containing the model-specific parameters from the table above |
output_folder | string | No | - | Folder path for output files (max 256 chars, '..' not allowed) |
webhook_url | string | No | - | Webhook URL to call on completion |
is_public | boolean | No | false | If true, output files are also available via permanent public URLs |
Generates a new image from a text prompt at a 16:9 aspect ratio.
curl -X POST "https://api.core.today/v1/predictions" \
-H "Content-Type: application/json" \
-H "X-API-Key: cdt_your_api_key" \
-d '{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "A futuristic city skyline at sunset, flying vehicles, neon reflections on glass towers",
"aspect_ratio": "16:9"
}
}'Edits an uploaded image based on the prompt; aspect_ratio is ignored.
curl -X POST "https://api.core.today/v1/predictions" \
-H "Content-Type: application/json" \
-H "X-API-Key: cdt_your_api_key" \
-d '{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "Change the background to a snowy mountain landscape",
"image": "https://example.com/input-photo.jpg"
}
}'POST /v1/predictions