Skip to main content
POST
/
api
/
portrait
/
effects
/
hairstyle-editor-pro
Hairstyle changer Pro
curl --request POST \
  --url https://www.ailabapi.com/api/portrait/effects/hairstyle-editor-pro \
  --header 'Content-Type: multipart/form-data' \
  --header 'ailabapi-api-key: <api-key>' \
  --form task_type=async \
  --form image='@example-file' \
  --form 'hair_style=<string>' \
  --form 'color=<string>' \
  --form 'image_size=<string>'
{
  "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": ""
}
Photo Validation GuideTo 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 5 MB.
  • Image resolution: Larger than 200x200px, smaller than 4090x4090px.
  • Minimum Face Proportion: To ensure effectiveness, the proportion of the face in the image cannot be less than 10%.
  • 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 30-degree rotation to the left or right.
Image ValidityReason for Invalidity
Hairstyle Changer Pro
Hairstyle Changer Pro
Hairstyle Changer Pro
Hairstyle Changer Pro
Hairstyle Changer Pro
Hairstyle Changer Pro
No face
Hairstyle Changer Pro
Hairstyle Changer Pro
Incomplete face
Hairstyle Changer Pro
Hairstyle Changer Pro
Face obscured
Hairstyle Changer Pro
Hairstyle Changer Pro
Face proportion too small
Hairstyle Changer Pro
Hairstyle Changer Pro
The face is too large to edit the hairstyle

Headers

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

Body

Fixed Fields

FieldRequiredTypeScopeDefaultDescription
task_typeYESstringasync“async: Asynchronous tasks.
autoYESinteger11“1: Automatic mode.
imageYESfileMain image.
hair_styleYESstringScopeHairstyle. More Details
colorNOstringScopeColor. More Details
image_sizeNOinteger1, 2, 3, 41Returns the number of images.

hair_style

Category: Genderhair_styleDescription
MaleBuzzCutBuzz Cut hair
UnderCutUnderCut hair
PompadourPompadour hair
SlickBackSlick Back hair
CurlyShagCurly Shag hair
WavyShagWavy Shag hair
FauxHawkFaux Hawk hair
SpikySpiky hair
CombOverComb-over hair
HighTightFadeHigh and Tight Fade hair
ManBunMan Bun hair
AfroAfro hair
LowFadeLow Fade hair
UndercutLongHairUndercut With Long Hair
TwoBlockHaircutTwo Block Haircut
TexturedFringeTextured Fringe Hair
BluntBowlCutBlunt Bowl Cut
LongWavyCurtainBangsLong Wavy Curtain Bangs Hair
MessyTousledMessy Tousled hair
CornrowBraidsCornrow Braids hair
LongHairTiedUpLong Hair Tied Up Hair
Middle-partedMiddle-parted Hair
ManGreasedMan greased slick-back hair
WavyMiddlePartWavy middle-part hair
Natural_Side-PartNatural side-part hair
Wolf_CropWolf crop hair
Wind-Tousled_CropWind-tousled crop hair
Side-Parted_TexturedSide-parted textured hair
FluffyMiddlePartFluffy middle-part hair
FreshSide-PartedFresh side-parted hair
Smooth_CropSmooth crop hair
Korean_Wavy_CropKorean wavy crop hair
Comma_HairComma hair
Side-Part_CropSide-part crop hair
Natural_Middle_PartNatural middle-part hair
FemaleShortPixieWithShavedSidesShort Pixie With Shaved Sides
ShortNeatBobShort neat bob hair
DoubleBunDouble bun hair
UpdoUpdo hair
SpikedSpiked hair
bowlCutBowl cut hair
ChignonChignon hair
PixieCutPixie Cut hair
SlickedBackSlicked back hair
LongCurlyLong curly hair
CurlyBobCurly bob hair
StackedCurlsInShortBobStacked curls in short bob hair
SidePartCombOverHairstyleWithHighFadeSide Part Comb-Over Hairstyle With High Fade hair
WavyFrenchBobVibesfrom1920Wavy French Bob Vibes from 1920
BobCutBob haircut hair
ShortTwintailsShort twintails hair
ShortCurlyPixieShort curly pixie
LongStraightLong straight hair
LongWavyLong wavy hair
FishtailBraidFishtail braid hair
TwinBraidsTwin braids hair
PonytailPonytail hair
DreadlocksDreadlocks hair
CornrowsCornrows hair
ShoulderLengthHairShoulder length straight hair
LooseCurlyAfroLoose curly afro hair
LongTwintailsLong twintails hair
LongHimeCutLong Hime cut hair
BoxBraidsBox braids hair
Layered_WavesLayered waves hair
Side_Flip_PermSide flip perm hair
Textured_CropTextured crop short hair
Mushroom_CurlMushroom curl hair
Vintage_CurlsVintage short curls hair
Magic_PermMagic perm hair
Side-Parted_WavesSide-parted waves hair
Fluffy_ShortFluffy short hair
Smooth_Inward_BobSmooth inward bob hair
Neat_ShortNeat short hair
Natural_ShortNatural airy short hair
Chic_Tapered_BobChic layered bob hair
Edgy_Textured_PixieEdgy textured pixie cut
Elegant_Wavy_CropElegant wavy short crop
Chic_Wavy_PixieChic wavy pixie cut
Elegant_Side_WaveElegant side-part wave hair
Soft_Layered_CurlSoft layered curl hair
Executive_PixieExecutive neat pixie cut
Curved_Chic_BobCurved chic bob hair
Airy_Short_CurlsAiry short curls hair
Playful_Curly_BobPlayful curly bob hair
Playful_Wavy_BobPlayful wavy bob hair
Elegant_Soft_CurlElegant soft large curls
Elegant_Smooth_BobElegant smooth short bob
Retro_Airy_CurlRetro airy curl hair
Soft_Wavy_BobSoft wavy bob hair
Light_Inward_BobLight inward short bob hair
Neat_Curly_Crop_CutNeat curly crop short hair
Elegant_Volumized_BobElegant volumized bob hair
Modern_Curls_ChicModern chic large curl hair
Mocha_Volume_PixieMocha-toned volumized pixie cut
Elegant_Side_FlowElegant side-flowing short hair

color

colorDescription
blondeblonde hair
platinumBlondeplatinum blonde hair
brownbrown hair
lightBrownlight brown hair
blueblue hair
lightBluelight blue hair
purplepurple hair
lightPurplelight purple hair
pinkpink hair
blackblack hair
whitewhite hair
greygrey hair
silversilver hair
redred hair
orangeorange hair
greengreen hair
gradientgradient hair
multicoloredmulticolored hair
darkBluedark blue hair
burgundyburgundy hair
darkGreendark green hair

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.
dataobjectThe content of the result data returned.
+imagesarrayArray 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.

Response Example

{
  "error_code":     0,
  "error_msg":      "",
  "error_detail":   {
    "status_code":  200,
    "code":         "",
    "code_message": "",
    "message":      ""
  },
  "task_status":    0,
  "data":           {
    "images": [
      "Image URL",
      "Image URL"
    ]
  }
}

Sample Code

👉 Online Experience 👈If you’d like to see the actual effects, please visit the experience page for a trial.

Authorizations

ailabapi-api-key
string
header
required

API Key for authentication

Body

multipart/form-data
task_type
string

Task Type.

Example:

"async"

image
file
hair_style
string

Hairstyle.

color
string

Color.

image_size
string

Returns the number of images.

Response

200 - application/json

Success

The response is of type object.