AILabTools API - Hairstyle Changer Pro - API
To ensure user-uploaded photos meet the Hairstyle Processing API requirements, we recommend splitting the workflow into two stages: Face Analysis and Hairstyle Processing. This approach minimizes error wait times by validating images on the frontend, ensuring they meet API standards before proceeding to hairstyle processing. This enhances overall user experience.
For detailed information, refer to the Photo Validation Guide.
Request
- URL:
https://www.ailabapi.com/api/portrait/effects/hairstyle-editor-pro
- Method:
POST
- Content-Type:
multipart/form-data
Image requirements
- Image format:
PNG
JPG
JPEG
- Image size: No more than 3 MB.
- Image resolution: Larger than 200x200px, smaller than 1999x1999px.
- Minimum Face Proportion: To ensure effectiveness, the proportion of the face in the image cannot be less than 20%.
- Facial Integrity: To ensure effectiveness, the face in the image should ideally not be obscured.
- Facial Angle: To ensure effectiveness, the face in the image should ideally be front-facing, with no more than a 45-degree rotation to the left or right.
Image Validity | Reason for Invalidity | |
---|---|---|
✅ | ||
❌ | No face | |
Incomplete face | ||
Face obscured | ||
Face proportion too small | ||
The face is too large to edit the hairstyle |
Header
Field | Required | Type | Description |
---|---|---|---|
ailabapi-api-key | YES | string | Application API KEY. Get API KEY |
Body
Fixed Fields
Field | Required | Type | Scope | Default | Description |
---|---|---|---|---|---|
task_type | YES | string | async | Task Type. async : Asynchronous tasks. | |
auto | YES | integer | 1 | 1 | Mode. 1 : Automatic mode. |
image | YES | file | Main image. | ||
hair_style | YES | string | Scope | Hairstyle. More Details | |
color | NO | string | Scope | Color. More Details | |
image_size | NO | integer | 1 2 3 4 | 1 | Returns the number of images. |
hair_style
Category: Gender | hair_style | Description |
---|---|---|
Male | BuzzCut | Buzz Cut hair |
UnderCut | UnderCut hair | |
Pompadour | Pompadour hair | |
SlickBack | Slick Back hair | |
CurlyShag | Curly Shag hair | |
WavyShag | Wavy Shag hair | |
FauxHawk | Faux Hawk hair | |
Spiky | Spiky hair | |
CombOver | Comb-over hair | |
HighTightFade | High and Tight Fade hair | |
ManBun | Man Bun hair | |
Afro | Afro hair | |
LowFade | Low Fade hair | |
UndercutLongHair | Undercut With Long Hair | |
TwoBlockHaircut | Two Block Haircut | |
TexturedFringe | Textured Fringe Hair | |
BluntBowlCut | Blunt Bowl Cut | |
LongWavyCurtainBangs | Long Wavy Curtain Bangs Hair | |
MessyTousled | Messy Tousled hair | |
CornrowBraids | Cornrow Braids hair | |
LongHairTiedUp | Long Hair Tied Up Hair | |
Middle-parted | Middle-parted Hair | |
Female | ShortPixieWithShavedSides | Short Pixie With Shaved Sides |
ShortNeatBob | short neat bob hair | |
DoubleBun | double bun hair | |
Updo | Updo hair | |
Spiked | spiked hair | |
bowlCut | bowl cut hair | |
Chignon | Chignon hair | |
PixieCut | Pixie Cut hair | |
SlickedBack | slicked back hair | |
LongCurly | Long curly hair | |
CurlyBob | Curly bob hair | |
StackedCurlsInShortBob | Stacked Curls in Short Bob hair | |
SidePartCombOverHairstyleWithHighFade | Side Part Comb-Over Hairstyle With High Fade hair | |
WavyFrenchBobVibesfrom1920 | Wavy French Bob Vibes from 1920 | |
BobCut | bob Haircut hair | |
ShortTwintails | Short Twintails hair | |
ShortCurlyPixie | Short Curly Pixie | |
LongStraight | Long straight hair | |
LongWavy | Long wavy hair | |
FishtailBraid | Fishtail braid hair | |
TwinBraids | Twin Braids hair | |
Ponytail | Ponytail hair | |
Dreadlocks | dreadlocks hair | |
Cornrows | Cornrows hair | |
ShoulderLengthHair | Shoulder Length Straight Hair | |
LooseCurlyAfro | Loose Curly Afro hair | |
LongTwintails | Long Twintails hair | |
LongHimeCut | Long Hime Cut hair | |
BoxBraids | Box Braids hair |
color
color | Description |
---|---|
blonde | blonde hair |
platinumBlonde | platinum blonde hair |
brown | brown hair |
lightBrown | light brown hair |
blue | blue hair |
lightBlue | light blue hair |
purple | purple hair |
lightPurple | light purple hair |
pink | pink hair |
black | black hair |
white | white hair |
grey | grey hair |
silver | silver hair |
red | red hair |
orange | orange hair |
green | green hair |
gradient | gradient hair |
multicolored | multicolored hair |
darkBlue | dark blue hair |
burgundy | burgundy hair |
darkGreen | dark green hair |
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 asynchronous 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 asynchronous 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 asynchronous 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 | The content of the result data returned. | |
+images | array | Array of resultant image addresses. |
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": {
"images": [
"Image URL",
"Image URL"
]
}
}
Code example
If you'd like to see the actual effects, please visit the experience page for a trial.