Sign in required
Sign inLayer Decomposition API Documentation
The service supports automatic whole-image decomposition and selected-region decomposition through asynchronous tasks. Prepare an image and choose a mode, call submit_task to create a task, then call query_task to retrieve the layers.
Decomposition modes
| Mode | pipeline_type | image_boxes | Use case |
|---|---|---|---|
| Whole-image decomposition | all |
Must be [] |
Let the model decompose the whole image without specifying regions |
| Selected-region decomposition | crop |
Supply 1–20 bounding boxes | Separate objects within regions selected by the user or API client |
Both modes use the same creation endpoint and the existing decomposition rate for the current environment. The mode and boxes must agree: all requires an empty array; crop requires a non-empty array. The official website will automatically select the mode based on whether a frame is drawn.
Request URLs
| Endpoint | Method | URL |
|---|---|---|
| Layer decomposition (object detection) | POST | https://api.research.360.cn/v1/object_detect |
| Layer Decomposition (Create Task) | POST | https://api.research.360.cn/v1/submit_task |
| Layer Decomposition (Query Task) | POST | https://api.research.360.cn/v1/query_task |
Send a JSON request body. Successful responses return task_id, status, output, and other fields directly, without a data wrapper.
Capabilities
| Capability | model | pipeline_type | image_boxes limit | Default steps |
|---|---|---|---|---|
| Layer Decomposition (No Boxes) | reveal_layer |
all |
Empty array [] |
10 |
| Layer Decomposition (With Boxes) | reveal_layer |
crop |
1–20 boxes | 10 |
Common Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| accept | string | Yes | Always application/json |
| Content-Type | string | Yes | Always application/json |
| Authorization | string | Yes | Bearer your_key |
Image Input Requirements
input is an image input array. Submit one image per task using { "type": "input_image", "image_url": "data:image/png;base64,..." }.
Supported image formats are JPG, JPEG, PNG, BMP, and WEBP. Set input[].image_url to an HTTP/HTTPS image URL or a complete Base64 Data URI, such as data:image/png;base64,.... A local file path is not sufficient.
| Field | Type | Required | Description |
|---|---|---|---|
input[].type |
string | Yes | Always input_image |
input[].image_url |
string | Yes | An image URL or a complete Base64 Data URI, such as https://example.com/image.png or data:image/jpeg;base64,... |
Website uploads and image URLs are limited to 10MB. API Key calls accept URLs and Base64 without a product-level image size limit. Gateway request-body limits, read timeouts, and resource safeguards still apply. Base64 increases request size, so keep the encoded request within the gateway limit.
For URL input, provide a readable HTTP/HTTPS link directly to the image. For Base64 input, include the MIME prefix matching the image format and replace the example placeholder with the actual encoding.
Bounding-Box Coordinates
image_boxes Use a two-dimensional array in the format [[x1, y1, x2, y2], [x3, y3, x4, y4]]. Coordinates use the image’s upper-left corner as the origin.x1,y1 is the upper-left point andx2,y2 is the lower-right point.
Selected-region decomposition(crop) 1–20 boxes must be provided, with coordinates in pixel units relative to the original image; the top-left corner coordinates must be non-negative, and the bottom-right corner must have higher coordinates than the top-left. Whole-image decomposition (all) will image_boxes set as []. The server scales boxes proportionally with the original image, resizing its longest side to 1024 pixels. Each scaled box must have a shortest side of at least 8 pixels; otherwise, the request fails.
Input boxes are filtered using an intersection-over-union (IoU) threshold of 0.8, so the returned count or order may differ from the input. output.image_boxes uses original-image coordinates; output.resized_image_boxes uses preprocessed-image coordinates. When returned, output.boxes_mapping_index maps retained boxes to input indices.
1. Layer Decomposition (Create Task)
Submit a layer decomposition task. Once accepted, the service returns task_id, which the client uses to query task status and results.
Request Method
POST /v1/submit_task
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Always reveal_layer for layer decomposition |
request_id |
string | No | A unique request identifier. Supply and save it explicitly, and reuse it when querying the same task. |
input |
object[] | Yes | One image; image_url accepts an HTTP/HTTPS image URL or a complete Base64 Data URI. The format and size limits are listed under Image Input Requirements. |
pipeline_type |
string | Yes | Mode: all decomposes the whole image without boxes; crop decomposes selected regions. See “Decomposition modes”. |
image_boxes |
number[][] | Yes | Use [] for all, or 1–20 original-image pixel boxes [x1, y1, x2, y2] for crop. Floating-point coordinates are supported. Upper-left coordinates must be non-negative, with x2 > x1 and y2 > y1. After resizing the longest side to 1024 pixels, each box must have a shortest side of at least 8 pixels. The server filters boxes by IoU and returns an index mapping. See Bounding Box Requirements. |
seed |
int | No | Defaults to 42. Range: 1 to 0xffffffffffffffff; 0 is invalid. Preserve large-integer precision when serializing JSON. |
steps |
int | No | Defaults to 10 when omitted. Must be a multiple of 10 in [10, 30]: 10, 20, or 30. |
input.image_url Supports HTTP/HTTPS image URLs or complete Base64 Data URIs; see "Image Input Requirements" for format and size rules. The caller must explicitly pass Decomposition modes along with the corresponding image_boxes: Frameless transmission [], framed transmission requires 1–20 coordinate boxes.
Request Example
Layer Decomposition (Create Task: No Boxes)
{
"model": "reveal_layer",
"request_id": "requestId-xxxxxxxx",
"input": [
{
"type": "input_image",
"image_url": "data:image/png;base64,REPLACE_WITH_IMAGE_BASE64"
}
],
"pipeline_type": "all",
"image_boxes": [],
"steps": 10,
"seed": 42
}
Layer Decomposition (Create Task: With Boxes)
{
"model": "reveal_layer",
"request_id": "requestId-xxxxxxxx",
"input": [
{
"type": "input_image",
"image_url": "data:image/png;base64,REPLACE_WITH_IMAGE_BASE64"
}
],
"pipeline_type": "crop",
"image_boxes": [
[
20,
20,
200,
240
]
],
"steps": 10,
"seed": 42
}
Response
| Field | Type | Description |
|---|---|---|
model |
string | Same as the input model, when returned |
timestamp |
int | Response timestamp in milliseconds, when returned |
task_id |
string | The task ID returned by the server; use it unchanged in queries |
request_id |
string | Request identifier, when returned |
status |
string | Usually in_queue when accepted; this does not mean decomposition is complete |
message |
string | Success message or a specific error description |
response_status |
int | 0 indicates a successful request; non-zero values indicate an error, when returned |
output |
object | Usually an empty object at creation; retrieve layer results through the query API |
Response Example
{
"model": "reveal_layer",
"response_status": 0,
"message": "success",
"status": "in_queue",
"task_id": "taskId-xxxxxxxx",
"request_id": "requestId-xxxxxxxx",
"output": {}
}
2. Layer Decomposition (Query Task)
Use task_id to query task status. When complete, output contains separate layers, foreground masks, and processed reference images.
Request Method
POST /v1/query_task
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Always reveal_layer for layer decomposition |
task_id |
string | Yes | The exact task ID returned by the create-task API |
request_id |
string | No | Reuse the identifier supplied when creating this task, including after a refresh. Do not generate a new identifier for each query. |
Request Example
{
"model": "reveal_layer",
"task_id": "taskId-xxxxxxxx",
"request_id": "requestId-xxxxxxxx"
}
Response
| Field | Type | Description |
|---|---|---|
model |
string | Same as the input model, when returned |
timestamp |
int | Response timestamp in milliseconds, when returned |
task_id |
string | Task ID to query |
request_id |
string | Request identifier, when returned |
message |
string | Success message or a specific error description |
response_status |
int | 0 indicates a successful request; non-zero values indicate an error, when returned |
generation_time |
number | Task generation time in seconds, when returned |
remaining_time |
number | Estimated remaining time in seconds, for reference only, when returned |
status |
string | Task status; see the status reference below |
usage |
object | Usage information; successful tasks return actual billable usage in total_tokens |
output |
object | Layer decomposition results. For a missing task, this remains an object with an empty layers_base array. |
billing |
object | Billing information, including settlement status and the charge for this task, when returned |
charge_amount |
string | Actual charge for this task in CNY, when returned |
Task Status
| Status | Description |
|---|---|
done |
Processing is complete; read the results in output |
generating / running |
Processing; continue polling |
in_queue |
Queued; continue polling |
not_found |
Task not found. Check the task ID, account, and selected environment. |
failed / timeout |
The task failed or timed out. See message for details. |
Output Fields
| Field | Type | Description |
|---|---|---|
output.layers_base_count |
int | Number of base layers, matching the length of layers_base. It need not equal the number of boxes. |
output.layers_base |
string[] | HTTPS image URLs for base layers, which may include a background layer |
output.layers_aug |
string[] | HTTPS image URLs for enhanced layers |
output.layers_fg_mask |
string[] | Foreground mask image URLs; the count is determined by the service response |
output.resized_image |
string | URL of the input image after preprocessing and resizing |
output.resized_bbox_image |
string | URL of the preprocessed image with boxes, for checking submitted regions |
output.image_boxes |
number[][] | Boxes in original-image pixels, using the same format as the create-task image_boxes, ordered to match layers_base[1:]. For all, the model detects the boxes. For crop, these are input boxes retained after filtering with an IoU threshold of 0.8. |
output.resized_image_boxes |
number[][] | Boxes in preprocessed-image coordinates, ordered to match layers_base[1:]. Use them with resized_image; do not draw these coordinates directly on the original image. |
output.boxes_mapping_index |
int[] | When returned, item i is the zero-based index of the original input box corresponding to retained box i. Use this mapping to link filtered boxes to submitted boxes. |
Usage Fields
| Field | Type | Description |
|---|---|---|
usage.total_tokens |
int | Actual billable usage returned for a successful task |
usage.prompt_tokens |
int | Auxiliary usage returned by the service. Do not add it to total_tokens for billing. |
Response Example
{
"model": "reveal_layer",
"response_status": 0,
"message": "success",
"status": "done",
"task_id": "taskId-xxxxxxxx",
"request_id": "requestId-xxxxxxxx",
"generation_time": 62,
"remaining_time": 0,
"usage": {
"prompt_tokens": 0,
"total_tokens": 10000
},
"output": {
"layers_base_count": 2,
"layers_base": [
"https://beijing2.xstore.qihu.com/example/background.png",
"https://beijing2.xstore.qihu.com/example/layer.png"
],
"layers_aug": [
"https://beijing2.xstore.qihu.com/example/background_aug.png",
"https://beijing2.xstore.qihu.com/example/layer_aug.png"
],
"layers_fg_mask": [
"https://beijing2.xstore.qihu.com/example/mask.png"
],
"resized_bbox_image": "https://beijing2.xstore.qihu.com/example/boxes.png",
"resized_image": "https://beijing2.xstore.qihu.com/example/input.png",
"image_boxes": [
[
20,
20,
200,
240
]
],
"resized_image_boxes": [
[
16,
16,
160,
192
]
],
"boxes_mapping_index": [
0
]
}
}
Layer decomposition (object detection)
Detects separable objects and returns initial boxes synchronously; this endpoint does not require polling. Adjust the boxes before creating a decomposition task. Detection may miss objects; add boxes manually or use whole-image decomposition when no objects are detected.
Request Method
POST /v1/object_detect
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Always reveal_layer |
request_id |
string | Yes | Unique detection request ID. Reuse the same ID and parameters when retrying to avoid duplicate detection and charges. |
input |
array | Yes | One image. See Image Input Requirements for supported formats and size rules. |
Detection does not require pipeline_type, image_boxes, steps, or seed. The server selects the version, product, and internal credentials for the current environment.
Request Example
{
"model": "reveal_layer",
"request_id": "replace-with-a-unique-detect-request-id",
"input": [
{
"type": "input_image",
"image_url": "data:image/png;base64,REPLACE_WITH_IMAGE_BASE64"
}
]
}
Response
| Field | Type | Description |
|---|---|---|
request_id |
string | Detection request ID |
response_status |
number | 0 indicates success; a non-zero value indicates an error |
message |
string | Result message or detailed error |
output |
object | Detection result |
output.image_boxes |
array | Original-image boxes. Edit them and supply them as image_boxes for selected-region decomposition. |
output.original_bbox_image |
string | URL of the image with detection boxes, when returned |
usage.total_tokens |
number | Actual detection token usage, billed at the detection unit rate |
Boxes use [x1, y1, x2, y2] pixel coordinates. If boxes refer to a resized image, convert them to original-image coordinates before submission. Selected-region tasks accept up to 20 boxes; remove excess detection boxes first.
Response Example
{
"model": "reveal_layer",
"request_id": "replace-with-a-unique-detect-request-id",
"response_status": 0,
"message": "success",
"output": {
"original_bbox_image": "https://beijing2.xstore.qihu.com/example/detected.png",
"image_boxes": [
[
20,
20,
200,
240
]
]
},
"usage": {
"prompt_tokens": 0,
"total_tokens": 100
}
}