Gpt-image-1 - Transparent backgrounds with Edit request

When using a reference image through ChatGPT 4o image-gen you could return an image with a transparent background (i.e a die cut sticker). It looks like the transparent option is only available through the Generate endpoint, but not the Edit endpoint. Even prompting ‘transparent background’ doesn’t result in a transparent background.

Am I doing something wrong, or are there plans to introduce this?

Hi, welcome to the community!

Are you trying with ChatGPT or API?

I’m using the API, specifically /edit endpoint because I need to supply a reference image.

This works fine through ChatGPT.

It works, but also it changes some details:



Thanks for trying.

That’s actually still a solid white background and the file is jpeg, not PNG.

Yet if you ran the same prompt in ChatGPT you would most likely get a transparent background and PNG file

The forum does that. You can only show or share preserved transparency by converting to a GIF with reduced color palette. Or you can use photo edit software to put a transparency grid behind just to demonstrate.

white to transparent by ChatGPT

Edits might be fundamentally different, since it has been used to infill and outfill from a mask.

Appreciate the clarification @_j

Here’s an example output through playground. It followed the PNG format request and provided a .png file, however the checkerboard background is fake and isn’t transparent.

Prompt

Create a digital die cut sticker in a 3D clay model inspired by characters like Wallace & Gromit, with rounded plastic features and sculpted textures based on the main uploaded subject image. The sticker should have a clean transparent background, a thick white outline around the subject, and be centered within a square canvas (1:1 aspect ratio). Guidelines - You must transform the subject into a style and not be photo-realistic. - You must remove the background completely and make it transparent and provide the final file in PNG format. Keep only the die cut sticker with a white solid white border. Output must be a cutout die cut sticker on a fully transparent background.

Are you explicitly setting it to output png transparent?

Use output_format="png" or "webp" and set background="transparent". Including “transparent background” in the prompt might also trigger this automatically (as per cookbook).

prompt_transparent_hat = “generate a pixel-art style picture of a green bucket hat with a pink quill on a transparent background.”

    response = client.images.generate(
        model="gpt-image-1",
        prompt=prompt_transparent_hat,
        size="1024x1024",
        quality="low",
        output_format="png",          # Required for transparency
        # background="transparent",   # Can be explicitly set
        response_format="b64_json",
        n=1
    )

More help here…

If you’re already setting it and it’s still not working, let us know.

The issue is with the Edit endpoint not Generate.

Edit doesn’t have explicit transparent options in the request.

It can edit with transparency, but the source must also be transparent.

Example:

prompt_mask_edit="make the dog green and in a jumping pose, and keep the transparent background"

result_sticker_edit = client.images.edit(
    model="gpt-image-1",         
    prompt=prompt_mask_edit,
    image=img_input,
    quality="low",
    size="1024x1024"
)

Thanks all.

Seems to just confirm my suspicions.

Shame /edit can’t work the same as the behaviour on ChatGPT. Maybe when Responses API is available.

Hi!

I’ve just tested, now /v1/images/edits has a background parameter. Set it to transparent, it can return png/webp with transparent layer.