Try on Clothes Refiner
curl --request POST \
--url https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner \
--header 'Content-Type: multipart/form-data' \
--header 'ailabapi-api-key: <api-key>' \
--form task_type=async \
--form person_image='@example-file' \
--form top_garment='@example-file' \
--form coarse_image='@example-file' \
--form gender=man \
--form bottom_garment='@example-file'import requests
url = "https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner"
files = {
"person_image": ("example-file", open("example-file", "rb")),
"top_garment": ("example-file", open("example-file", "rb")),
"coarse_image": ("example-file", open("example-file", "rb")),
"bottom_garment": ("example-file", open("example-file", "rb"))
}
payload = {
"task_type": "async",
"gender": "man"
}
headers = {"ailabapi-api-key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('task_type', 'async');
form.append('person_image', '<string>');
form.append('top_garment', '<string>');
form.append('coarse_image', '<string>');
form.append('gender', 'man');
form.append('bottom_garment', '<string>');
const options = {method: 'POST', headers: {'ailabapi-api-key': '<api-key>'}};
options.body = form;
fetch('https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"ailabapi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ailabapi-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner")
.header("ailabapi-api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ailabapi-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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": ""
}Try-on Clothes Refiner
Try on Clothes Refiner API
Try on Clothes Refiner API enhances virtual try-on images with more realistic details, colors, and clothing fit.
POST
/
api
/
portrait
/
enhance
/
try-on-clothes-refiner
Try on Clothes Refiner
curl --request POST \
--url https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner \
--header 'Content-Type: multipart/form-data' \
--header 'ailabapi-api-key: <api-key>' \
--form task_type=async \
--form person_image='@example-file' \
--form top_garment='@example-file' \
--form coarse_image='@example-file' \
--form gender=man \
--form bottom_garment='@example-file'import requests
url = "https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner"
files = {
"person_image": ("example-file", open("example-file", "rb")),
"top_garment": ("example-file", open("example-file", "rb")),
"coarse_image": ("example-file", open("example-file", "rb")),
"bottom_garment": ("example-file", open("example-file", "rb"))
}
payload = {
"task_type": "async",
"gender": "man"
}
headers = {"ailabapi-api-key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('task_type', 'async');
form.append('person_image', '<string>');
form.append('top_garment', '<string>');
form.append('coarse_image', '<string>');
form.append('gender', 'man');
form.append('bottom_garment', '<string>');
const options = {method: 'POST', headers: {'ailabapi-api-key': '<api-key>'}};
options.body = form;
fetch('https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"ailabapi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ailabapi-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner")
.header("ailabapi-api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.ailabapi.com/api/portrait/enhance/try-on-clothes-refiner")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ailabapi-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_type\"\r\n\r\nasync\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"person_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"top_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"coarse_image\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nman\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bottom_garment\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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/enhance/try-on-clothes-refiner - Method:
POST - Content-Type:
multipart/form-data
Image requirements
- Image format:
JPGJPEGPNGBMP - 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
| 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 | Model image for calling the Try on Clothes API. | |
top_garment | YES | file | Top clothing image for calling the Try on Clothes API. | |
coarse_image | YES | file | Result image obtained from calling the Try on Clothes API. | |
gender | YES | string | woman, man | Gender of the person_image. woman`: Female.` man: Male. |
bottom_garment | NO | file | Bottom clothing image for calling the Try on Clothes API. |
Response
Response Field Handling Flow
-
Handle
Public Response FieldsParse and validate thePublic Response Fields, checking the status code or response message to ensure the request is successful and error-free. -
Handle
Business Response FieldsIf thePublic Response Fieldsare valid and error-free, proceed with processing the business logic in theBusiness Response Fields.
Public Response Fields
Viewing Public Response Fields and Error CodesBusiness Response Fields
| 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. |
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
-
Handle
Public Response FieldsParse and validate thePublic Response Fields, checking the status code or response message to ensure the request is successful and error-free. -
Handle
Business Response FieldsIf thePublic Response Fieldsare valid and error-free, proceed with processing the business logic in theBusiness Response Fields.
Public Response Fields
Viewing Public Response Fields and Error CodesBusiness Response Fields
| 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. |
output | object | ||
+image_url | string | Result image URL. | |
usage | object | ||
+image_count | integer | Number 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
}
}
Authorizations
API Key for authentication
Body
multipart/form-data
Task Type.
async: Asynchronous tasks.Example:
"async"
Model image for calling the Try on Clothes API.
Top clothing image for calling the Try on Clothes API.
Result image obtained from calling the Try on Clothes API.
Gender of the person_image.
woman: Female.man: Male.Example:
"man"
Bottom clothing image for calling the Try on Clothes API.
Response
200 - application/json
Success
The response is of type object.
⌘I

