Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

AILabTools API - Hairstyle Changer Advanced - API


draft: true

Important Announcement: API End of Maintenance Notice

Dear Developers,

We sincerely appreciate your continued support and use of our API over the years. Throughout this time, we have strived to provide high-quality services and reliable API interfaces to meet your needs.

However, due to technological advancements and adjustments in our business strategies, we regret to announce the discontinuation of maintenance and support for the current API. This means that we will no longer be releasing new features, fixing known issues, or providing technical support.

If you have any questions or need assistance regarding this change, please feel free to reach out to our support team ([email protected]). We are committed to assisting you and making this transition process as smooth as possible.

Once again, we thank you for your continued support and cooperation.

Warm regards,

AILabTools Support Team

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. Get 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

    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.
    +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.

    Example

    {
    "request_id": "",
    "log_id": "",
    "error_code": 0,
    "error_code_str": "",
    "error_msg": "",
    "error_detail": {
    "status_code": 200,
    "code": "",
    "code_message": "",
    "message": ""
    },
    "task_status": 0,
    "data": {
    "cropped_image": "",
    "hairstyle_image": ""
    }
    }

    Code example