Skip to main content
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_format controls the encoded image type inside b64_json
  • response_format only matters when a model supports URL output
  • qwen-image-edit follows provider-specific edit behavior behind the same CometAPI route

Authorizations

Authorization
string
header
required

Bearer token authentication. Use your CometAPI key.

Body

multipart/form-data
image
file
required

Source image file. Start with one PNG or JPG input for the simplest flow.

prompt
string
required

Edit instruction describing the change you want.

Example:

"Add a small red ribbon to the paper boat."

model
string
default:gpt-image-2

The image editing model to use. Choose a supported model from the Models page.

mask
file

Optional PNG mask. Transparent areas mark the regions to edit. The mask dimensions must match the source image exactly.

n
string
default:1

Number of edited images to return.

quality
enum<string>

Quality setting for models that support it.

Available options:
high,
medium,
low
response_format
enum<string>

Requested response container when supported by the selected model. GPT image edit models return data[].b64_json; use output_format to choose the encoded image type.

Available options:
url,
b64_json
output_format
string

Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.

Example:

"jpeg"

size
string

Requested output size when supported by the selected model.

Response

200 - application/json

Edited image result.

created
integer
required
usage
object
required
data
object[]
required
background
string

Background mode returned by models that expose it.

output_format
string

Encoded image type returned by GPT image models.

quality
string

Quality level returned by models that expose it.

size
string

Output size returned by models that expose it.