Image editing API: Inpainting with masks not working as expected

Sam Okwu
Sam OkwuMar 10, 2026

I'm trying to use the image edit endpoint to replace specific parts of an image using a mask, but the results are ignoring my mask area.

response = client.images.edit(
    image=open("photo.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="A red sports car",
    n=1,
    size="1024x1024"
)

My mask is a PNG with the area to edit in transparent and the rest in black. But the entire image gets regenerated. Am I creating the mask wrong?

2.1k views12 replies28 likesSolved
4 Replies
Karen Wu

We're investigating increased error rates on GPT-4o. Will update this thread with progress. In the meantime, implementing retry logic with exponential backoff is recommended.

Karen Wu

Update: The issue has been identified and a fix has been deployed. Error rates should return to normal within the next 30 minutes. We apologize for the disruption. A full post-mortem will be published on our status page.

Nina Patel

Our monitoring shows the error rate peaked at 25% around 11am EST and has been gradually improving since.

Alex Petrov

Confirmed, back to normal on our end. Thanks for the quick resolution.

Log in to reply to this topic.