BeeRoute logoBeeRoute.

Home / Docs / GPT-Image-2 Image Generation API

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

Featuregpt-image-2gpt-image-2.5-flare / -sunburstgpt-image-2.6-flare / -sunburst
TypeImage generation modelImage generation and editing modelImage generation and editing model
Supported EndpointImage generationImage generation + image editingImage generation + image editing
Return FormatURL or Base64URL or Base64URL or Base64; also supports svg and gif
Quality Tierslow, medium, highlow, medium, high, xhigh, maxlow, 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 FormatDALLΒ·E formatDALLΒ·E formatDALLΒ·E format

Version Selection Notes

  • Quality tier availability: xhigh and max are tiers exclusive to the 2.5 series; 2.6 supports up to high, so adjust quality accordingly when calling across generations.
  • Transparent background: Officially supported from 2.5 onward (in preview on 2); requires output_format to be set to png or webp.
  • Markup editing: markup is 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 low and medium tiers, 2.6 consumes significantly more than 2.5, while at high and above they are roughly the same. For maximum detail, still use 2.5's xhigh or max; use 2.6 when you need GIF, SVG, or complexity.

Request Parameters

ParameterTypeRequiredDefaultDescription
Authorizationstringβœ…Bearer {{YOUR_API_KEY}}API authentication token
Content-Typestringβœ…application/jsonRequest body type

Body (application/json)

ParameterTypeRequiredDefaultDescription
modelstringβœ…-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
promptstringβœ…-Describes the desired image content, style, and composition. Supports both Chinese and English, up to 32,000 characters
imagearray[string]❌-Image-to-image reference image list (URL or Base64), 1–16 images
aspect_ratioenum[string]❌autoImage aspect ratio: auto, 1:1, 9:16, 16:9, 4:3, 3:4
resolutionstring❌1KImage 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.
sizestring❌-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
qualitystring❌mediumImage quality. Options: low, medium, high; xhigh and max are tiers exclusive to the 2.5 series, and 2.6 supports only up to high
backgroundstring❌autoBackground 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
complexitystring❌highNew 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_formatstring❌pngOutput 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_countinteger❌9Takes effect only when output_format=gif. Number of frames, range 2–16
frame_duration_msinteger❌200Takes effect only when output_format=gif. Duration of each frame, range 20–2000, rounded to 10ms
svgobject❌-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_formatstring❌urlReturn 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

  • gif and svg are output only by the generation endpoint; the edit endpoint does not return these two formats. Neither supports streaming responses, partial images, or output_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.
  • svg is 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 with mask.
  • gif and svg are 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 image parameter.

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 background to transparent; the output format must be png or webp.

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 image parameter (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=low to 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

ScenarioKey ParametersPrompt Example
Basic Text-to-Imageaspect_ratio: "1:1""A corgi running on the grass"
Landscape Posteraspect_ratio: "16:9""Cinematic sci-fi poster, space station scene"
Phone Wallpaperaspect_ratio: "9:16""Aurora and starry sky wallpaper, dreamy purple tones"
Style Transferimage: [url]"Convert to oil painting style"
Image Editingimage: [url]"Remove the background and replace it with a beach"
Multi-Image Fusionimage: [url1, url2, ...]"Combine multiple images into one"
Social Coveraspect_ratio: "16:9""Minimalist tech-style profile cover"
GIF Animationoutput_format: "gif", frame_count: 12"Mascot waving, single-action loop"
Vector Iconoutput_format: "svg""Flat minimalist app icon, solid background"
Transparent-Background Assetbackground: "transparent", output_format: "png""Product subject on a fully transparent background"
Local Image Editcomplexity: "low""Replace only the background, keep everything else unchanged"

5. Key Notes

  1. Image Link Validity: The returned URL is a temporary link that expires after 2 hours. Please download and save it promptly.
  2. No Charge on Failure: No quota is deducted when generation fails.
  3. Image-to-Image image Parameter: Supports passing image URLs or Base64 strings, which can be mixed, up to 16 images, each no larger than 10MB.
  4. Supported Image Formats: JPEG, PNG, WEBP, JPG.
  5. Supported Aspect Ratios: auto, 1:1, 9:16, 16:9, 4:3, 3:4.
  6. Prompt Tips: The more detailed the description, the better the generated result; mixed Chinese-English prompts are supported.
  7. New 2.6 Parameters: complexity, the gif/svg values of output_format, frame_count, frame_duration_ms, and svg are supported only by gpt-image-2.6-flare / gpt-image-2.6-sunburst; do not pass them to 2.5 or earlier models.
  8. Quality Tier Availability: xhigh and max are supported only by the 2.5 series, and 2.6 tops out at high; when migrating from 2.5 to 2.6, adjust quality to high or below.

Last updated 2026-11-27 Β· Markdown source Β· llms.txt