AILabTools API - Try on Clothes - API
If the Try on Clothes does not fully meet your expectations, you might consider using the Try on Clothes Refiner to enhance its results, or alternatively, the Try on Clothes Pro for a more advanced option.
Request
- URL:
https://www.ailabapi.com/api/portrait/editing/try-on-clothes
- Method:
POST
- Content-Type:
multipart/form-data
Image requirements
Portrait
- Image format:
JPG
JPEG
PNG
- Image size: No more than 3 MB.
- Image resolution: Less than 4096x4096px.
- Pose requirements: full-body front view with hands fully visible. Arm positioning should avoid wide openings, crossing, or other exaggerated gestures.
Correct Example
Incorrect Example
Non-Front Full-Body Shot (Avoid uploading side views, sitting poses, lying down poses, or half-body photos.) Group Photo Clothing Obstruction (Avoid holding items, bags, etc.) Lighting Too Dark / Blurry |
Clothing
- Image format:
JPG
JPEG
PNG
- Image size: No more than 3 MB.
- Image resolution: Less than 4096x4096px.
- Pose requirements: full-body front view with hands fully visible. Arm positioning should avoid wide openings, crossing, or other exaggerated gestures.
- Clothing Category: Minimal Patterns & Prints. Examples include jeans, polo shirts, yoga wear, dresses, suits, T-shirts, etc.
- Upload a clear, well-aligned flat-lay image of the clothing.
- Background should be simple, clean, and well-lit.
- Only a single item of clothing should be displayed in the image.
- No layering with other clothing items.
- The clothing item should occupy as much of the image frame as possible.
Correct Example
Incorrect Example
Multiple Clothing Items Non-Front View Folded Obstruction Clothing Wrinkles |
Header
Field | Required | Type | Description |
---|---|---|---|
ailabapi-api-key | YES | string | Application API KEY. Get API KEY |
Body
Field | Required | Type | Scope | Description |
---|---|---|---|---|
task_type | YES | string | async | Task Type. async : Asynchronous tasks. |
person_image | YES | file | Portrait image. | |
coarse_image | YES | file | Clothing image. | |
clothes_type | YES | string | upper_body lower_body full_body | Clothing Types. upper_body : Upper body clothing.lower_body : Lower body clothing.full_body : Full body clothing. |
Response
-
Handle
Public Parameters
:First, parse and validate the
Public Parameters
, checking the status code or response message to ensure the request is successful and no errors are present. -
Handle
Business Parameters
:If the public parameters are valid and no exceptions are found, proceed to process the business logic in the
Business Parameters
.
Public Parameters
Viewing Public Parameters and Error CodesBusiness Parameters
Field | Type | Scope | Description |
---|---|---|---|
task_type | string | async | Task Type. async : Asynchronous tasks. |
task_id | string | Asynchronous task ID. Please use this field when calling the Querying Async Task Results API. |
Example
{
"request_id": "",
"log_id": "",
"error_code": 0,
"error_code_str": "",
"error_msg": "",
"error_detail": {
"status_code": 200,
"code": "",
"code_message": "",
"message": ""
},
"task_type": "",
"task_id": ""
}
This API is asynchronous, please keep task_id
and call Querying Async Task Results
to get the final results.
Asynchronous task results are valid for 24 hours. It is recommended that asynchronous task results be queried every 5 seconds.
Querying Async Task Results
Response
-
Handle
Public Parameters
:First, parse and validate the
Public Parameters
, checking the status code or response message to ensure the request is successful and no errors are present. -
Handle
Business Parameters
:If the public parameters are valid and no exceptions are found, proceed to process the business logic in the
Business Parameters
.
Public Parameters
Viewing Public Parameters and Error CodesBusiness Parameters
Field | Type | Scope | Description |
---|---|---|---|
task_status | integer | 0 1 2 | Asynchronous task status. 0 : The task is queued.1 : Asynchronous processing.2 : Processing was successful. |
data | object | ||
+image | string | Result image URL. |
The URL address is a temporary address, valid for 24 hours, and will not be accessible after it expires. If you need to save the file for a long time or permanently, please visit the URL address within 24 hours and download the file to your own storage space.
Example
{
"error_code": 0,
"error_code_str": "",
"error_msg": "",
"error_detail": {
"status_code": 200,
"code": "",
"code_message": "",
"message": ""
},
"task_status": 0,
"data": {
"image": ""
}
}