Skip to main content

AILabTools API - Hairstyle Changer Advanced - API

Request

  • URL: https://www.ailabapi.com/api/portrait/effects/hairstyle-editor-advanced
  • Method: POST
  • Content-Type: multipart/form-data

Image requirements

  • Image format: PNG JPG JPEG BMP TIFF WEBP
  • Image size: No more than 5 MB.
  • Image resolution: Less than 1024x1024px.
FieldRequiredTypeDescription
ailabapi-api-keyYESstringApplication API KEY.

Body

Fixed Fields

FieldRequiredTypeScopeDescription
task_typeYESstring
  • async
  • Task Type.
  • async: Asynchronous tasks.
  • imageYESfile
    editing_typeYESstring
  • both
  • hairstyle
  • color
  • Edit Type.
  • both: Change the hairstyle & Change the color.
  • hairstyle: Change the hairstyle.
  • color: Change the color.
  • genderYES:
  • editing_type=both
  • editing_type=hairstyle

  • NO:
  • editing_type=color
  • string
  • male
  • female
  • Gender.
  • male: Male.
  • female: Female.
  • hair_styleYES:
  • editing_type=both
  • editing_type=hairstyle

  • NO:
  • editing_type=color
  • stringediting_type=male OR editing_type=female:
  • style_1
  • style_2
  • style_3
  • style_4
  • style_5
  • style_6
  • style_7
  • style_8
  • style_9
  • style_10
  • style_11
  • style_12
  • style_13
  • style_14
  • style_15
  • style_16
  • style_17


  • editing_type=female:
  • style_18
  • Hairstyle.
  • See the results of men's hairstyles
  • See the effect of women's hairstyles
  • colorYES:
  • editing_type=both
  • editing_type=color

  • NO:
  • editing_type=hairstyle
  • string
  • color_1
  • color_2
  • color_3
  • color_4
  • color_5
  • color_6
  • color_7
  • color_8
  • color_9
  • color_10
  • color_11
  • color_12
  • color_13
  • color_14
  • color_15
  • color_16
  • color_17
  • color_18
  • color_19
  • color_20
  • Color. View Effect

    Response

    Parameters

    FieldTypeScopeDescription
    error_codeintegerStatus Code.
    error_code_strstringError Code.
    error_msgstringError Message.
    request_idstringRequest ID.
    log_idstringLog ID.
    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

    {
    "error_code": 0,
    "error_code_str": "",
    "error_msg": "",
    "request_id": "",
    "log_id": "",
    "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

    Parameters

    FieldTypeScopeDescription
    error_codeintegerStatus Code.
    error_code_strstringError Code.
    error_msgstringError Message.
    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.
    +cropped_imagestringCropped face image URL.
    +hairstyle_imagestringResulting graph URL.
    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.

    Examples

    {
    "error_code": 0,
    "error_code_str": "",
    "error_msg": "",
    "task_status": 0,
    "data": {
    "cropped_image": "",
    "hairstyle_image": ""
    }
    }

    Code example