{ "model_id": "xai/grok-imagine-image-2.0", "provider_id": "xai", "name": "Grok Imagine Image 2.0", "description": "xAI's Grok Imagine Image 2.0 is a precise image generation and editing model for creative work, with strong instruction following, typography, layout, and reference-image preservation.", "task": "Text-to-Image", "tags": [ "Image Generation", "Image Editing", "Multimodal", "Text Rendering", "Typography" ], "context_length": null, "max_output_tokens": null, "schema_version": "1.0.0", "pricing": { "Per image": 0.04, "Per input image": 0.01 }, "examples": [ { "name": "Simple Generation", "description": "Basic text-to-image generation", "input": { "prompt": "A concert poster for a synthwave band, bold retro typography, sharp small print", "response_format": "b64_json" }, "output": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/simple-generation.jpg" }, "raw_response": { "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/simple-generation.jpg" }, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image-2.0',\n { prompt: 'A concert poster for a synthwave band, bold retro typography, sharp small print' },\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-2.0\",\n \"input\": {\n \"prompt\": \"A concert poster for a synthwave band, bold retro typography, sharp small print\"\n }\n}'" } ] }, { "name": "Portrait 2K", "description": "High-resolution image with a controlled aspect ratio", "input": { "aspect_ratio": "3:4", "prompt": "A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures", "quality": "medium", "resolution": "2k", "response_format": "b64_json" }, "output": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/portrait-2k.png" }, "raw_response": { "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/portrait-2k.png" }, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image-2.0',\n {\n aspect_ratio: '3:4',\n prompt:\n 'A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures',\n quality: 'medium',\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-2.0\",\n \"input\": {\n \"aspect_ratio\": \"3:4\",\n \"prompt\": \"A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures\",\n \"quality\": \"medium\",\n \"resolution\": \"2k\"\n }\n}'" } ] }, { "name": "Low Quality Draft", "description": "Fast low-quality draft for iteration", "input": { "aspect_ratio": "1:1", "prompt": "A quiet Japanese garden in morning mist with a stone lantern and koi pond", "quality": "low", "resolution": "1k", "response_format": "b64_json" }, "output": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/low-quality-draft.jpg" }, "raw_response": { "state": "Completed", "result": { "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/low-quality-draft.jpg" }, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image-2.0',\n {\n aspect_ratio: '1:1',\n prompt: 'A quiet Japanese garden in morning mist with a stone lantern and koi pond',\n quality: 'low',\n resolution: '1k',\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-2.0\",\n \"input\": {\n \"aspect_ratio\": \"1:1\",\n \"prompt\": \"A quiet Japanese garden in morning mist with a stone lantern and koi pond\",\n \"quality\": \"low\",\n \"resolution\": \"1k\"\n }\n}'" } ] } ], "default_example": null, "code_snippets": [], "supports_async": false, "zdr": false, "zdr_comment": null, "external_info": "https://docs.x.ai/developers/model-capabilities/images/generation", "terms": "https://x.ai/legal/terms-of-service", "cover_image_url": "https://pub-26f1392c1b674324be6786695bd72257.r2.dev/xai/grok-imagine-image-2.0.png", "metadata": { "Aspect Ratios": "1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 9:19.5, 19.5:9, 9:20, 20:9, 2:1, 1:2, auto", "Max Reference Images": "5", "Quality": "low, medium", "Resolutions": "1k, 2k", "Text Rendering": "Yes" }, "request_formats": null, "providers": null, "provider_details": [ { "id": "xai", "pricing": { "output_image_count": 0.04, "input_image_count": 0.01 } } ], "banner": null, "created_at": "2026-08-14 22:17:39", "schema": { "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "prompt": { "type": "string" }, "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" ] }, "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": 5, "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", "description": "Generated image. Either a base64 data URI (`data:image/png;base64,...`) or an `https://` URL, depending on the upstream `response_format`." } }, "required": [ "image" ], "additionalProperties": false } } }