GPT-Image-2 Image Generation API
Download this document as MD file
Endpoint Path: POST /v1/images/generations
Recommended Models:
gpt-image-2 (OpenAI's next-generation image generation model, supporting both text-to-image and image-to-image)
gpt-image-2.5-flare (up to 50% lower latency than GPT-Image-2 with still-improved quality; suited to batch generation and draft iteration)
gpt-image-2.5-sunburst (trades longer generation time for finer detail and better consistency across multi-turn edits; suited to final versions)
gpt-image-2.6-flare (2.6 speed tier: as fast as about 6 seconds per image with quality=low; better layouts for posters, product images, and similar designs)
gpt-image-2.6-sunburst (2.6 detail tier: more complete detail when quality is set to medium/high, and better consistency across multi-turn edits)
Note: Generated image URLs are temporary links (valid for 2 hours). Please save important works locally.
Model Features
| Feature | gpt-image-2 | gpt-image-2.5-flare / -sunburst | gpt-image-2.6-flare / -sunburst |
|---|---|---|---|
| Type | Image generation model | Image generation and editing model | Image generation and editing model |
| Supported Endpoint | Image generation | Image generation + image editing | Image generation + image editing |
| Return Format | URL or Base64 | URL or Base64 | URL or Base64; also supports svg and gif |
| Quality Tiers | low, medium, high | low, medium, high, xhigh, max | low, medium, high |
Planning Control complexity | - | - | β Supported |
| Transparent Background | β οΈ Preview | β Supported | β Supported |
| Aspect Ratio Setting | β Supported | β Supported | β Supported |
| Image-to-Image | β Supported (up to 16 images) | β Supported (up to 16 images) | β Supported (up to 16 images) |
| Charge on Failure | β No charge | β No charge | β No charge |
| Compatible Format | DALLΒ·E format | DALLΒ·E format | DALLΒ·E format |
Version Selection Notes
- Quality tier availability:
xhighandmaxare tiers exclusive to the 2.5 series; 2.6 supports up tohigh, so adjustqualityaccordingly when calling across generations. - Transparent background: Officially supported from 2.5 onward (in preview on 2); requires
output_formatto be set topngorwebp. - Markup editing:
markupis supported on both 2.5 and 2.6, via/v1/images/edits. - Cost basis: 2.5 and 2.6 have the same per-token price; the difference comes from token consumption per image. At the
lowandmediumtiers, 2.6 consumes significantly more than 2.5, while athighand above they are roughly the same. For maximum detail, still use 2.5'sxhighormax; use 2.6 when you need GIF, SVG, orcomplexity.
Request Parameters
Header
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
Authorization | string | β | Bearer {{YOUR_API_KEY}} | API authentication token |
Content-Type | string | β | application/json | Request body type |
Body (application/json)
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | β | - | Model name: gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare, gpt-image-2.6-sunburst |
prompt | string | β | - | Describes the desired image content, style, and composition. Supports both Chinese and English, up to 32,000 characters |
image | array[string] | β | - | Image-to-image reference image list (URL or Base64), 1β16 images |
aspect_ratio | enum[string] | β | auto | Image aspect ratio: auto, 1:1, 9:16, 16:9, 4:3, 3:4 |
resolution | string | β | 1K | Image resolution: supports 1K, 2K, 4K.β οΈ Note: When aspect_ratio is 1:1, auto, or not provided, only 1K resolution is supported. Specifying 2K or 4K in this case will cause task creation to fail. |
size | string | β | - | Image resolution. Takes priority over the aspect_ratio and resolution parameters. Supports any resolution, with the requirements: both sides must be multiples of 16 pixels; the long side may reach up to 3,840 pixels (4K); the aspect ratio may reach up to 3:1. Example: 1024x1024 |
quality | string | β | medium | Image quality. Options: low, medium, high; xhigh and max are tiers exclusive to the 2.5 series, and 2.6 supports only up to high |
background | string | β | auto | Background handling: auto, transparent, opaque. Transparent backgrounds are officially supported from 2.5 onward (in preview on 2); transparent requires output_format to be set to png or webp |
complexity | string | β | high | New in 2.6. Planning depth before generation: low, medium, high; independent of quality. When omitted, it is treated as high, which adds extra latency; for most simple edits, explicitly passing low is recommended |
output_format | string | β | png | Output file format: png, jpeg, webp; new in 2.6: gif (looping animation) and svg (vector graphic). Unrelated to response_format, which only controls whether a URL or Base64 is returned |
frame_count | integer | β | 9 | Takes effect only when output_format=gif. Number of frames, range 2β16 |
frame_duration_ms | integer | β | 200 | Takes effect only when output_format=gif. Duration of each frame, range 20β2000, rounded to 10ms |
svg | object | β | - | Takes effect only when output_format=svg. Specifies the author model that writes the vector and its reasoning level, e.g. {"model": "<author model>", "reasoning": {"effort": "medium"}} |
response_format | string | β | url | Return format: url or b64_json |
Image Input Restrictions (Image-to-Image)
- Supported Formats: JPEG, PNG, WEBP, JPG
- Maximum File Size: 10MB
- Maximum Number of Files: 16
GPT-Image-2.6 New Parameter Constraints
gifandsvgare output only by the generation endpoint; the edit endpoint does not return these two formats. Neither supports streaming responses, partial images, oroutput_compression.- GIF frame count and image size share a pixel budget: the larger the size, the fewer frames fit; requests that exceed the limit fail outright.
svgis generated in two stages: a reference image is generated first, then the author model converts it into a vector; a single request is billed for both parts. Only a single vector file is output.markup(markup editing) is supported only by/v1/images/edits: upload a transparent PNG layer of the same size as the original image to circle the areas to be changed; it cannot be used together withmask.gifandsvgare capabilities being rolled out in stages; requests return an error if the account does not have the corresponding permission.
π Usage Scenario Examples
1. Text-to-Image
Generate an image using only a text prompt, without passing the
imageparameter.
1.1 Basic Text-to-Image
JSON Body
{
"model": "gpt-image-2",
"prompt": "An orange cat lying on a windowsill basking in the sun, with cherry blossoms in full bloom outside the window in spring",
"aspect_ratio": "16:9"
}
cURL
curl -X POST 'https://beeroute.ai/v1/images/generations' \
-H 'Authorization: Bearer {{YOUR_API_KEY}}' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "An orange cat lying on a windowsill basking in the sun, with cherry blossoms in full bloom outside the window in spring",
"aspect_ratio": "16:9"
}'
1.2 Portrait Phone Wallpaper
JSON Body
{
"model": "gpt-image-2",
"prompt": "Aurora and starry sky wallpaper, dreamy purple tones, snowy mountain silhouette",
"aspect_ratio": "9:16"
}
cURL
curl -X POST 'https://beeroute.ai/v1/images/generations' \
-H 'Authorization: Bearer {{YOUR_API_KEY}}' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "Aurora and starry sky wallpaper, dreamy purple tones, snowy mountain silhouette",
"aspect_ratio": "9:16"
}'
1.3 Returning Base64 Format
JSON Body
{
"model": "gpt-image-2",
"prompt": "Watercolor-style sunrise over Mount Fuji, with its reflection on the lake in the foreground",
"aspect_ratio": "4:3",
"response_format": "b64_json"
}
1.4 Looping Animated GIF (2.6)
Describe a single action and a matching first and last frame in the prompt to get a seamlessly looping animation.
JSON Body
{
"model": "gpt-image-2.6-flare",
"prompt": "Flat-illustration brand mascot, fixed camera, a single waving loop, with matching poses in the first and last frames",
"aspect_ratio": "1:1",
"output_format": "gif",
"frame_count": 12,
"frame_duration_ms": 120
}
1.5 SVG Vector Output (2.6)
The output is a single static vector file, suited to icons, logos, and other assets that need further editing.
JSON Body
{
"model": "gpt-image-2.6-sunburst",
"prompt": "Flat minimalist app icon, single subject, deep blue color scheme, solid background",
"size": "1024x1024",
"output_format": "svg"
}
1.6 Transparent-Background Product Image (2.5 and Above)
Set
backgroundtotransparent; the output format must bepngorwebp.
JSON Body
{
"model": "gpt-image-2.5-sunburst",
"prompt": "Hero shot of a matte black wireless speaker on a light concrete base, soft side lighting, clean subject edges",
"size": "1536x1024",
"quality": "high",
"background": "transparent",
"output_format": "png"
}
2. Image-to-Image
Pass the
imageparameter (the reference image's URL or Base64), and combine it with a prompt to perform style transfer, editing, extension, and other operations on the image.
Supports 1β16 reference images, each up to 10MB, in JPEG / PNG / WEBP / JPG format.
2.1 Image-to-Image β Passing an Image URL
JSON Body
{
"model": "gpt-image-2",
"prompt": "Convert this photo into Studio Ghibli animation style, keeping the original composition while making the colors warmer and brighter",
"aspect_ratio": "auto",
"image": [
"https://example.com/my-photo.jpg"
]
}
cURL
curl -X POST 'https://beeroute.ai/v1/images/generations' \
-H 'Authorization: Bearer {{YOUR_API_KEY}}' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "Convert this photo into Studio Ghibli animation style, keeping the original composition while making the colors warmer and brighter",
"aspect_ratio": "auto",
"image": [
"https://example.com/my-photo.jpg"
]
}'
2.2 Image-to-Image β Passing a Base64 Image
JSON Body Example (Base64 shown truncated)
{
"model": "gpt-image-2",
"prompt": "Turn this portrait photo into a cyberpunk-style illustration with neon lighting effects",
"aspect_ratio": "1:1",
"image": [
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA..."
]
}
2.3 Image-to-Image β Multi-Image Reference Fusion
Pass multiple reference images (up to 16), and the model will create based on a comprehensive reference of all images.
JSON Body
{
"model": "gpt-image-2",
"prompt": "Blend the person from the first image into the scene of the second image, keeping it natural and harmonious with consistent lighting",
"aspect_ratio": "4:3",
"image": [
"https://example.com/person.jpg",
"https://example.com/background.jpg"
]
}
cURL
curl -X POST 'https://beeroute.ai/v1/images/generations' \
-H 'Authorization: Bearer {{YOUR_API_KEY}}' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-2",
"prompt": "Blend the person from the first image into the scene of the second image, keeping it natural and harmonious with consistent lighting",
"aspect_ratio": "4:3",
"image": [
"https://example.com/person.jpg",
"https://example.com/background.jpg"
]
}'
2.4 Image-to-Image β Landscape Image Editing
JSON Body
{
"model": "gpt-image-2",
"prompt": "Add a vivid rainbow to this landscape photo and shift the sky to warm sunset tones",
"aspect_ratio": "16:9",
"image": [
"https://example.com/landscape.jpg"
]
}
2.5 Local Edit + Low Planning Depth (2.6)
When changing only part of an image, explicitly pass
complexity=lowto reduce planning time and lower the chance of unintended changes.
JSON Body
{
"model": "gpt-image-2.6-sunburst",
"prompt": "Replace only the background with solid gray, keeping the person, clothing, and lighting unchanged",
"aspect_ratio": "3:4",
"image": [
"https://example.com/portrait.jpg"
],
"quality": "medium",
"complexity": "low"
}
3. Response Format
Success Response (HTTP 200)
Returning URL Format (default)
{
"data": [
{
"url": "https://example.com/generated_image.png"
}
]
}
Returning Base64 Format
{
"data": [
{
"b64_json": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
]
}
4. Common Scenarios Quick Reference
| Scenario | Key Parameters | Prompt Example |
|---|---|---|
| Basic Text-to-Image | aspect_ratio: "1:1" | "A corgi running on the grass" |
| Landscape Poster | aspect_ratio: "16:9" | "Cinematic sci-fi poster, space station scene" |
| Phone Wallpaper | aspect_ratio: "9:16" | "Aurora and starry sky wallpaper, dreamy purple tones" |
| Style Transfer | image: [url] | "Convert to oil painting style" |
| Image Editing | image: [url] | "Remove the background and replace it with a beach" |
| Multi-Image Fusion | image: [url1, url2, ...] | "Combine multiple images into one" |
| Social Cover | aspect_ratio: "16:9" | "Minimalist tech-style profile cover" |
| GIF Animation | output_format: "gif", frame_count: 12 | "Mascot waving, single-action loop" |
| Vector Icon | output_format: "svg" | "Flat minimalist app icon, solid background" |
| Transparent-Background Asset | background: "transparent", output_format: "png" | "Product subject on a fully transparent background" |
| Local Image Edit | complexity: "low" | "Replace only the background, keep everything else unchanged" |
5. Key Notes
- Image Link Validity: The returned URL is a temporary link that expires after 2 hours. Please download and save it promptly.
- No Charge on Failure: No quota is deducted when generation fails.
- Image-to-Image
imageParameter: Supports passing image URLs or Base64 strings, which can be mixed, up to 16 images, each no larger than 10MB. - Supported Image Formats: JPEG, PNG, WEBP, JPG.
- Supported Aspect Ratios:
auto,1:1,9:16,16:9,4:3,3:4. - Prompt Tips: The more detailed the description, the better the generated result; mixed Chinese-English prompts are supported.
- New 2.6 Parameters:
complexity, thegif/svgvalues ofoutput_format,frame_count,frame_duration_ms, andsvgare supported only bygpt-image-2.6-flare/gpt-image-2.6-sunburst; do not pass them to 2.5 or earlier models. - Quality Tier Availability:
xhighandmaxare supported only by the 2.5 series, and 2.6 tops out athigh; when migrating from 2.5 to 2.6, adjustqualitytohighor below.
Last updated 2026-11-27 Β· Markdown source Β· llms.txt