Skip to main content

AILabTools API - Try on Clothes Refiner - API

Request

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

Image requirements

  • 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.

Headers

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

Body

FieldRequiredTypeScopeDescription
task_typeYESstring
  • async
  • Task Type.
  • async: Asynchronous tasks.
  • person_imageYESfileModel image for calling the Try on Clothes API.
    top_garmentYESfileTop clothing image for calling the Try on Clothes API.
    coarse_imageYESfileResult image obtained from calling the Try on Clothes API.
    genderYESstring
  • woman
  • man
  • Gender of the person_image.
  • woman: Female.
  • man: Male.
  • bottom_garmentNOfileBottom clothing image for calling the Try on Clothes API.

    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_typestring
  • async
  • Task 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": ""
    }
    tip

    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_statusinteger
  • 0
  • 1
  • 2
  • Asynchronous 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.
    tip

    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