TsgcHTTP_API_OpenAI › Methods › CreateImageEdit
Edits an existing image using a text prompt and an optional transparency mask
function CreateImageEdit(const aRequest: TsgcOpenAIClass_Request_Image_Edit) : TsgcOpenAIClass_Response_Image_Edit;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Image_Edit | Request payload containing the source image, optional mask, edit prompt, model, size and result format. |
Parsed response object exposing the edited image(s) as URLs or base64-encoded PNG data. (TsgcOpenAIClass_Response_Image_Edit)
Issues a multipart/form-data POST to /v1/images/edits. Supply the original PNG and, when using DALL-E 2, a PNG mask with transparent pixels marking the region to regenerate. The text prompt describes how the masked area should be filled; unmasked pixels are preserved. Works with DALL-E 2 (with mask) and gpt-image-1 (mask optional), producing one or more edited images in the requested size and format.
oRequest := TsgcOpenAIClass_Request_Image_Edit.Create;
try
oRequest.Model := 'gpt-image-1';
oRequest.Image := 'C:\images\photo.png';
oRequest.Mask := 'C:\images\mask.png';
oRequest.Prompt := 'Replace the sky with a colorful aurora borealis';
oResponse := oAPI.CreateImageEdit(oRequest);
ShowMessage(oResponse.Data[0].Url);
finally
oRequest.Free;
end;