GPT Image 2 / 2.5 / 2.6 Image Editing API

GPT Image 2.6 API Model Selection and Quickstart

1. Get an API Key

Open the Ace Data Cloud application list, enter an available application, and copy the API Key.

Get an Ace Data Cloud API Key

2. Edit Using an Image URL

Original image:

Original image for GPT Image 2 editing

curl https://api.acedata.cloud/openai/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "image": "https://cdn.acedata.cloud/assets/examples/gpt-image/d56455e2-e7f7-4bcd-b935-475b0a1e0948_0-18240dc44b9c.png",
    "prompt": "Keep the mug, tabletop, camera angle, portrait layout, and soft shadow unchanged. Change only the mug color from white to vivid orange and the pale cream background to solid dark navy blue. No text and no logo.",
    "size": "1024x1536"
  }'

Successful response:

{
  "success": true,
  "task_id": "49848451-c624-4df9-9dc2-494018daaf4c",
  "trace_id": "5ac021c2-2891-4eed-bfcf-4c6668ac1be1",
  "created": 1788831893,
  "model": "gpt-image-2",
  "data": [
    {
      "url": "https://cdn.acedata.cloud/assets/examples/gpt-image/49848451-c624-4df9-9dc2-494018daaf4c_0-b6d780a732ca.png"
    }
  ],
  "usage": {
    "input_tokens": 775,
    "output_tokens": 1372,
    "total_tokens": 2147
  }
}

This is the actual editing result completed through Ace Data Cloud on September 8, 2026: the mug turned orange, the background turned dark navy blue, and the original composition and 1024×1536 dimensions were preserved:

GPT Image 2 orange mug editing result

3. Upload a Local Image

Use multipart/form-data:

curl https://api.acedata.cloud/openai/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gpt-image-2" \
  -F "image=@input.png" \
  -F "prompt=Replace the background with a bright modern studio"

You can pass image multiple times; the GPT Image series supports up to 16 reference images. The image field in a JSON request can be a single URL or an array of URLs; local files are uploaded using multipart.

Models and Billing Methods

Model Use Cases and Billing Methods
gpt-image-2 Default reverse channel, fixed billing per successfully generated image
gpt-image-2:reverse Explicitly selects the reverse channel, fixed billing per successfully generated image
gpt-image-2:official Official API channel, greater stability, billed based on actual Token usage
gpt-image-2.5-flare Focuses on generation speed, fixed billing per successfully generated image
gpt-image-2.6-flare Focuses on generation speed, fixed billing per successfully generated image
gpt-image-2.5-flare:reverse Explicit reverse alias, equivalent to gpt-image-2.5-flare, fixed billing per successfully generated image
gpt-image-2.6-flare:reverse Explicit reverse alias, equivalent to gpt-image-2.6-flare, fixed billing per successfully generated image
gpt-image-2.5-flare:official Official API channel, greater stability and a focus on generation speed, billed based on actual Token usage
gpt-image-2.6-flare:official Official API channel, greater stability and a focus on generation speed, billed based on actual Token usage
gpt-image-2.5-sunburst Focuses on high fidelity and fine control, fixed billing per successfully generated image
gpt-image-2.6-sunburst Focuses on high fidelity and fine control, fixed billing per successfully generated image
gpt-image-2.5-sunburst:reverse Explicit reverse alias, equivalent to gpt-image-2.5-sunburst, fixed billing per successfully generated image
gpt-image-2.6-sunburst:reverse Explicit reverse alias, equivalent to gpt-image-2.6-sunburst, fixed billing per successfully generated image
gpt-image-2.5-sunburst:official Official API channel, greater stability and a focus on high fidelity and fine control, billed based on actual Token usage
gpt-image-2.6-sunburst:official Official API channel, greater stability and a focus on high fidelity and fine control, billed based on actual Token usage

The price shown on the page for the official API channel is an estimate made before the request; the final charge is based on the actual Token usage in the response and the usage records.

quality supports auto, low, medium, and high; 2.5 / 2.6 Flare and Sunburst (including :reverse and :official variants) additionally support xhigh and max. This field can be passed for both JSON image URL editing and multipart file editing; the official channel is billed based on actual Token usage.

4. Use a Mask for Localized Editing

