{ "model_id": "openai/gpt-image-2", "provider_id": "openai", "name": "GPT Image 2", "description": "OpenAI's next-generation image model that creates and edits images from text prompts, with support for multiple quality levels, sizes, and output formats. Note: transparent backgrounds are not supported \u2014 use openai/gpt-image-1.5 for transparent PNGs.", "task": "Text-to-Image", "tags": [ "Image Generation", "Image Editing", "Multimodal" ], "context_length": null, "max_output_tokens": null, "schema_version": "1.0.0", "pricing": { "Input tokens (per 1M)": 5, "Input image tokens (per 1M)": 8, "Cached input tokens (per 1M)": 1.25, "Cached input image tokens (per 1M)": 2, "Output image tokens (per 1M)": 30, "Output tokens (per 1M)": 10 }, "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://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/simple-generation.png" }, "raw_response": { "gatewayMetadata": { "keySource": "BYOK" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/simple-generation.png" }, "state": "Completed" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'openai/gpt-image-2',\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\": \"openai/gpt-image-2\",\n \"input\": {\n \"prompt\": \"A golden retriever puppy playing in autumn leaves\"\n }\n}'" } ] }, { "name": "High Quality", "description": "Generate a high-quality detailed image", "input": { "prompt": "A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures", "quality": "high" }, "output": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/high-quality.png" }, "raw_response": { "gatewayMetadata": { "keySource": "BYOK" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/high-quality.png" }, "state": "Completed" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'openai/gpt-image-2',\n {\n prompt:\n 'A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures',\n quality: 'high',\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\": \"openai/gpt-image-2\",\n \"input\": {\n \"prompt\": \"A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures\",\n \"quality\": \"high\"\n }\n}'" } ] }, { "name": "Custom Size", "description": "Generate a portrait-oriented image", "input": { "prompt": "A towering redwood forest with sunbeams filtering through the canopy, misty atmosphere", "size": "1024x1536" }, "output": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/custom-size.png" }, "raw_response": { "gatewayMetadata": { "keySource": "BYOK" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/custom-size.png" }, "state": "Completed" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'openai/gpt-image-2',\n {\n prompt: 'A towering redwood forest with sunbeams filtering through the canopy, misty atmosphere',\n size: '1024x1536',\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\": \"openai/gpt-image-2\",\n \"input\": {\n \"prompt\": \"A towering redwood forest with sunbeams filtering through the canopy, misty atmosphere\",\n \"size\": \"1024x1536\"\n }\n}'" } ] }, { "name": "WebP Output", "description": "Generate an image in WebP format for smaller file size", "input": { "prompt": "A neon-lit cyberpunk cityscape at night with rain-slicked streets and holographic billboards", "output_format": "webp", "quality": "high" }, "output": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/webp-output.webp" }, "raw_response": { "gatewayMetadata": { "keySource": "BYOK" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/webp-output.webp" }, "state": "Completed" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'openai/gpt-image-2',\n {\n prompt:\n 'A neon-lit cyberpunk cityscape at night with rain-slicked streets and holographic billboards',\n output_format: 'webp',\n quality: 'high',\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\": \"openai/gpt-image-2\",\n \"input\": {\n \"prompt\": \"A neon-lit cyberpunk cityscape at night with rain-slicked streets and holographic billboards\",\n \"output_format\": \"webp\",\n \"quality\": \"high\"\n }\n}'" } ] }, { "name": "Image Edit", "description": "Edit an existing image by providing it in the images array as base64 (a raw string or a data:image/{png|jpeg|webp};base64,... URI). This routes the call to OpenAI's /v1/images/edits endpoint. The example uses a tiny 32x32 smiley-face PNG - real inputs are the full base64 encoding of your source image.", "input": { "prompt": "Transform this cartoon smiley into a photorealistic 3D clay sculpture sitting on a marble pedestal, studio lighting", "images": [ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAnklEQVR42u2XQRLAIAgD8/839i/26qFCACm0ozPe1KwcQsAoXvgcAABxpwFowl4QWITHxW0LCBhxVngF4gKIirMQyBRnIJAtrkE8AuwWnyFEgKzfS1UA+3sWTju3BGAu7gKYIfBW+Q/AAQgBeMCkt1wVsLZjcwUYG2Z9wGLHZitWk1DEisubUYt2XB5IWkSyFqG0RSxvMZi0Gc1+Ox3fm00ZJ5mGVtkAAAAASUVORK5CYII=" ] }, "output": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/image-edit.png" }, "raw_response": { "gatewayMetadata": { "keySource": "BYOK" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/image-edit.png" }, "state": "Completed" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'openai/gpt-image-2',\n {\n prompt:\n 'Transform this cartoon smiley into a photorealistic 3D clay sculpture sitting on a marble pedestal, studio lighting',\n images: [\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAnklEQVR42u2XQRLAIAgD8/839i/26qFCACm0ozPe1KwcQsAoXvgcAABxpwFowl4QWITHxW0LCBhxVngF4gKIirMQyBRnIJAtrkE8AuwWnyFEgKzfS1UA+3sWTju3BGAu7gKYIfBW+Q/AAQgBeMCkt1wVsLZjcwUYG2Z9wGLHZitWk1DEisubUYt2XB5IWkSyFqG0RSxvMZi0Gc1+Ox3fm00ZJ5mGVtkAAAAASUVORK5CYII=',\n ],\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\": \"openai/gpt-image-2\",\n \"input\": {\n \"prompt\": \"Transform this cartoon smiley into a photorealistic 3D clay sculpture sitting on a marble pedestal, studio lighting\",\n \"images\": [\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAnklEQVR42u2XQRLAIAgD8/839i/26qFCACm0ozPe1KwcQsAoXvgcAABxpwFowl4QWITHxW0LCBhxVngF4gKIirMQyBRnIJAtrkE8AuwWnyFEgKzfS1UA+3sWTju3BGAu7gKYIfBW+Q/AAQgBeMCkt1wVsLZjcwUYG2Z9wGLHZitWk1DEisubUYt2XB5IWkSyFqG0RSxvMZi0Gc1+Ox3fm00ZJ5mGVtkAAAAASUVORK5CYII=\"\n ]\n }\n}'" } ] }, { "name": "Multi-Image Edit", "description": "Compose multiple input images by passing up to 16 base64 strings in the images array. The model blends the references; useful for combining subjects, styles, or reference shots. The example pairs a smiley-face PNG with a red ball PNG.", "input": { "prompt": "Combine these into a single photorealistic scene: a ceramic smiley-face mug next to a red rubber ball on a sunlit wooden table", "images": [ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAnklEQVR42u2XQRLAIAgD8/839i/26qFCACm0ozPe1KwcQsAoXvgcAABxpwFowl4QWITHxW0LCBhxVngF4gKIirMQyBRnIJAtrkE8AuwWnyFEgKzfS1UA+3sWTju3BGAu7gKYIfBW+Q/AAQgBeMCkt1wVsLZjcwUYG2Z9wGLHZitWk1DEisubUYt2XB5IWkSyFqG0RSxvMZi0Gc1+Ox3fm00ZJ5mGVtkAAAAASUVORK5CYII=", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAhklEQVR42u2XsRHAMAgDNY73nye7OG2KgGUnGCWH76j/oTACPfnhcwIA3AoTGIFXRTADPlqjakYEDJwFWyJLAk/hrAQi4YwEouEjiVuBt+FXCVcgqntvCtjVvTUF7OremkIJlEAJ6Aikf0QSX3H6MpJYx+mBRCKSSYRSiVgucZjInGa/vY5PvB72/7IdMuAAAAAASUVORK5CYII=" ] }, "output": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/multi-image-edit.png" }, "raw_response": { "gatewayMetadata": { "keySource": "BYOK" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__gpt-image-2/multi-image-edit.png" }, "state": "Completed" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'openai/gpt-image-2',\n {\n prompt:\n 'Combine these into a single photorealistic scene: a ceramic smiley-face mug next to a red rubber ball on a sunlit wooden table',\n images: [\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAnklEQVR42u2XQRLAIAgD8/839i/26qFCACm0ozPe1KwcQsAoXvgcAABxpwFowl4QWITHxW0LCBhxVngF4gKIirMQyBRnIJAtrkE8AuwWnyFEgKzfS1UA+3sWTju3BGAu7gKYIfBW+Q/AAQgBeMCkt1wVsLZjcwUYG2Z9wGLHZitWk1DEisubUYt2XB5IWkSyFqG0RSxvMZi0Gc1+Ox3fm00ZJ5mGVtkAAAAASUVORK5CYII=',\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAhklEQVR42u2XsRHAMAgDNY73nye7OG2KgGUnGCWH76j/oTACPfnhcwIA3AoTGIFXRTADPlqjakYEDJwFWyJLAk/hrAQi4YwEouEjiVuBt+FXCVcgqntvCtjVvTUF7OremkIJlEAJ6Aikf0QSX3H6MpJYx+mBRCKSSYRSiVgucZjInGa/vY5PvB72/7IdMuAAAAAASUVORK5CYII=',\n ],\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\": \"openai/gpt-image-2\",\n \"input\": {\n \"prompt\": \"Combine these into a single photorealistic scene: a ceramic smiley-face mug next to a red rubber ball on a sunlit wooden table\",\n \"images\": [\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAnklEQVR42u2XQRLAIAgD8/839i/26qFCACm0ozPe1KwcQsAoXvgcAABxpwFowl4QWITHxW0LCBhxVngF4gKIirMQyBRnIJAtrkE8AuwWnyFEgKzfS1UA+3sWTju3BGAu7gKYIfBW+Q/AAQgBeMCkt1wVsLZjcwUYG2Z9wGLHZitWk1DEisubUYt2XB5IWkSyFqG0RSxvMZi0Gc1+Ox3fm00ZJ5mGVtkAAAAASUVORK5CYII=\",\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAhklEQVR42u2XsRHAMAgDNY73nye7OG2KgGUnGCWH76j/oTACPfnhcwIA3AoTGIFXRTADPlqjakYEDJwFWyJLAk/hrAQi4YwEouEjiVuBt+FXCVcgqntvCtjVvTUF7OremkIJlEAJ6Aikf0QSX3H6MpJYx+mBRCKSSYRSiVgucZjInGa/vY5PvB72/7IdMuAAAAAASUVORK5CYII=\"\n ]\n }\n}'" } ] } ], "default_example": null, "code_snippets": [], "supports_async": false, "zdr": true, "zdr_comment": null, "external_info": "https://openai.com/", "terms": "https://openai.com/policies/", "cover_image_url": "https://pub-26f1392c1b674324be6786695bd72257.r2.dev/openai/gpt-image-2.png", "metadata": { "Image Editing": "Yes", "Output Formats": "png, webp, jpeg", "Quality": "low, medium, high, auto", "Sizes": "1024x1024, 1024x1536, 1536x1024, auto" }, "request_formats": null, "providers": null, "provider_details": [ { "id": "openai", "pricing": { "input_tokens": 5, "input_image_tokens": 8, "input_cached_tokens": 1.25, "input_cached_image_tokens": 2, "output_image_tokens": 30, "output_tokens": 10 } } ], "banner": null, "created_at": "2026-05-22 17:53:39", "schema": { "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "prompt": { "type": "string", "description": "Text prompt describing the image to generate or edit" }, "images": { "description": "Input images for image editing, 1-16 entries. Each entry is base64-encoded (raw string or data:image/{png|jpeg|webp};base64,... URI).", "maxItems": 16, "type": "array", "items": { "type": "string" } }, "quality": { "description": "Quality of the generated image", "type": "string", "enum": [ "low", "medium", "high", "auto" ] }, "size": { "type": "string", "pattern": "^(?:auto|\\d+x\\d+)$", "description": "Size of the generated image: auto or WIDTHxHEIGHT. Each edge must be at most 3840 pixels, both dimensions must be multiples of 16, the aspect ratio must be between 1:3 and 3:1, and total pixels must be between 655,360 and 8,294,400." }, "background": { "description": "Background transparency setting. Use transparent for images with no background, opaque for a solid background, or auto to let the model decide.", "type": "string", "enum": [ "transparent", "opaque", "auto" ] }, "output_format": { "description": "Output format for the generated image", "type": "string", "enum": [ "png", "webp", "jpeg" ] } }, "required": [ "prompt" ], "additionalProperties": {} }, "output": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "image": { "type": "string", "format": "uri", "description": "URL to the generated image" } }, "required": [ "image" ], "additionalProperties": false } } }