Skip to main content
xAIFastStandard

Grok Imagine Image

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.

47 credits
per image
Text-to-image generation built on the Grok Imagine architecture
Image editing mode โ€” pass an existing image plus a prompt to edit it
14 aspect ratio presets plus an auto option
Shares its underlying architecture with Grok Imagine Video

Run it right now

Test this model instantly in the Console Playground โ€” no code required

Sign in to try

Use with AI Assistant

Copy usage instructions for Claude, ChatGPT, or other AI

Quick Start

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"
  }
}'

Parameters

ParameterTypeRequiredDefaultDescription
promptstringYes-Text prompt for image generation or editing
imagestringNo-Input image for editing. When provided, the model edits this image based on the prompt. Supports jpg, jpeg, png, webp.
aspect_ratiostringNo1:1Aspect 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

How to Provide File Input

There are 3 ways to provide files for the image parameter:

Recommended

Direct Upload (Multipart)

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"

Image URL

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"
  }
}
See the File Upload docs for more upload methods including Presigned URLs.

Common Parameters

Common parameters used when calling POST /v1/predictions.

ParameterTypeRequiredDefaultDescription
modelstringYes-Model identifier
inputobjectYes-Object containing the model-specific parameters from the table above
output_folderstringNo-Folder path for output files (max 256 chars, '..' not allowed)
webhook_urlstringNo-Webhook URL to call on completion
is_publicbooleanNofalseIf true, output files are also available via permanent public URLs

Examples

Text-to-image generation

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"
  }
}'

Edit an existing image

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"
  }
}'

Tips & Best Practices

1Pass an image to switch into edit mode โ€” the model edits that image based on your prompt instead of generating from scratch
2aspect_ratio is ignored when editing an image since the output follows the input image's dimensions
3Use aspect_ratio=auto to let the model choose a sensible ratio for the prompt

Use Cases

Rapidly iterating on image concepts from text prompts
Editing an existing image by passing it in as input alongside a prompt
Generating images across varied aspect ratios for social posts, wide banners, and mobile screens