OpenAI
Create image edit
Use POST /v1/images/edits in CometAPI to edit images with multipart uploads, masks, GPT image models, and encoded image output controls.
POST
/
v1
/
images
/
edits
curl https://api.cometapi.com/v1/images/edits \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F image=@cat.jpg \
-F prompt="Add a small red bow tie on the cat" \
-F model=gpt-image-2 \
-F quality=low{
"created": 1781075000,
"background": "opaque",
"output_format": "png",
"quality": "low",
"size": "1024x1024",
"usage": {
"input_tokens": 784,
"input_tokens_details": {
"image_tokens": 768,
"text_tokens": 16
},
"output_tokens": 196,
"output_tokens_details": {
"image_tokens": 196,
"text_tokens": 0
},
"total_tokens": 980
},
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}Use this route to edit existing images with OpenAI-compatible multipart uploads on CometAPI.
Use this route when
- You already have a source image and want a prompt-driven edit
- You may need a mask for targeted changes
- You can handle multipart file upload instead of a plain JSON request
Safe first request
- Start with one PNG or JPG file
- Skip the mask until the base edit flow works
- Use
model: "gpt-image-2"for GPT image edit requests on this route - Use one short instruction that asks for one visible change
- Read the edited result from
data[0].b64_json - Set
output_format: "jpeg"when you want a JPEG payload - Expect longer latency than plain image generation
Model behavior
- GPT image edit models on this route return inline base64 image data
output_formatcontrols the encoded image type insideb64_jsonresponse_formatonly matters when a model supports URL outputqwen-image-editfollows provider-specific edit behavior behind the same CometAPI route
Body
multipart/form-data
Response
200 - application/json
Edited image result.
Last modified on June 23, 2026
⌘I
curl https://api.cometapi.com/v1/images/edits \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F image=@cat.jpg \
-F prompt="Add a small red bow tie on the cat" \
-F model=gpt-image-2 \
-F quality=low{
"created": 1781075000,
"background": "opaque",
"output_format": "png",
"quality": "low",
"size": "1024x1024",
"usage": {
"input_tokens": 784,
"input_tokens_details": {
"image_tokens": 768,
"text_tokens": 16
},
"output_tokens": 196,
"output_tokens_details": {
"image_tokens": 196,
"text_tokens": 0
},
"total_tokens": 980
},
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}