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:
JPEGJPGPNGBMP - Image size: No more than 5 MB.
- Image resolution: Less than 4096x4096px.
Headers
| Field | Required | Type | Description |
|---|---|---|---|
ailabapi-api-key | YES | string | Application API KEY. Get API KEY |
Body
| Field | Required | Type | Scope | Default | Description |
|---|---|---|---|---|---|
image_target | YES | file | |||
hair_type | NO | integer | 1012013014014024035025036038019011001110112011301 | 101 | Hairstyle type. 101: Bangs (default)201: Long hair301: Bangs with long hair401: Medium hair increase402: Light hair increase403: Heavy hair increase502: Light curling503: Heavy curling603: 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: Blonde901: Straight hair1001: 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
Response Field Handling Flow
-
Handle
Public Response FieldsParse and validate the
Public Response Fields, checking the status code or response message to ensure the request is successful and error-free. -
Handle
Business Response FieldsIf the
Public Response Fieldsare valid and error-free, proceed with processing the business logic in theBusiness Response Fields.
Public Response Fields
Viewing Public Response Fields and Error CodesBusiness Response Fields
| Field | Type | Description |
|---|---|---|
data | object | The content of the result data returned. |
+image | string | The result image, returning the Base64 encoding of the image. |
Response Example
{
"request_id": "",
"log_id": "",
"error_code": 0,
"error_msg": "",
"error_detail": {
"status_code": 200,
"code": "",
"code_message": "",
"message": ""
},
"data": {
"image": ""
}
}
Sample Code
If you'd like to see the actual effects, please visit the experience page for a trial.