Skip to main content

AILabTools API - Hairstyle changer - API:V1.1.0

Request

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

Image requirements

  • Image format: JPEG JPG PNG BMP
  • Image size: No more than 5 MB.
  • Image resolution: Less than 4096x4096px.
FieldRequiredTypeDescription
ailabapi-api-keyYESstringApplication API KEY. Get API KEY

Body

FieldRequiredTypeScopeDefaultDescription
image_targetYESfile
hair_typeNOinteger
  • 101
  • 201
  • 301
  • 401
  • 402
  • 403
  • 502
  • 503
  • 603
  • 801
  • 901
  • 1001
  • 1101
  • 1201
  • 1301
  • 101Hairstyle type.
  • 101: Bangs (default)
  • 201: Long hair
  • 301: Bangs with long hair
  • 401: Medium hair increase
  • 402: Light hair increase
  • 403: Heavy hair increase
  • 502: Light curling
  • 503: Heavy curling
  • 603: Short hair (requires input size < 2048x2048; if the input is larger than 2048x2048, the output image will be resized to a maximum of 2048 on the longest side.)
  • 801: Blonde
  • 901: Straight hair
  • 1001: Oil-free hair (slight effect, recommended for images with noticeable issues)
  • 1101: Hairline fill (slight effect, recommended for images with noticeable issues of a high hairline)
  • 1201: Smooth hair (slight effect, recommended for images with a large hairstyle area)
  • 1301: Fill hair gap (slight effect, fills the scalp part in the hair area, recommended for images with noticeable issues)
  • 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

    FieldTypeDescription
    dataobjectThe content of the result data returned.
    +imagestringThe result image, returning the Base64 encoding of the image.

    Example

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

    Code example

    If you'd like to see the actual effects, please visit the experience page for a trial.