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 | Mandatory | Description |
|---|---|---|---|
| crop | Boolean | No | Crop the result to the subject's bounding box. Default: false. |
| image | Object | Yes | Image source object. Contains url and/or base64; see nested fields. |
| image.url | String | No | Public http(s) URL of the image. Must be ≤ 20 MB; private and internal addresses are refused. |
| image.base64 | String | No | The image as base64, including a data: URI if desired. Must be ≤ 20 MB decoded. |
| format | ENUM | No | 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 | No | Pixels kept around the subject when crop is true. Default: 0; minimum: 0, maximum: 1000. |
| quality | ENUM | No | Output quality. Allowed values: best, fast. Default: best. best prioritizes detail; fast is suitable for previews. |
| max_size | Integer | No | 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 | Mandatory | Description |
|---|---|---|---|
| bbox | Object | Yes | Subject bounding box in the original image, or null when nothing was found. |
| bbox.x | Integer | Yes (if bbox is not null) | X coordinate of the bounding box. |
| bbox.y | Integer | Yes (if bbox is not null) | Y coordinate of the bounding box. |
| bbox.width | Integer | Yes (if bbox is not null) | Width of the bounding box. |
| bbox.height | Integer | Yes (if bbox is not null) | Height of the bounding box. |
| bytes | Integer | Yes | Size of the output in bytes. |
| width | Integer | Yes | Output width in pixels. |
| format | String | Yes | Encoding of data_uri. |
| height | Integer | Yes | Output height in pixels. |
| quality | ENUM | Yes | Quality used for the result. Allowed values: best, fast. |
| data_uri | String | Yes | data:<media_type>;base64,… |
| media_type | String | Yes | Media type of the returned data URI. |
| foreground_ratio | Number | Yes | Share of the original image covered by the subject, from 0 to 1. |


