{ "model_id": "xai/grok-imagine-image", "provider_id": "xai", "name": "Grok Imagine Image", "description": "xAI's Grok Imagine image model. Generates and edits images from text and reference-image inputs with configurable aspect ratio and resolution.", "task": "Text-to-Image", "tags": [ "Image Generation", "Image Editing", "Multimodal" ], "context_length": null, "max_output_tokens": null, "schema_version": "1.0.0", "pricing": { "Per image": 0.02, "Per input image": 0.002 }, "examples": [ { "name": "Simple Generation", "description": "Basic text-to-image with just a prompt", "input": { "prompt": "A golden retriever puppy playing in autumn leaves" }, "output": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/simple-generation.jpeg" }, "raw_response": { "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/simple-generation.jpeg" }, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image',\n { prompt: 'A golden retriever puppy playing in autumn leaves' },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"xai/grok-imagine-image\",\n \"input\": {\n \"prompt\": \"A golden retriever puppy playing in autumn leaves\"\n }\n}'" } ] }, { "name": "Custom Aspect Ratio", "description": "Portrait orientation render at 2K resolution", "input": { "prompt": "A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures", "aspect_ratio": "3:4", "resolution": "2k" }, "output": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/custom-aspect-ratio.png" }, "raw_response": { "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/custom-aspect-ratio.png" }, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image',\n {\n prompt:\n 'A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures',\n aspect_ratio: '3:4',\n resolution: '2k',\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"xai/grok-imagine-image\",\n \"input\": {\n \"prompt\": \"A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures\",\n \"aspect_ratio\": \"3:4\",\n \"resolution\": \"2k\"\n }\n}'" } ] }, { "name": "Cinematic Landscape", "description": "Widescreen landscape at 2K resolution", "input": { "prompt": "A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting", "aspect_ratio": "16:9", "resolution": "2k" }, "output": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/cinematic-landscape.png" }, "raw_response": { "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/cinematic-landscape.png" }, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image',\n {\n prompt:\n 'A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting',\n aspect_ratio: '16:9',\n resolution: '2k',\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"xai/grok-imagine-image\",\n \"input\": {\n \"prompt\": \"A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting\",\n \"aspect_ratio\": \"16:9\",\n \"resolution\": \"2k\"\n }\n}'" } ] } ], "default_example": null, "code_snippets": [], "supports_async": false, "zdr": true, "zdr_comment": null, "external_info": "https://docs.x.ai/developers/models/grok-imagine-image", "terms": "https://x.ai/legal/terms-of-service", "cover_image_url": "https://pub-26f1392c1b674324be6786695bd72257.r2.dev/xai/grok-imagine-image.png", "metadata": { "Aspect Ratios": "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", "Resolutions": "1k, 2k", "Response Formats": "url, b64_json", "Text Rendering": "Yes" }, "request_formats": null, "providers": null, "provider_details": [ { "id": "xai", "pricing": { "output_image_count": 0.02, "input_image_count": 0.002 } } ], "banner": null, "created_at": "2026-05-22 17:54:03", "schema": { "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "prompt": { "type": "string" }, "n": { "type": "integer", "minimum": 1, "maximum": 10 }, "aspect_ratio": { "type": "string", "enum": [ "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" ] }, "quality": { "type": "string", "enum": [ "low", "medium", "high" ] }, "resolution": { "type": "string", "enum": [ "1k", "2k" ] }, "response_format": { "type": "string", "enum": [ "url", "b64_json" ] }, "user": { "type": "string" }, "image": { "type": "object", "properties": { "url": { "type": "string" }, "type": { "type": "string" } }, "required": [ "url" ], "additionalProperties": false }, "images": { "maxItems": 10, "type": "array", "items": { "type": "object", "properties": { "url": { "type": "string" }, "type": { "type": "string" } }, "required": [ "url" ], "additionalProperties": false } }, "mask": { "type": "object", "properties": { "url": { "type": "string" } }, "required": [ "url" ], "additionalProperties": false } }, "required": [ "prompt" ], "additionalProperties": false }, "output": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "image": { "type": "string" } }, "required": [ "image" ], "additionalProperties": false } } }