Skip to main content
POST
/
api
/
portrait
/
editing
/
try-on-clothes-pro
Try on Clothes Pro
curl --request POST \
  --url https://www.ailabapi.com/api/portrait/editing/try-on-clothes-pro \
  --header 'Content-Type: multipart/form-data' \
  --header 'ailabapi-api-key: <api-key>' \
  --form task_type=async \
  --form resolution=-1 \
  --form restore_face=true \
  --form person_image=@example-file \
  --form top_garment=@example-file \
  --form bottom_garment=@example-file
{
  "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": ""
}

Request

  • URL: https://www.ailabapi.com/api/portrait/editing/try-on-clothes-pro
  • Method: POST
  • Content-Type: multipart/form-data

Image requirements

Portrait

  • Image format: JPG JPEG PNG BMP
  • Image size: No more than 5 MB.
  • Image resolution: Larger than 150x150px, smaller 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
Correct Example ImageCorrect Example Image
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
Incorrect Example Image
Incorrect Example Image
Incorrect Example Image
Incorrect Example Image

Clothing

  • Image format: JPG JPEG PNG BMP
  • Image size: No more than 5 MB.
  • Image resolution: Larger than 150x150px, smaller 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
Correct Example ImageCorrect Example ImageCorrect Example ImageCorrect Example Image
Correct Example ImageCorrect Example ImageCorrect Example ImageCorrect Example Image
Incorrect Example
Multiple Clothing Items
Non-Front View
Folded Obstruction
Clothing Wrinkles
Incorrect Example Image
Incorrect Example Image
Incorrect Example Image
Incorrect Example Image

Headers

FieldRequiredTypeDescription
ailabapi-api-keyYESstringApplication API KEY. Get API KEY

Body

FieldRequiredTypeScopeDefaultDescription
task_typeYESstringasync“async: Asynchronous tasks.
person_imageYESfilePortrait Image.
top_garmentYESfileUpper Body Clothing Image.
bottom_garmentNOfileIf no lower body clothing image is provided, the lower body clothing effect will be randomly generated., If lower body clothing is not needed (e.g., when the upper body garment is a dress), this value should be left empty.
resolutionNOinteger-1, 1024, 1280-1-1`: Original image resolution.`, 1024: 576x1024px., “1280: 720x1280px.
restore_faceNObooleantrue, falsetruetrue`: Keep the model’s original face.`, false: Regenerate the model’s face.

Response

Response Field Handling Flow
  1. Handle Public Response Fields Parse and validate the Public Response Fields, checking the status code or response message to ensure the request is successful and error-free.
  2. Handle Business Response Fields If the Public Response Fields are valid and error-free, proceed with processing the business logic in the Business Response Fields.

Public Response Fields

Viewing Public Response Fields and Error Codes

Business Response Fields

FieldTypeScopeDescription
task_typestringasyncTask Type. “async: Asynchronous tasks.
task_idstringAsynchronous task ID.
Please use this field when calling the Querying Async Task Results API.

Response Example

{
  "request_id":     "",
  "log_id":         "",
  "error_code":     0,
  "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

Response Field Handling Flow
  1. Handle Public Response Fields Parse and validate the Public Response Fields, checking the status code or response message to ensure the request is successful and error-free.
  2. Handle Business Response Fields If the Public Response Fields are valid and error-free, proceed with processing the business logic in the Business Response Fields.

Public Response Fields

Viewing Public Response Fields and Error Codes

Business Response Fields

FieldTypeScopeDescription
task_statusinteger0, 1, 2Asynchronous task status. 0`: The task is queued.` 1: Asynchronous processing. “2: Processing was successful.
outputobject
+image_urlstringResult image URL.
usageobject
+image_countintegerNumber of generated images.
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.

Response Example

{
  "error_code":     0,
  "error_msg":      "",
  "error_detail":   {
    "status_code":  200,
    "code":         "",
    "code_message": "",
    "message":      ""
  },
  "task_status":    0,
  "output":         {
    "image_url": ""
  },
  "usage":          {
    "image_count": 0
  }
}

Sample Code

Authorizations

ailabapi-api-key
string
header
required

API Key for authentication

Body

multipart/form-data
task_type
string

Task Type. <li>async: Asynchronous tasks.</li>

Example:

"async"

person_image
file

Portrait image.

top_garment
file

Upper Body Clothing Image.

resolution
number

Output Image Resolution. If you need to call Try on Clothes Refiner in the future, select -1. <li>-1: Original image resolution.</li> <li>1024: 576x1024px.</li> <li>1280: 720x1280px.</li>

Example:

"-1"

restore_face
boolean

Whether to Keep the Model’s Face. If you need to call Try on Clothes Refiner in the future, select true. <li>true: Keep the model’s original face.</li> <li>false: Regenerate the model’s face.</li>

Example:

"true"

bottom_garment
file

Lower Body Clothing Image. <li>If no lower body clothing image is provided, the lower body clothing effect will be randomly generated.</li> <li>If lower body clothing is not needed (e.g., when the upper body garment is a dress), this value should be left empty.</li>

Response

200 - application/json

Success

The response is of type object.