Skip to main content

AILabTools API - Hairstyle Changer Pro - API

Photo Validation Guide

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 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
FieldRequiredTypeDescription
ailabapi-api-keyYESstringApplication API KEY. Get API KEY

Body

Fixed Fields

FieldRequiredTypeScopeDefaultDescription
task_typeYESstring
  • async
  • Task Type.
  • async: Asynchronous tasks.
  • autoYESinteger
  • 1
  • 1Mode.
  • 1: Automatic mode.
  • imageYESfileMain image.
    hair_styleYESstringScopeHairstyle. More Details
    colorNOstringScopeColor. More Details
    image_sizeNOinteger
  • 1
  • 2
  • 3
  • 4
  • 1Returns 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
    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

    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

    Processing Flow
    1. 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.

    2. 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 Codes

    Business Parameters

    FieldTypeScopeDescription
    task_typestring
  • async
  • Task Type.
  • async: Asynchronous tasks.
  • task_idstringAsynchronous 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": ""
    }
    tip

    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

    Processing Flow
    1. 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.

    2. 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 Codes

    Business Parameters

    FieldTypeScopeDescription
    task_statusinteger
  • 0
  • 1
  • 2
  • Asynchronous 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.
    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.

    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.