Skip to main content

AILabTools API - Hairstyle Changer Pro - API:V1.0.0(DEPRECATED)


draft: true

Important Announcement: API Version Update Notice

Dear Developers,

We are thrilled to announce that our API is receiving a major update! The new version will introduce a host of improvements and feature enhancements to enhance your development experience and meet your needs.

However, along with the rollout of the new version, we must also inform you that the old version of the API will no longer receive maintenance and support. This means that we will no longer release new features, fix known issues, or provide technical support for the old version of the API.

We strongly encourage you to upgrade to the latest version of the API as soon as possible to ensure that your applications continue to operate smoothly and to take advantage of the latest features and optimizations.

If you have any questions or need assistance regarding this change, please feel free to contact our support team ([email protected]). We are committed to assisting you and ensuring a smooth transition.

Once again, thank you for your support and trust in our API.

Best Regards,

AILabTools Support Team

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 2000x2000px.
  • 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.
  • imageYESfileMain image.
    hair_styleYESstringScopeHairstyle. More Details
    colorNOstringScopeColor. More Details
    image_sizeNOinteger
  • 1
  • 2
  • 3
  • 4
  • 1Returns the number of images.
    maskNOfileMasked Image. If left blank, a masked image will be generated automatically. The white portion of the masked image is the editable area, while the black portion remains unchanged. For example, by using the white area of the mask to cover a person's face, the face will remain unaltered, and other parts will be generated automatically.
    bangsNOinteger
  • 0
  • 1
  • 1Whether to add bangs to the resulting image. This parameter is ineffective when the hairstyle has no bangs or when bangs are mandatory. Parameter Validity Explanation
  • 0: No.
  • 1: Yes.
  • Parameter Effect Comparison
  • modeNOinteger
  • 1
  • 2
  • 1Generation mode. Please enable this parameter based on the original hairstyle.
  • 1: Head-only mode. More suitable for short hair.
  • 2: Full-image generation mode. More suitable for long hair; use this mode when the original image features shoulder-length or longer hair.
  • Parameter Effect Comparison
  • referenceNOinteger
  • 0
  • 1
  • 0Reference Original Hairstyle. Enabling this parameter will make changes to the hairstyle based on the original hairstyle, resulting in minor alterations. Please do not enable this parameter if changing from short hair to long hair or from long hair to short hair.
  • 0: No.
  • 1: Yes.
  • Parameter Effect Comparison
  • hair_style

    Category: GenderCategory: Lengthhair_styleDescriptionValidity of the 'bangs' Field
    MaleShortBuzzCutBuzz Cut hairIneffective
    UnderCutUnderCut hairIneffective
    PompadourPompadour hairIneffective
    SlickBackSlick Back hairIneffective
    CurlyShagCurly Shag hairEffective
    WavyShagWavy Shag hairEffective
    FauxHawkFaux Hawk hairIneffective
    SpikySpiky hairIneffective
    CombOverComb-over hairEffective
    HighTightFadeHigh and Tight Fade hairIneffective
    ManBunMan Bun hairIneffective
    AfroAfro hairEffective
    LowFadeLow Fade hairEffective
    UndercutLongHairUndercut With Long HairIneffective
    TwoBlockHaircutTwo Block HaircutEffective
    TexturedFringeTextured Fringe HairEffective
    BluntBowlCutBlunt Bowl CutIneffective
    MiddleLongWavyCurtainBangsLong Wavy Curtain Bangs HairEffective
    MessyTousledMessy Tousled hairEffective
    MediumLengthWavyMedium Length Wavy hairEffective
    LongCornrowBraidsCornrow Braids hairIneffective
    LongHairTiedUpLong Hair Tied Up HairIneffective
    FemaleShortShortPixieWithShavedSidesShort Pixie With Shaved SidesEffective
    ShortNeatBobshort neat bob hairEffective
    DoubleBundouble bun hairEffective
    UpdoUpdo hairEffective
    Spikedspiked hairEffective
    bowlCutbowl cut hairEffective
    ChignonChignon hairIneffective
    PixieCutPixie Cut hairEffective
    SlickedBackslicked back hairIneffective
    MiddleLongCurlyLong curly hairEffective
    CurlyBobCurly bob hairEffective
    StackedCurlsInShortBobStacked Curls in Short Bob hairEffective
    SidePartCombOverHairstyleWithHighFadeSide Part Comb-Over Hairstyle With High Fade hairIneffective
    WavyFrenchBobVibesfrom1920Wavy French Bob Vibes from 1920Effective
    BobCutbob Haircut hairIneffective
    ShortTwintailsShort Twintails hairEffective
    ShortCurlyPixieShort Curly PixieEffective
    LongLongStraightLong straight hairEffective
    LongWavyLong wavy hairEffective
    FishtailBraidFishtail braid hairEffective
    TwinBraidsTwin Braids hairIneffective
    PonytailPonytail hairEffective
    Dreadlocksdreadlocks hairIneffective
    CornrowsCornrows hairIneffective
    ShoulderLengthHairShoulder Length Straight HairEffective
    LooseCurlyAfroLoose Curly Afro hairEffective
    LongTwintailsLong Twintails hairIneffective

    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

    bangs: Parameter Effect Comparison

    When the 'bangs' field is valid
    HairstylebangsOriginalResult
    Short Pixie With Shaved Sides0ORIGINAL IMAGERESULT IMAGE
    Short Pixie With Shaved Sides1ORIGINAL IMAGERESULT IMAGE
    When the 'bangs' Field Is Invalid
    HairstylebangsOriginalResult
    slicked back hair0ORIGINAL IMAGERESULT IMAGE
    slicked back hair1ORIGINAL IMAGERESULT IMAGE

    mode: Parameter Effect Comparison

    HairstylemodeOriginalResult
    double bun hair1ORIGINAL IMAGERESULT IMAGE
    double bun hair2ORIGINAL IMAGERESULT IMAGE

    reference: Parameter Effect Comparison

    HairstylereferenceOriginalResult
    Medium Length Wavy hair0ORIGINAL IMAGERESULT IMAGE
    Medium Length Wavy hair1ORIGINAL IMAGERESULT IMAGE

    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 Async 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 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

    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.