image-edit.v1

docs/capabilities/image-edit.v1.md · wiki index

image-edit.v1

Status: v1. A published shape is frozen by spec.md section 20.1. Capability key: image-edit Route: POST /image/edit

Parts in

kindrolerequiredmeaning
imagesourceyes, exactly onethe image that the job changes.
imagemasknothe area that the job may change. At most one.
textinstructionyes, exactly onewhat to change in the source.

Parameters

The plugin validates these. A parameter that is not in this table is ignored, not an error (R26). A default of catalogue means the model entry in the catalogue gives the value. A default of none means the plugin chooses.

nametypedefaultmeaning
stepsuintcataloguethe number of denoise steps
guidancefloatcataloguehow closely the job follows the instruction
strengthfloatcataloguehow far the job moves from the source
seeduintnonea fixed seed for a repeatable job

There is no size parameter. The output size is the source size, always.

Channels out

channelmimepayload
imageimage/pngone whole image
progressapplication/json{stage, pct} during generation

Terminal metadata

done.meta is vocabulary-defined. The core stores it and never reads it. done without meta means {}.

keytypemeaning
modelstringthe served name that ran the job
widthuintthe width of the produced image, in pixels
heightuintthe height of the produced image, in pixels

These keys are present when outcome is completed. They are absent when the outcome is cancelled or expired.

Request

POST /image/edit
{
  "model": "<served-name>",
  "input": [
    {"kind": "image", "role": "source", "mime": "image/png", "inline": "<png bytes>"},
    {"kind": "image", "role": "mask", "mime": "image/png", "inline": "<png bytes>"},
    {"kind": "text", "role": "instruction", "text": "replace the sky with a storm"}
  ],
  "params": {"steps": 28, "guidance": 4.5, "strength": 0.8, "seed": 7},
  "stream": true
}

Response, no stream

{"job": "019...", "outcome": "completed",
 "image": {"mime": "image/png", "inline": "<png bytes>"},
 "usage": {"images": 1, "pixels": 1048576},
 "meta": {"model": "<served-name>", "width": 1024, "height": 1024}}

Stream

Image bytes travel in the done frame. The stream carries progress only.

event  ch=progress {"stage": "denoise", "pct": 0.4}
event  ch=progress {"stage": "denoise", "pct": 0.9}
done   outcome=completed usage={"images":1,"pixels":1048576}
       artifacts=[{"channel":"image","mime":"image/png","inline":"<png bytes>"}]
       meta={"model":"<served-name>","width":1024,"height":1024}

Rules

  1. Exactly one image part with role source is required. Zero or more than one is invalid_part.
  2. Exactly one text part with role instruction is required. A missing part or a second one is invalid_part.
  3. At most one image part carries role mask. A second mask is invalid_part.
  4. An image part with a role other than source or mask is invalid_part.
  5. A text part with a role other than instruction is invalid_part.
  6. An audio, video, tokens, or json part is invalid_part.
  7. A mask has the pixel size of the source. Any other size is invalid_part.
  8. One job produces exactly one image. A job with zero or two image artifacts is failed.
  9. The mime of the image artifact is always image/png. It is a constant, not a parameter.
  10. An event frame never carries image bytes. The image is one artifact in done.
  11. meta.width and meta.height equal the pixel size of the source image.
  12. The job changes no pixel outside the mask area, when a mask is present.
  13. strength is inside the range that the plugin declares. A value outside it gives a refusal that names strength.
  14. usage.images is 1 when the outcome is completed. It counts one image.
  15. usage.pixels equals meta.width multiplied by meta.height.
  16. A progress event carries {stage, pct}. pct stays between 0 and 1 and never decreases.
  17. Two jobs with the same seed and the same input make the same image bytes.
  18. seed is absent from the terminal metadata. The plugin never reports it.
  19. No event follows a cancel. The terminal frame is done with outcome = cancelled.
  20. The plugin emits image and progress. It emits no other channel for this job.