Skip to content

Mask gpt-image-1.5

POST https://www.kkiai.com/v1/images/edits

Given a prompt, this model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.

Create a completion for the provided prompt and parameters

Official documentation: https://platform.openai.com/docs/api-reference/images/createEdit

Request Parameters

Header Parameters

Parameter NameTypeRequiredDescriptionExample
AcceptstringRequiredapplication/json
AuthorizationstringOptionalBearer {{YOUR_API_KEY}}

Body Parameters (multipart/form-data)

Parameter NameTypeRequiredDescription
imagefileRequiredThe image to edit. Must be a supported image file or image array. For gpt-image-1, each image should be a png, webp, or jpg file smaller than 25MB. For dall-e-2, you can only provide one image, and it should be a square png file smaller than 4MB.
promptstringRequiredA text description of the desired image. Maximum length is 1000 characters for dall-e-2 and 32000 characters for gpt-image-1.
maskfileOptionalAn additional image whose fully transparent areas (for example, alpha value of zero) indicate where image should be edited. If multiple images are provided, the mask will be applied to the first image. Must be a valid PNG file, smaller than 4MB, and have the same dimensions as image.
modelstringOptionalThe model to use for generating images. Only gpt-image-1, gpt-image-1-all, flux-kontext-pro, flux-kontext-max.
nstringOptionalThe number of images to generate. Must be between 1 and 10.
qualitystringOptionalThe quality of the generated images. Only gpt-image-1 supports high, medium, and low quality. dall-e-2 only supports standard quality. Defaults to auto.
response_formatstringOptionalThe format in which the generated images are returned. Must be one of url or b64_json. URLs are valid for 60 minutes after image generation. This parameter only applies to dall-e-2, as gpt-image-1 always returns base64-encoded images, please do not use this parameter.
sizestringOptionalThe size of the generated images. For GPT image models, must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default), for dall-e-2 must be one of 256x256, 512x512, or 1024x1024, for dall-e-3 must be one of 1024x1024, 1792x1024, or 1024x1792.
backgroundstringOptionalAllows setting transparency for the background of the generated image. This parameter is only supported in gpt-image-1. Its value must be one of "transparent", "opaque", or "auto" (default). When using "auto", the model will automatically determine the best background for the image.
moderationstringOptionalControls the content moderation level of images generated by gpt-image-1. Can be set to "low" for less restrictive filtering, or "auto" (default).

cURL Example

bash
curl --location --request POST 'https://www.kkiai.com/v1/images/edits' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--form 'image=@"C:\\Users\\Administrator\\Desktop\\sunlit_lounge.png"' \
--form 'prompt="A sunlit indoor lounge area with a pool containing a flamingo"' \
--form 'mask=@"C:\\Users\\Administrator\\Desktop\\mask.png"' \
--form 'model="gpt-image-1.5"' \
--form 'n="1"' \
--form 'size="1024x1024"'

Response

🟢 200 OK

Response Body

Parameter NameTypeRequiredDescription
idstringRequired
objectstringRequired
createdintegerRequired
choicesarray[object]Required
  └ indexintegerOptional
  └ messageobjectOptional
  └ finish_reasonstringOptional
usageobjectRequired
  └ prompt_tokensintegerRequired
  └ completion_tokensintegerRequired
  └ total_tokensintegerRequired

Response Example

json
{
    "id": "chatcmpl-123",
    "object": "chat.completion",
    "created": 1677652288,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n\nHello there, how may I assist you today?"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 12,
        "total_tokens": 21
    }
}