openapi: 3.0.0
servers:
  - url: https://prod.api.market/api/v1/ailabtools/merge-portraits
info:
  title: Merge Portraits
  version: 1.12.0
  description: Achieve seamless face swapping with our 3D and GAN-powered Merge
    Portraits API, merging faces from template and target images.
paths:
  /portrait/editing/merge:
    post:
      tags:
        - AI PORTRAIT > Portrait Editing
      summary: Merge Portraits
      operationId: 3450c9a569c7ee9de6760374e2efcdc0
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              required:
                - image_template
                - image_target
              properties:
                image_template:
                  description: "Target image. <li>Image format: `JPEG` `JPG` `BMP` `PNG`</li>
                    <li>Image size: No more than 4 MB.</li> <li>Image
                    resolution: Larger than 200x200px, smaller than
                    4096x4096px.</li> <li>Note that for special face materials,
                    such as cartoon style images with large eyes, the original
                    key point results will be deviated, and should be made
                    accurate by dragging the position in the configuration tool.
                    Most normal images are already very accurate and do not need
                    to be adjusted.</li> <li>The pixel area of the face in the
                    image should not be too small (at least 200x200px, too small
                    to change the face will not be clear), nor too large (the
                    pixel size of the face area and speed is positively
                    correlated, too large will affect the server speed and
                    increase costs).</li> <li>Pay attention to the quality of
                    the material, make sure the face is clear enough, there
                    should be no noise caused by compression, otherwise it will
                    reduce the quality of the face replacement result.</li>
                    <li>For better results, the face of the material should be
                    as positive as possible, with the highest yaw angle required
                    (within plus or minus 10 degrees recommended), followed by
                    the pitch angle (within plus or minus 20 degrees
                    recommended), and the roll angle (within plus or minus 30
                    degrees).</li>"
                  type: file
                image_target:
                  description: "Template images. <li>Image format: `JPEG` `JPG` `BMP` `PNG`</li>
                    <li>Image size: No more than 4 MB.</li> <li>Image
                    resolution: Larger than 128x128px, smaller than
                    4096x4096px.</li> <li>Face pixel size: To ensure the fusion
                    effect, it is recommended that the minimum value of the side
                    length of the face box (square) in the image is not less
                    than 200px.</li> <li>Face quality: The higher the face
                    quality, the better the fusion effect.</li> <li>Factors
                    affecting face quality include: occlusion of the five facial
                    features, improper lighting (bright light, dark light,
                    backlighting), excessive face angle (recommended yaw ≤ ±20°,
                    pitch ≤ ±20°), etc.</li> <li>Black and white images are not
                    supported.</li>"
                  type: file
                source_similarity:
                  description: "Face similarity, where a higher numerical value indicates greater
                    similarity. <li>`0`: Consistent with the original
                    template.</li> <li>`1`: Maximum similarity with the target
                    image.</li>"
                  type: number
                  format: float
                  default: 1
                  enum:
                    - 0
                    - 0.1
                    - 0.2
                    - 0.3
                    - 0.4
                    - 0.5
                    - 0.6
                    - 0.7
                    - 0.8
                    - 0.9
                    - 1
              type: object
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                allOf:
                  - properties:
                      data:
                        type: object
                        allOf:
                          - properties:
                              image:
                                description: The result image, returning the Base64 encoding of the image.
                                type: string
                            type: object
                    type: object
                  - $ref: "#components/schemas/commonResponses"
        "400":
          description: Bad Request
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
        "404":
          description: Not Found
        "405":
          description: Method Not Allowed
        "409":
          description: Conflict
        "410":
          description: Gone
        "413":
          description: Payload Too Large
        "415":
          description: Unsupported Media Type
        "422":
          description: Unprocessable Entity
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
        "502":
          description: Bad Gateway
        "503":
          description: Service Unavailable
        "504":
          description: Gateway Timeout
    parameters:
      - description: API.market API Key
        in: header
        name: x-api-market-key
        value: Please Login/Signup to get an API Key
        required: true
        schema:
          type: string
components:
  schemas:
    commonResponses:
      properties:
        request_id:
          description: Request ID. <li>If there is a problem that cannot be located, this
            field can be sent to technology for problem location.</li>
          type: string
        log_id:
          description: Log ID. <li>If there is a problem that cannot be located, this
            field can be sent to technology for problem location.</li>
          type: string
        error_code:
          description: "Status code. <li>When HTTP Status is 200: error_code=0; otherwise
            exactly the same as HTTP Status.</li>"
          type: integer
        error_detail:
          type: object
          allOf:
            - properties:
                status_code:
                  description: Status Code.
                  type: integer
                code:
                  description: Error Code.
                  type: string
                code_message:
                  description: The information represented by the Error Code(`code`).
                  type: string
                message:
                  description: Supplementary information for the `code_message` field.
                  type: string
              type: object
        error_msg:
          description: Error message.
          type: string
      type: object
security: {}
tags:
  - name: artificial-intelligence
    description: Operations related to artificial-intelligence
