About this endpoint
What it does
Generates a subject mask for an input image. The request accepts an image source and optional output controls, and the response returns mask metadata plus either a data URI or PNG-oriented output depending on the requested format.
Request Body
| Parameter | Type | Description |
|---|---|---|
| crop | Boolean | Crop the result to the subject's bounding box. Default: false. |
| image | Object | Image source object. Contains url and/or base64; see nested fields. |
| image.url | String | Public http(s) URL of the image. Must be ≤ 20 MB; private and internal addresses are refused. |
| image.base64 | String | The image as base64, including a data: URI if desired. Must be ≤ 20 MB decoded. |
| format | ENUM | Output format. Allowed values: json, png. Default: json. json returns metadata plus a PNG data URI; png returns the 8-bit grayscale mask. |
| padding | Integer | Pixels kept around the subject when crop is true. Default: 0; minimum: 0, maximum: 1000. |
| quality | ENUM | Output quality. Allowed values: best, fast. Default: best. best prioritizes detail; fast is suitable for previews. |
| max_size | Integer | Longest side of the output in pixels. Default: original size; minimum: 64, maximum: 4096. |
Response
Returns a JSON object with format, media_type, width, height, bytes, data_uri, bbox, foreground_ratio, and quality fields. bbox is either an object with x, y, width, and height, or null when nothing was found.
| Parameter | Type | Description |
|---|---|---|
| bbox | Object | Subject bounding box in the original image, or null when nothing was found. |
| bbox.x | Integer | X coordinate of the bounding box. |
| bbox.y | Integer | Y coordinate of the bounding box. |
| bbox.width | Integer | Width of the bounding box. |
| bbox.height | Integer | Height of the bounding box. |
| bytes | Integer | Size of the output in bytes. |
| width | Integer | Output width in pixels. |
| format | String | Encoding of data_uri. |
| height | Integer | Output height in pixels. |
| quality | ENUM | Quality used for the result. Allowed values: best, fast. |
| data_uri | String | data:<media_type>;base64,… |
| media_type | String | Media type of the returned data URI. |
| foreground_ratio | Number | Share of the original image covered by the subject, from 0 to 1. |


