Skip to content
xAI logo

Grok Imagine Image

Text-to-ImagexAIProxied

xAI's Grok Imagine image model. Generates and edits images from text and reference-image inputs with configurable aspect ratio and resolution.

Model Info
Terms and Licenselink
More informationlink
PricingView pricing in the Cloudflare dashboard

Usage

TypeScript
const response = await env.AI.run(
'xai/grok-imagine-image',
{ prompt: 'A golden retriever puppy playing in autumn leaves' },
)
console.log(response)
Simple Generation

Examples

Custom Aspect Ratio — Portrait orientation render at 2K resolution
TypeScript
const response = await env.AI.run(
'xai/grok-imagine-image',
{
prompt:
'A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures',
aspect_ratio: '3:4',
resolution: '2k',
},
)
console.log(response)
Custom Aspect Ratio
Cinematic Landscape — Widescreen landscape at 2K resolution
TypeScript
const response = await env.AI.run(
'xai/grok-imagine-image',
{
prompt:
'A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting',
aspect_ratio: '16:9',
resolution: '2k',
},
)
console.log(response)
Cinematic Landscape

Parameters

aspect_ratio
stringenum: 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1, auto
n
integermaximum: 10minimum: 1
prompt
stringrequired
quality
stringenum: low, medium, high
resolution
stringenum: 1k, 2k
response_format
stringenum: url, b64_json
user
string

API Schemas (Raw)

Input
Output