Skip to navigation

Image editing

Edit or combine reference images with a prompt

POST /v1/images/edits takes one or more reference images plus a prompt and returns a new image, to change or combine pictures you already have. The request is multipart/form-data; the response matches image generation: base64 in data[].b64_json, plus usage and cost.

curl https://api-gateway.merge.dev/v1/images/edits \
-H "Authorization: Bearer $MERGE_GATEWAY_API_KEY" \
-F "model=openai/gpt-image-2" \
-F "prompt=Recolor the mug blue and change nothing else" \
-F "image=@product-shot.png"

An edit needs a route listing image in both capabilities.input and capabilities.output; filter by both in the model catalog.

Reference

FieldNotes
modelRequired. A canonical model ID, since @alias/... returns 400 alias_not_supported.
promptRequired
imageRequired. 1 to 16 PNG, JPEG, or WebP files. Repeat the field, or use image[].
maskPNG with alpha. Transparent areas mark where the first image is edited.
n1 to 10
output_compression0 to 100
size, quality, background, input_fidelity, output_format, moderation, response_format, userForwarded to the vendor, which sets the accepted values
vendorPin the execution vendor
customerCustomer UUID to scope the key, budget, and usage to
ErrorCause
400 image_requiredNo image file
400 image_emptyAn uploaded file is empty
400 too_many_imagesMore than 16 images
400 image_too_largeA file over 50 MB
400 uploads_too_largeImages and mask over 100 MB combined
400 image_input_unsupportedThe route can’t take and produce images
400 stream_unsupportedstream=true
400 invalid_customercustomer isn’t a UUID

Reference images bill as image-input tokens at pricing.input_image_per_million, the prompt at the text rate, and the output at the image-output rate. usage.input_tokens_details splits image_tokens from text_tokens.

Next steps