The edits endpoint can be used to implement this.
The image edits endpoint allows you to edit and extend an image by uploading a mask. The transparent areas of the mask indicate where the image should be edited, and the prompt should describe the full new image, not just the erased area . This endpoint can enable experiences like the editor in our DALL·E preview app.