API reference / Smart Brush

Smart Brush

Select a region or object with 1–32 stroke points in original image coordinates. Selection balances model confidence with the painted stroke; it can extend to detected boundaries beyond the brush. Returns a PNG selection mask; the caller applies it to the editor. Uses 1 credit per request.

POST/api/jobs/{id}/segment
Authenticate with X-API-Key. Keep your key on your server; never embed it in a public website.

Request parameters

pointsarrayrequired

Ordered [x, y] stroke coordinates inside the image. Include both ends and sample evenly along the path.

radiusnumber

Brush radius in original-image pixels, greater than zero and at most the longest image edge. Defaults to 2% of the longest edge. Used to rank selection candidates against the painted area.

modestringdefault: erase

Intended editor action. Both modes return the same detected boundary, without an extra erase margin; the caller subtracts or restores the mask.

eraserestore

Response

200 · Success
{
  "binary": "PNG selection mask"
}

Errors use a structured error.code and error.message. See error handling →

Clearcut support