AI retouches selected object areas from a source image and mask, improving material texture, line structure, and product details while optionally preserving specified regions. It is suitable for ecommerce product images, accessories, bags, transparent objects, metal objects, and other refined product retouching scenarios, with async and sync request modes.
The result image URL is generally valid for 1 hour. Please download and store it promptly.
Authentication
Every API request must include your API Key in the X-API-KEY request header. Send it with each request exactly as shown in the examples and parameter descriptions.
X-API-KEY: YOUR_API_KEY Create an object retouching task
/api/tasks/visual/retouching-collection Body Parameters
image_url string optional Image download URL. Optional, but one of image_file or image_url is required. Supports HTTP and OSS URLs, up to 512 characters, with a 10-second download timeout. If both image_file and image_url are provided, image_file takes priority.
image_file file optional Image file as binary data. Optional, but one of image_file or image_url is required. It takes priority over image_url.
mask_url string optional Mask image download URL for the subject to retouch. Optional, but one of mask_file or mask_url is required. Supports HTTP and OSS URLs, up to 512 characters, with a 10-second download timeout. If both mask_file and mask_url are provided, mask_file takes priority.
mask_file file optional Mask image file for the subject to retouch. Optional, but one of mask_file or mask_url is required. It takes priority over mask_url.
Images must match the source size and resolution; see Guidelines and Limits #4.
retain_mask_url string optional Download URL of the mask image for areas whose original features should be retained, up to 512 characters. Provide either retain_mask_url or retain_mask_file; both are optional. If empty, the whole retouch subject is processed.
retain_mask_file file optional Mask image file for areas whose original features should be retained. Provide either retain_mask_file or retain_mask_url; both are optional, and retain_mask_file takes priority. If empty, the whole retouch subject is processed.
Images must match the source size and resolution; see Guidelines and Limits #4.
sync number optional Whether to wait for the result and return it immediately. Use 0 to return a task_id asynchronously, then fetch the result later with the task_id. Use 1 to wait and return the result synchronously.
retouch_strength number optional Material strength, from 0 to 100. Default is 37. A higher value changes the material more. Only effective in the normal model.
line_strength number optional Line strength, from 0 to 100. Default is 60. A higher value applies stronger line constraints. Only effective in the normal model.
type number optional Retouch type. 1 = normal-general; 2 = advanced-general; 3 = advanced-transparent; 4 = advanced-metal; 5 = advanced-jewelry/accessories; 6 = advanced-bags. Default is 1.
Return Parameters
status number HTTP response status code. 200 means the HTTP request succeeded, not necessarily that object retouching succeeded. See Status Code Definitions.
message string API response message. Usually success for a successful request.
data.task_id string Async object retouching task ID returned after the task is created. Use it to query the result later.
status number HTTP response status code. 200 means the HTTP request succeeded, not necessarily that object retouching succeeded. See Status Code Definitions.
message string API response message.
data.task_id string Object retouching task ID.
data.created_at string Task creation timestamp.
data.processed_at string Timestamp when processing started.
data.completed_at string Task completion timestamp.
data.image string Object retouching result image URL or Base64 data. The URL is valid for 1 hour.
data.return_type number Result return type.
data.type number Retouch type used for the task.
data.progress number Task progress. 100 means processing is complete.
data.state number Task status code. 1 means completed, greater than 1 means processing, and less than 0 means failed. See Status Code Definitions.
data.time_elapsed string Processing time.
data.state_detail string Detailed task state.
Query object retouching result
/api/tasks/visual/retouching-collection/{task_id} Path Parameters
task_id string required Object retouching task ID returned after creating an async task. Use it to query the processing result.
Return Parameters
status number HTTP response status code. 200 means the HTTP request succeeded, not necessarily that object retouching succeeded. See Status Code Definitions.
message string API response message.
data.task_id string Object retouching task ID.
data.created_at string Task creation timestamp.
data.processed_at string Timestamp when processing started.
data.completed_at string Task completion timestamp.
data.image string Object retouching result image URL or Base64 data. The URL is valid for 1 hour.
data.return_type number Result return type.
data.type number Retouch type used for the task.
data.progress number Task progress. 100 means processing is complete.
data.state number Task status code. 1 means completed, greater than 1 means processing, and less than 0 means failed. See Status Code Definitions.
data.time_elapsed string Processing time.
data.state_detail string Detailed task state.
Guidelines and Limits
-
The result image URL is generally valid for 1 hour. Please download and store it promptly.
-
HTTP status 200 indicates that the HTTP request succeeded, not that object retouching succeeded. See Status Code Definitions for details.
-
When passing URLs as parameters, follow URL encoding standards to prevent parameter parsing confusion.
-
The image and mask must have the same dimensions and resolution. If a retain_mask image is provided, all three images must be consistent.
Original image Retouch subject mask Retain feature mask Result image
-
Uploaded images must meet the following format, resolution, and file size limits.
Format Resolution Size jpg, jpeg, bmp, png, webp, tiff, bitmap Up to 4096 x 4096 Less than 30MB
# Object Retouching API
AI retouches selected object areas from a source image and mask, improving material texture, line structure, and product details while optionally preserving specified regions. It is suitable for ecommerce product images, accessories, bags, transparent objects, metal objects, and other refined product retouching scenarios. The API supports asynchronous and synchronous request modes.
> Note: Every result image URL is generally valid for 1 hour. Download and store it promptly.
## Base URL
```
https://techhk.aoscdn.com
```
## Authentication
Every request must include your API key in the `X-API-KEY` request header:
```http
X-API-KEY: YOUR_API_KEY
```
Get or manage your API key from [API Key](https://picwish.com/my-account?subRoute=api-key).
## Request modes
The mode is controlled by the `sync` body parameter:
- Asynchronous (`sync=0`): the create request returns `data.task_id`, then you poll the query endpoint until processing finishes.
- Synchronous (`sync=1`): the create request waits for processing to finish and returns the result directly.
## Source and mask images
The request needs one source image and one retouch mask:
- `image_url` or `image_file` is required. If both are present, the file has higher priority.
- `mask_url` or `mask_file` is required. If both are present, the file has higher priority.
- `retain_mask_url` or `retain_mask_file` is optional. Use it to protect feature areas from being changed.
The source image, mask image, and retain mask image must have the same dimensions and resolution.
## Endpoints
| Purpose | Method | Path |
| --- | --- | --- |
| Create an object retouching task | POST | /api/tasks/visual/retouching-collection |
| Query a task result (async) | GET | /api/tasks/visual/retouching-collection/{task_id} |
## Create an object retouching task
`POST /api/tasks/visual/retouching-collection`
Content-Type: `multipart/form-data`
### Body parameters
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| image_url | string | one of image_url / image_file | Image download URL. Supports HTTP and OSS URLs, up to 512 characters, with a 10-second download timeout. If both image_file and image_url are provided, image_file takes priority. |
| image_file | file | one of image_url / image_file | Image file uploaded as multipart binary data. It takes priority over image_url. |
| mask_url | string | one of mask_url / mask_file | Mask image download URL for the subject to retouch. Supports HTTP and OSS URLs, up to 512 characters, with a 10-second download timeout. If both mask_file and mask_url are provided, mask_file takes priority. |
| mask_file | file | one of mask_url / mask_file | Mask image file for the subject to retouch. It takes priority over mask_url. |
| retain_mask_url | string | optional | Download URL of the mask image for areas whose original features should be retained, up to 512 characters. Empty means the full retouch subject is processed. |
| retain_mask_file | file | optional | Mask image file for areas whose original features should be retained. Empty means the full retouch subject is processed. |
| sync | number | optional | 0 = asynchronous; 1 = synchronous. |
| retouch_strength | number | optional | Material strength, from 0 to 100. Default is 37. A higher value changes the material more. Only effective in the normal model. |
| line_strength | number | optional | Line strength, from 0 to 100. Default is 60. A higher value applies stronger line constraints. Only effective in the normal model. |
| type | number | optional | Retouch type. 1 = normal-general; 2 = advanced-general; 3 = advanced-transparent; 4 = advanced-metal; 5 = advanced-jewelry/accessories; 6 = advanced-bags. Default is 1. |
### Return parameters - asynchronous (sync=0)
| Name | Type | Description |
| --- | --- | --- |
| status | number | HTTP-style status code. 200 means the request succeeded, not necessarily that retouching succeeded. See /states. |
| message | string | Response message. Usually "success". |
| data.task_id | string | Task ID. Use it to query the result later. |
### Return parameters - synchronous (sync=1)
| Name | Type | Description |
| --- | --- | --- |
| status | number | HTTP-style status code. 200 means the request succeeded, not necessarily that retouching succeeded. See /states. |
| message | string | Response message. |
| data.task_id | string | Task ID. |
| data.created_at | string | Task creation timestamp. |
| data.processed_at | string | Timestamp when processing started. |
| data.completed_at | string | Task completion timestamp. |
| data.image | string | Object retouching result image URL or Base64 data. The URL is valid for 1 hour. |
| data.return_type | number | Result return type. |
| data.type | number | Retouch type used for the task. |
| data.progress | number | Task progress. 100 means processing is complete. |
| data.state | number | Task state. 1 means completed, greater than 1 means processing, and less than 0 means failed. See /states. |
| data.time_elapsed | string | Processing time. |
| data.state_detail | string | Detailed task state. |
### Examples
Asynchronous, image URL and mask URL:
```bash
curl -k 'https://techhk.aoscdn.com/api/tasks/visual/retouching-collection' \
-H 'X-API-KEY: YOUR_API_KEY' \
-F 'sync=0' \
-F 'image_url=YOUR_IMAGE_URL' \
-F 'mask_url=YOUR_MASK_IMAGE_URL'
```
Asynchronous, image file and mask file upload:
```bash
curl -k 'https://techhk.aoscdn.com/api/tasks/visual/retouching-collection' \
-H 'X-API-KEY: YOUR_API_KEY' \
-F 'sync=0' \
-F 'image_file=@/path/to/image.jpg' \
-F 'mask_file=@/path/to/mask.png'
```
Synchronous (result returned directly):
```bash
curl -k 'https://techhk.aoscdn.com/api/tasks/visual/retouching-collection' \
-H 'X-API-KEY: YOUR_API_KEY' \
-F 'sync=1' \
-F 'image_url=YOUR_IMAGE_URL' \
-F 'mask_url=YOUR_MASK_IMAGE_URL'
```
## Query object retouching result
`GET /api/tasks/visual/retouching-collection/{task_id}`
Use this endpoint in asynchronous mode to poll for the result. We recommend polling once every second and keeping the total polling duration within 3 minutes. Stop polling when `data.state=1` or `data.state<0`.
### Path parameters
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| task_id | string | required | The task ID returned by the create request. |
### Return parameters
| Name | Type | Description |
| --- | --- | --- |
| status | number | HTTP-style status code. 200 means the request succeeded, not necessarily that retouching succeeded. See /states. |
| message | string | Response message. |
| data.task_id | string | Task ID. |
| data.created_at | string | Task creation timestamp. |
| data.processed_at | string | Timestamp when processing started. |
| data.completed_at | string | Task completion timestamp. |
| data.image | string | Object retouching result image URL or Base64 data. The URL is valid for 1 hour. |
| data.return_type | number | Result return type. |
| data.type | number | Retouch type used for the task. |
| data.progress | number | Task progress. 100 means processing is complete. |
| data.state | number | Task state. 1 means completed, greater than 1 means processing, and less than 0 means failed. See /states. |
| data.time_elapsed | string | Processing time. |
| data.state_detail | string | Detailed task state. |
### Example
```bash
curl -k 'https://techhk.aoscdn.com/api/tasks/visual/retouching-collection/{task_id}' \
-H 'X-API-KEY: YOUR_API_KEY'
```
## Recommended asynchronous flow
1. POST to /api/tasks/visual/retouching-collection with `sync=0`, one source image, and one mask image.
2. Read `data.task_id` from the create response.
3. GET /api/tasks/visual/retouching-collection/{task_id} every 1 second.
4. Stop polling when `data.state=1` or `data.state<0`.
5. Download `data.image` within 1 hour after processing succeeds.
## Guidelines and Limits
- The result image URL is generally valid for **1 hour**. Please download and store it promptly.
- HTTP status 200 indicates that the HTTP request succeeded, not that object retouching succeeded. See /states for details.
- When passing URLs as parameters, follow URL encoding standards to prevent parameter parsing confusion.
- The **image** and **mask** must have the same dimensions and resolution. If a **retain_mask** image is provided, all three images must be consistent.
- The image examples below show how the original image, retouch subject mask, retain feature mask, and result image correspond to each other.
| Original image | Retouch subject mask | Retain feature mask | Result image |
| --- | --- | --- | --- |
| [](https://picwish.comhttps://cfcdn.apowersoft.info/astro/picwish/_astro/original-image.B9RHMs0f.png) | [](https://picwish.comhttps://cfcdn.apowersoft.info/astro/picwish/_astro/retouch-subject-mask.B3oBIbuv.png) | [](https://picwish.comhttps://cfcdn.apowersoft.info/astro/picwish/_astro/retain-feature-mask.DtZ4jUGV.png) | [](https://picwish.comhttps://cfcdn.apowersoft.info/astro/picwish/_astro/retouched-result.DMUuuqDG.png) |
- Uploaded images must meet the following format, resolution, and file size limits.
| Format | Resolution | Size |
| --- | --- | --- |
| jpg, jpeg, bmp, png, webp, tiff, bitmap | Up to 4096 x 4096 | Less than 30MB |
## Status codes
Determine success by combining the HTTP response status code (`status`) with the task status code (`data.state`).
### HTTP response status codes
| Code | Meaning |
| --- | --- |
| 200 | The request is successful. |
| 400 | Wrong parameter passed by the client. Check whether a parameter is missing or has an incorrect value. |
| 401 | Unauthorized API key. Check that X-API-KEY is correct and the service is enabled. |
| 404 | The requested URL or resource does not exist. Check that the URL or task_id is correct. |
| 413 | The uploaded file exceeds the allowed size. Refer to the supported image size. |
| 429 | Request frequency exceeds the QPS limit (default QPS is 2). Slow down or contact us to raise your QPS. |
| 500 | Server-side exception. Please contact support. |
### Task status codes (data.state)
1 = succeeded; greater than 1 = still processing; less than 0 = failed.
| Code | Meaning |
| --- | --- |
| -17 | Processing failed because the prompt is invalid. |
| -16 | Processing failed because a third-party review detected prohibited content. |
| -15 | Processing failed due to insufficient resources. |
| -14 | Processing failed because the input image content does not meet the requirements. |
| -13 | Processing failed because the task was canceled due to an exception. |
| -11 | Processing failed because the result is empty. |
| -10 | Processing failed because internal review detected prohibited content. |
| -9 | Processing failed because the internal program failed during loop processing. |
| -8 | Processing timed out. The maximum processing time is 180 seconds. |
| -7 | Invalid image file (e.g. corrupted image or incorrect format). |
| -5 | The image_url image exceeds the size limit (30MB). |
| -3 | The server failed to download your file. Check that the source image URL is available. |
| -2 | Processing completed, but uploading the result to OSS failed. |
| -1 | Processing failed. |
| 0 | Queued. The task is waiting in the queue. |
| 1 | Completed. Processing succeeded. |
| 2 | Preparing. |
| 3 | Waiting. |
| 4 | Processing in progress. |
| 5 | Internally publishing the result. |
| 6 | Processing. Internal loop processing is in progress. |