Theme
Edit gpt-image-1
POST
https://www.kkiai.com/v1/images/edits
Given a prompt, the model will return one or more predicted completions, and can also return the probability 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 Name | Type | Required | Description | Example |
|---|---|---|---|---|
Accept | string | Required | application/json | |
Authorization | string | Optional | Bearer {{YOUR_API_KEY}} |
Body Parameters (multipart/form-data)
| Parameter Name | Type | Required | Description |
|---|---|---|---|
image | file | Required | The 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. |
prompt | string | Required | A text description of the desired image. Maximum length is 1000 characters for dall-e-2 and 32000 characters for gpt-image-1. |
mask | string | Optional | An additional image whose fully transparent areas (e.g., alpha value of zero) indicate where the 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 the same dimensions as the image. |
model | string | Optional | The model to use for generating images. Only gpt-image-1, gpt-image-1-all, flux-kontext-pro, flux-kontext-max. |
n | string | Optional | The number of images to generate. Must be between 1 and 10. |
quality | string | Optional | The quality of the generated image. Only gpt-image-1 supports high, medium, and low quality. dall-e-2 only supports standard quality. Defaults to auto. |
response_format | string | Optional | The format in which the generated image is 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; do not use this parameter. |
size | string | Optional | The size of the generated image. 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. |
background | string | Optional | Allows 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. |
moderation | string | Optional | Controls 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\\example.png"' \
--form 'image=@"C:\\Users\\Administrator\\Desktop\\scene2.png"' \
--form 'prompt="Merge them in one image"' \
--form 'model="gpt-image-1"' \
--form 'n="1"' \
--form 'size="1024x1536"'Response
🟢 200 OK
Response Body
| Parameter Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | |
object | string | Required | |
created | integer | Required | |
choices | array[object] | Required | |
└ index | integer | Optional | |
└ message | object | Optional | |
└ finish_reason | string | Optional | |
usage | object | Required | |
└ prompt_tokens | integer | Required | |
└ completion_tokens | integer | Required | |
└ total_tokens | integer | Required |
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
}
}