Grok Imagine Image
Text-to-Image • xAI • ProxiedxAI'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 License | link ↗ |
| More information | link ↗ |
| Pricing | View pricing in the Cloudflare dashboard ↗ |
Usage
const response = await env.AI.run( 'xai/grok-imagine-image', { prompt: 'A golden retriever puppy playing in autumn leaves' },)console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "xai/grok-imagine-image", "input": { "prompt": "A golden retriever puppy playing in autumn leaves" }}'
{ "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/simple-generation.jpeg" }, "gatewayMetadata": { "keySource": "Unified" }}Examples
Custom Aspect Ratio — Portrait orientation render at 2K resolution
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)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "xai/grok-imagine-image", "input": { "prompt": "A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures", "aspect_ratio": "3:4", "resolution": "2k" }}'
{ "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/custom-aspect-ratio.png" }, "gatewayMetadata": { "keySource": "Unified" }}Cinematic Landscape — Widescreen landscape at 2K resolution
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)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "xai/grok-imagine-image", "input": { "prompt": "A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting", "aspect_ratio": "16:9", "resolution": "2k" }}'
{ "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/cinematic-landscape.png" }, "gatewayMetadata": { "keySource": "Unified" }}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▶image{}
object▶images[]
arraymaxItems: 10▶mask{}
objectn
integermaximum: 10minimum: 1prompt
stringrequiredquality
stringenum: low, medium, highresolution
stringenum: 1k, 2kresponse_format
stringenum: url, b64_jsonuser
stringimage
string