The official Images Edit endpoint uses mask to specify the area that may be modified. Ace Data Cloud's :official models follow the same multipart contract:

  • mask must be a PNG with an Alpha channel, no larger than 4MB;
  • The mask dimensions must exactly match the first image;
  • Transparent pixels with an Alpha value of 0 indicate areas where editing is allowed, while non-transparent pixels indicate areas that should be preserved;
  • An RGB image that is only black and white but has no transparency channel cannot serve as a valid mask;
  • The prompt should describe the desired complete image while clearly specifying the localized changes and the content that must remain unchanged.

First, generate a mask from the original image below. The example makes the central rectangle transparent, allowing the model to modify only that area:

from PIL import Image, ImageDraw

source = Image.open("input.png").convert("RGBA")
mask = Image.new("RGBA", source.size, (0, 0, 0, 255))
draw = ImageDraw.Draw(mask)
width, height = source.size
draw.rectangle(
    (width // 4, height // 4, width * 3 // 4, height * 3 // 4),
    fill=(0, 0, 0, 0),
)
mask.save("mask.png")

Then upload the original image and the mask together:

curl https://api.acedata.cloud/openai/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gpt-image-2:official" \
  -F "image=@input.png" \
  -F "mask=@mask.png" \
  -F "prompt=Keep the composition, lighting, and all objects outside the transparent mask unchanged. Inside the masked area, replace the empty tabletop with a small blue ceramic vase."

You can also use the images.edit call from the official OpenAI Python SDK; simply point base_url to Ace Data Cloud:

from openai import OpenAI

client = OpenAI(
    api_key="你的 API Key",
    base_url="https://api.acedata.cloud/openai",
)

with open("input.png", "rb") as image, open("mask.png", "rb") as mask:
    result = client.images.edit(
        model="gpt-image-2:official",
        image=image,
        mask=mask,
        prompt=(
            "Keep the composition, lighting, and all objects outside the "
            "transparent mask unchanged. Inside the masked area, replace "
            "the empty tabletop with a small blue ceramic vase."
        ),
    )

print(result.data[0].url)

When using mask, the original image and the mask must be uploaded separately in the same multipart request using image=@input.png and mask=@mask.png. Do not mix an original image URL with a local mask file; image editing requests using only URLs do not support attaching a local mask file. The mask constrains the editing area, but the generative model may still blend the edges naturally; when strict boundaries are required, use clear Alpha edges and reiterate in the prompt which content must remain unchanged.

The above calling methods are consistent with the mask examples in the OpenAI Image Edit API and the official GPT Image Cookbook.

5. Common Parameters

Field Description
model gpt-image-2, gpt-image-2.5-flare (faster), or gpt-image-2.5-sunburst (higher fidelity and control); all three offer corresponding :official variants, and gpt-image-2 also supports :reverse
image For JSON, use a single URL or an array of up to 16 URLs; for multipart, use one or more image file fields. A local image file must be uploaded when using mask
mask Optional PNG mask, limited to multipart file uploads; must have an Alpha channel, match the dimensions of the first image, and not exceed 4MB
prompt Editing instructions
size auto or WIDTHxHEIGHT that meets the constraints
n 1–10; only 1 is supported when response_format=b64_json
response_format url or b64_json
callback_url Optional asynchronous callback URL

The size rules are the same as those for the generation API: width and height must be multiples of 16, the longer side must not exceed 3840, the total pixel count must be 655,360–8,294,400, and the aspect ratio must not exceed 3:1. When size is omitted or auto is used, the model selects the image dimensions based on the prompt and the first reference image.

gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, and their :reverse aliases are billed by the number of successfully generated images; gpt-image-2:official, gpt-image-2.5-flare:official, and gpt-image-2.5-sunburst:official are billed based on actual Token usage for text input, reference image input, and image output, with usage records serving as the final reference.

6. Asynchronous Callbacks and Troubleshooting

For long-running tasks, add the following to the request:

{
  "callback_url": "https://example.com/webhooks/images"
}

The asynchronous 200 response is {"task_id": "..."}; the final result is sent via callback upon completion. Synchronous requests return created and data.

Status Check
400 Image format/number, parameter combinations, and size format; when using mask, check the PNG Alpha channel, the 4MB limit, and whether its dimensions match the first original image
401 API Key and Bearer Header
429 Request frequency
504 Switch to asynchronous callbacks

Error responses include a trace_id. Provide this ID when reporting a problem; do not provide your API Key.

Refer to the OpenAI Images Edits API page for the complete fields and current enumerated values. For text-only image generation, see GPT Image 2 / 2.5 / 2.6 Image Generation.

GPT Image 2.6

GPT Image 2.6 uses the same generation, editing, asynchronous task, and billing interfaces as 2.5:

Model Billing
gpt-image-2.6-flare / gpt-image-2.6-flare:reverse 0.22 Credits/image
gpt-image-2.6-sunburst / gpt-image-2.6-sunburst:reverse 0.22 Credits/image
gpt-image-2.6-flare:official Same as 2.5 official, billed based on actual Token usage
gpt-image-2.6-sunburst:official Same as 2.5 official, billed based on actual Token usage

Quality options are auto, low, medium, high, xhigh, and max; for size, use auto or WIDTHxHEIGHT that meets the above constraints. This API supports png, jpeg, and webp; GPT Image 2.6 also supports native animated gif, but does not currently support SVG. Editing supports JSON image URLs and multipart file uploads. :reverse is an explicit alias for the standard version of the same name. Use the full model name; do not pass gpt-image-2.6.

GPT Image 2.6 Image-to-Animated-GIF

The standard, :reverse, and :official versions of GPT Image 2.6 Flare and Sunburst can all use output_format: "gif". Animation frames, loop information, and playback duration are preserved; frame_count specifies the number of frames, and frame_duration_ms specifies the duration of each frame in milliseconds. The frame count must be an integer from 2–16, and the duration of each frame must be an integer from 20–655350 milliseconds; these parameters are only for GIFs. Encoding rounds to the nearest 10ms. When unspecified, the default is 9 frames at 200 milliseconds per frame; when the GIF size is omitted or set to auto, the 512x512 preset is used.

It is recommended to start with size: "512x512", frame_count: 9, and frame_duration_ms: 200. GIFs have separate size and frame-count limits, so the static 4K specifications cannot be applied directly; some models may adjust the actual output size. n specifies the number of GIF files returned, not the number of animation frames. The standard and :reverse versions are still billed by the number of successful files, while the official version is billed by actual Token usage.

{
  "model": "gpt-image-2.6-flare",
  "image": "https://cdn.acedata.cloud/assets/examples/gpt-image/d56455e2-e7f7-4bcd-b935-475b0a1e0948_0-18240dc44b9c.png",
  "prompt": "Animate the mug gently moving left and right. Keep its appearance and the background, no text.",
  "output_format": "gif",
  "size": "512x512",
  "quality": "medium",
  "frame_count": 9,
  "frame_duration_ms": 200,
  "n": 1,
  "async": true
}

GPT Image 2.6 4K Static Images

Flare, Sunburst, and their :reverse and :official variants can all use the 4K pixel presets mentioned above, such as 3840x2160 and 2160x3840. For both generation and editing, pass the specific pixel dimensions through size; 4K is not a valid size value, and 4096x4096 also exceeds the current pixel limit. The 4K specifications above apply to static PNG/JPEG/WebP images; for GIFs, use their dedicated parameters.

GPT Image 2.6 Composition Complexity

complexity can be set to low, medium, or high; when omitted, the model default of high is used. It controls planning complexity independently of quality rendering quality; there is no additional per-request charge, and the official version is still billed by actual Token usage. Other models do not support this parameter.

GIFs do not support masks, markup images, custom compression, prompt rewriting, or partial image streaming; incompatible combinations will be rejected before generation. Size, frame count, and quantity are jointly subject to the model's pixel budget; 1024x1024 with 2 frames has been verified to work for standard Flare, but this conclusion cannot be extended to all 1K combinations or 4K GIFs.

Markup-Guided Editing

GPT Image 2.6 static editing supports markup. Upload a transparent PNG with the same dimensions as the first reference image, circle the area to be modified on a separate layer, and describe the requested changes in prompt. The markup layer must contain transparent pixels; each of the two images must not exceed 16777216 pixels, and the markup image must not exceed 40MB. JSON can accept an HTTPS URL, a PNG base64 data URL, or { "image_url": "https://..." }; multipart uploads the file through markup. The platform passes the markup layer as a file. markup cannot be used with mask, GIF, or prompt_rewriter, and does not support file_id.

input_fidelity does not apply to GPT Image 2.6; please omit it.