Edit an image
Change one thing on an image and keep the rest, on the whole image or an area, or erase what an area covers.
POST/v2/editsReturns 202 straight away with the job and what it charged. Poll GET /v2/jobs/{id} for the result; a job that fails is refunded. An edit is $0.099 and an erase $0.099, whichever engine made the image.
Choosing the area
- A
region: a box or a polygon in fractions of the image, drawn at the image’s own size, so it means the same on any resolution. - A
mask: a black-and-white PNG the size of the image, white where to change, sent like the image (a file, a link or base64). - Neither: an edit changes the whole image. An erase always needs an area.
Headers
AuthorizationstringRequiredBearer mk_live_…: your API key. See Authentication.Content-TypestringRequiredapplication/json, ormultipart/form-datato send a file.Idempotency-Keystring- Your own key, 1 to 255 visible ASCII characters. A retry with the same key and request within 24 hours returns the first answer instead of running again.
Body
kindstringDefaultediteditchanges what the prompt names.eraseremoves what the area covers and fills in the background.editerasepromptstring- What to change, in plain words. Required for an edit; an erase takes none.
imagestring- The JPEG, PNG or WebP to work on, up to 15 MB: a public
https://link we fetch, adata:image/…;base64,URI, or bare base64. With multipart form data, attach the file itself (-F [email protected]). Send one ofimageorjob_id. job_idstring- A finished job of yours: work on its output without downloading it first.
enginestringDefaultv4.6-ultra- The engine whose edit runs. An erase takes none.
modestringDefaultexterior- What the image shows. An erase takes none.
exteriorinteriormasterplanplanlandscapeproducttext-to-render referencesstring | object[]- Images whose style, materials, mood or geometry to follow, up to 15. Each is just the image (a link or base64, or with multipart a
referencesfile part, repeated), or an object,{ image | job_id, mode }, that also sets itsmode. How many an engine takes iscapabilities.max_referencesin GET /v2/engines.Fields of each item (3)
imagestring- The reference image: a public
https://link we fetch, adata:image/…;base64,URI, or bare base64. With multipart form data, attach the file itself. Send one ofimageorjob_id. job_idstring- The reference image, as a finished job of yours.
modestringDefaultstyle- What to take from it: its
style, amaterial, theatmosphere, thecoloror thegeometry.autolets the engine decide.autostylematerialatmospherecolorgeometry
regionobject- The area to change, as a
boxor apolygon, in 0–1 fractions of the image from its top-left corner. Leave it out to edit the whole image.Fields (2)
boxobject- A rectangle.
Fields (4)
xnumberRequired- Its left edge, 0–1 of the image’s width.
ynumberRequired- Its top edge, 0–1 of the image’s height.
widthnumberRequired- Its width, 0–1 of the image’s width.
heightnumberRequired- Its height, 0–1 of the image’s height.
polygonnumber[][]- Any outline, as
[[x, y], …]points in the same 0–1 fractions.
maskstring- The area as a mask: a PNG the size of the image, white where to change, black where to keep. a public
https://link we fetch, adata:image/…;base64,URI, or bare base64. With multipart form data, attach the file itself. Sendregionormask, not both. webhook_urlstring- A public
https://URL to send this job’s settle event to, signed like every webhook, on top of your account’s endpoints.
Response
On success (202): Started. Poll GET /v2/jobs/{id} for the result. The JSON is { "success": true, "data": … }, and inside data:
idstringRequired- The job. Read it at GET /v2/jobs/{id}.
statusstringRequired- The job’s status when it was accepted, usually
queued.queuedprocessingsucceededfailedcanceled charged_usdnumberRequired- What this call charged, in US dollars. A job that fails is refunded.
replayedbooleanRequired- True when this is the stored answer to an earlier identical request with the same
Idempotency-Key: nothing ran or was charged again. See Idempotency. notesstring[]Required- What was accepted but not applied, in plain words: a setting that does not fit the engine, a seed it does not take. Empty when everything applied.
Response headers (5)
X-Request-Idstring- This request, for support and the console log.
RateLimit-Limitinteger- Requests this key may make per minute.
RateLimit-Remaininginteger- Requests left in the current minute.
RateLimit-Resetinteger- Seconds until the current minute resets.
Idempotent-Replayedstring- Present, as
true, when this is the stored answer to an earlier request.
Status codes
- 202
- Started. Poll GET /v2/jobs/{id} for the result.
- 401
- The API key is missing, malformed, unknown or revoked.
- 402
- The balance does not cover this call.
- 409
- The Idempotency-Key was reused for a different request, or is still in progress.
- 429
- A limit was reached: requests per minute, or a daily or concurrency limit.
- Other
- Any other error, in the same envelope.
Every error answers { "success": false, "error": { "code", "message" } }. What each code means, and what to do, is on Errors.