> ## Documentation Index
> Fetch the complete documentation index at: https://ailabtools.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Hair Loss Simulation API

> AI Hair Loss Simulation API creates realistic hair thinning, receding hairline, and baldness previews from portrait photos.

export const manLevel = [{
  value: "man_1",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_1.webp"
}, {
  value: "man_2",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_2.webp"
}, {
  value: "man_3",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_3.webp"
}, {
  value: "man_4",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_4.webp"
}, {
  value: "man_5",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_5.webp"
}, {
  value: "man_6",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_6.webp"
}, {
  value: "man_7",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/man-level/man_7.webp"
}];

export const womanLevel = [{
  value: "woman_1",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_1.webp"
}, {
  value: "woman_2",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_2.webp"
}, {
  value: "woman_3",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_3.webp"
}, {
  value: "woman_4",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_4.webp"
}, {
  value: "woman_5",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_5.webp"
}, {
  value: "woman_6",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_6.webp"
}, {
  value: "woman_7",
  image: "https://ai-resource.ailabtools.com/ai-hair-loss-simulation/doc/woman-level/woman_7.webp"
}];

## Query Task

<Tip>
  This is an asynchronous task API. The submission request returns only `task_id`.

  Use `task_id` to call [Querying Async Task Results](/docs/ai-common/async-task-results/api) and retrieve the final result. Async task results remain available for 24 hours. Query every 5 seconds.
</Tip>

| Field             | Type     | Description        |
| :---------------- | :------- | :----------------- |
| `data`            | `object` | Final result data. |
| +`result_urls`    | `array`  | Result image URLs. |
| ++`result_urls[]` | `string` | Result image URL.  |

```json theme={null}
{
  "data": {
    "result_urls": [""]
  }
}
```

<Tip>
  `result_urls` are temporary and remain valid for 24 hours. Download the files to your own storage before the URLs expire if you need long-term storage.
</Tip>

## Submit Task

### `level`

The following enum values are supported for `level`.

<Expandable title="Men's Level">
  <div className="mt-2 grid grid-cols-2 lg:grid-cols-4 align-center gap-2">
    {manLevel.map((item) => (
            <div key={item.value} className="rounded-xl">
              <img className="w-full mt-0 mb-2 aspect-square object-contain rounded-xl" src={item.image} alt={item.value} />
              <code className="block break-all text-center text-xs">{item.value}</code>
            </div>
          ))}
  </div>
</Expandable>

<Expandable title="Women's Level">
  <div className="mt-2 grid grid-cols-2 lg:grid-cols-4 align-center gap-2">
    {womanLevel.map((item) => (
            <div key={item.value} className="rounded-xl">
              <img className="w-full mt-0 mb-2 aspect-square object-contain rounded-xl" src={item.image} alt={item.value} />
              <code className="block break-all text-center text-xs">{item.value}</code>
            </div>
          ))}
  </div>
</Expandable>


## OpenAPI

````yaml POST /api/portrait/editing/ai-hair-loss-simulation
openapi: 3.0.0
info:
  title: AILabAPI
  description: >-
    [<b>AILabTools</b>](https://www.ailabtools.com) is an advanced tool that
    offers a vast array of simple and flexible API endpoints to suit your
    specific needs. With just one [<b>API
    KEY</b>](https://www.ailabtools.com/doc/get-api-key), you can easily call
    any of the endpoints and integrate them quickly into your application or
    workflow, allowing for smooth and efficient operations.


    [<b>AILabTools</b>](https://www.ailabtools.com) is continuously evolving,
    and you can anticipate even more API endpoints being added in the future,
    further enhancing its capabilities and usefulness for your artificial
    intelligence and machine learning requirements.
  version: 1.0.0
servers:
  - url: https://www.ailabapi.com
    description: Production server
security:
  - apiKeyAuth: []
tags:
  - name: AI IMAGE
  - name: AI IMAGE > Image Enhancement
  - name: AI IMAGE > Image Effects
  - name: AI IMAGE > Image Editing
  - name: AI IMAGE > Image Scoring
  - name: AI BACKGROUND REMOVAL
  - name: AI BACKGROUND REMOVAL > Portrait
  - name: AI BACKGROUND REMOVAL > General
  - name: AI PORTRAIT
  - name: AI PORTRAIT > Portrait Effects
  - name: AI PORTRAIT > Portrait Enhance
  - name: AI PORTRAIT > Portrait Editing
  - name: AI PORTRAIT > Portrait Analysis
  - name: AI COMMON
paths:
  /api/portrait/editing/ai-hair-loss-simulation:
    post:
      tags:
        - AI PORTRAIT > Portrait Editing
      summary: AI Hair Loss Simulation
      description: >-
        AI Hair Loss Simulation API creates realistic hair thinning, receding
        hairline, and baldness previews from portrait photos.
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - image
                - level
              properties:
                image:
                  type: string
                  description: |-
                    - Image format: `JPEG` `JPG` `PNG` `WEBP` 
                    - Image size: No more than 10 MB. 
                    - Image resolution: Less than 4096x4096px.
                  format: binary
                level:
                  type: string
                  description: >-
                    Hair loss level. See [Supported level
                    values](/docs/ai-portrait/editing/ai-hair-loss-simulation/api#level).
                  enum:
                    - man_1
                    - man_2
                    - man_3
                    - man_4
                    - man_5
                    - man_6
                    - man_7
                    - woman_1
                    - woman_2
                    - woman_3
                    - woman_4
                    - woman_5
                    - woman_6
                    - woman_7
      responses:
        '200':
          headers:
            Content-Type:
              schema:
                type: string
                example: application/json
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PublicResponseFields'
                  - type: object
                    required:
                      - task_id
                    properties:
                      task_id:
                        $ref: '#/components/schemas/AsyncTaskId'
              example:
                request_id: ''
                log_id: ''
                error_detail:
                  code: ''
                  code_message: ''
                  message: ''
                task_id: ''
          description: Success
components:
  schemas:
    PublicResponseFields:
      type: object
      required:
        - request_id
        - log_id
        - error_detail
      properties:
        request_id:
          type: string
          description: Request ID for debugging.
        log_id:
          type: string
          description: Log ID for debugging.
        error_detail:
          $ref: '#/components/schemas/ErrorDetail'
    AsyncTaskId:
      type: string
      description: >-
        Task ID for querying [Querying Async Task
        Results](/docs/ai-common/async-task-results/api).
    ErrorDetail:
      type: object
      required:
        - code
        - code_message
        - message
      properties:
        code:
          type: string
          description: >-
            Error Code. See [Error
            Codes](/docs/response-description#error-codes).
        code_message:
          type: string
          description: Error summary.
        message:
          type: string
          description: Detailed error message.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: ailabapi-api-key
      description: API Key for authentication

````