Edit and repaint specific areas of existing images generated by previous tasks.

Endpoint

POST https://api.legnext.ai/api/v1/edit

Headers

HeaderTypeRequiredDescription
x-api-keystringYesYour API key

Request Body

ParameterTypeRequiredDescription
jobIdstringYesID of the original image generation task
imageNointegerYesImage number to edit (0/1/2/3)
canvasCanvasYesTarget canvas dimensions
imgPosCanvasImgYesImage position relative to canvas
remixPromptstringYesText prompt for the edit
maskMaskNoAreas to repaint on the original image
callbackstringNoCallback URL for task completion notifications

Data Types

Canvas

FieldTypeDescription
widthintegerCanvas width in pixels
heightintegerCanvas height in pixels

CanvasImg

FieldTypeDescription
widthintegerImage width in pixels
heightintegerImage height in pixels
xintegerHorizontal offset from canvas top-left
yintegerVertical offset from canvas top-left

Mask

FieldTypeDescription
areasPolygon[]Polygonal areas to repaint (optional)
urlstringBlack and white mask image URL (optional)

Polygon

FieldTypeDescription
widthintegerImage width in pixels (500-4096)
heightintegerImage height in pixels (500-4096)
pointsinteger[]Polygon coordinates in XYXY format, clockwise from top-left

Example Request

curl -X POST "https://api.legnext.ai/api/v1/edit" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jobId": "c6821434-5e41-408f-b42b-2562306b109c",
    "imageNo": 1,
    "canvas": {
        "width": 1024,
        "height": 1024
    },
    "imgPos": {
        "width": 512,
        "height": 512,
        "x": 256,
        "y": 256
    },
    "remixPrompt": "A beautiful landscape with mountains"
  }'

Response

Returns a task object containing the task information.