Short answer
Usegpt-image-2 and add two fields to the request:
background: "transparent" is a capability OpenAI opened up for GPT-Image-2 on 2026-08-21 (marked preview by OpenAI). APIYI has verified it end to end: both text-to-image and image editing return true alpha transparency.Which models can produce transparent backgrounds
Two ways to call it
Text-to-image /v1/images/generations
Image editing /v1/images/edits
Hand it an ordinary photo and ask it to drop the background:
mask) and a transparent background work together — they do not conflict.
Why jpeg does not work
JPEG has no alpha channel — there is nowhere to store transparency. Combining output_format: "jpeg" with background: "transparent" returns a 400:
png (lossless, larger) or webp (lossy and tunable, smaller, also supports alpha). webp additionally accepts output_compression to trim file size.
Editing is a re-draw, not a precise cutout
Set expectations here up front: when/v1/images/edits runs with background: transparent, the model understands the scene and paints the subject again rather than tracing the original outline the way Photoshop would. That means:
- The subject’s pose, style, and fine detail will shift — this is not pixel-level preservation
- To stay closer to the original, use
quality: "high"and state “keep the original composition, do not change the subject’s appearance” in the prompt - If your workflow needs pixel-exact extraction, do the cutout yourself with
rembg,PIL, orsharp. Model generation is a better fit for “produce reusable assets” than for exact matting
Do not describe a scene in the prompt — the parameter cannot override it
background: "transparent" only guarantees an alpha channel and nudges the model toward a cutout. If the prompt or the reference image describes a full scene, the model paints that scene and the parameter will not stop it. This is the most common reason transparent output “sometimes works, sometimes doesn’t”, and it has nothing to do with the quality tier.
Measured on 2026-09-11 with gpt-image-2.5-sunburst, 30 calls (half medium, half high, text-to-image plus reference-image edits):
Three writing rules:
- ❌ Avoid environment words — ground, sky, room, forest. If you want atmosphere, attach it to the subject (“a few falling maple leaves”, not “a maple forest”)
- ✅ End every prompt with
isolated subject on a transparent background, no scenery, no ground, no shadow - ✅ When the reference image has a background, state
remove the background entirely, keep only the characterin the edit prompt
quality from medium to high does not make transparency more reliable; it only costs 4× the tokens (439 → 1,756).
Billing
Transparency costs nothing extra. At the same quality tier and size,background: "transparent" and background: "opaque" consume exactly the same number of image tokens, billed under the normal per-token rules for gpt-image-2.
Common errors
400: Transparent background is not supported for JPEG output format
400: Transparent background is not supported for JPEG output format
output_format was set to jpeg. Switch it to png or webp.The image really is on white, not transparent
The image really is on white, not transparent
Check three things. First, that the
background field actually reached the API — the edits endpoint is multipart/form-data, so it must be -F background=transparent rather than a JSON body field. Second, whether the top-level background in the response echoes transparent. Third, whether you are on gpt-image-2 — gpt-image-2-all and gpt-image-2-vip have no such parameter and silently ignore it.If all three check out and you still get white or a full background, the prompt (or the reference image) almost certainly describes a scene — the model painted the environment it was asked for, and the parameter cannot override that. See “Do not describe a scene in the prompt” above.How do I confirm the image really has an alpha channel
How do I confirm the image really has an alpha channel
One Python snippet is enough:Mode
RGB means there is no alpha channel at all. Mode RGBA with every alpha value at 255 means the channel exists but nothing was cut out.My prompt already says transparent background — why pass the parameter too
My prompt already says transparent background — why pass the parameter too
A prompt only asks the model to paint it that way, and the model may paint a grey-and-white checkerboard that merely looks transparent — those are still opaque pixels. Only the
background: "transparent" parameter guarantees a real alpha channel. The reverse also holds: the parameter guarantees the channel but cannot override a scene described in the prompt — the two have to work together.Related docs
GPT-Image-2 overview
Full parameters, sizes, quality tiers, and error codes
Text-to-image API reference
Every field on
/v1/images/generationsImage editing API reference
/v1/images/edits and multi-image fusionMask inpainting
Use an alpha mask to mark the region to change
Official vs reverse routes
Choosing between
gpt-image-2.5-flare / sunburst / gpt-image-2 / -all / -vipArtifacts on white backgrounds
A different problem with pure-white backgrounds