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

# SwapFace换脸

> 创建换脸服务，此接口交互与 TTAPI Midjourney API 交互模式相同（Async）

### 换脸功能说明

换脸功能基于 Midjourney 图片编辑能力实现，支持上传人像图片与参考风格图，生成符合指定比例的换脸效果。使用前请确保：

1. 参考图片清晰，面部特征可识别；
2. 避免上传违规、侵权的图片内容；
3. 生成结果仅用于合法合规的场景。

<img src="https://mintcdn.com/acme-ce820e56/3BhrtPa-2pJn8c5Y/images/swapimg.png?fit=max&auto=format&n=3BhrtPa-2pJn8c5Y&q=85&s=1579463ac6fca1ba97134285658f4c95" alt="换脸效果示例" style={{width: "200px", height: "auto"}} width="394" height="670" data-path="images/swapimg.png" />


## OpenAPI

````yaml openapi/cn/swapface.json POST /insightFace/v1/swap
openapi: 3.1.0
info:
  title: Swapface API DOCS
  version: 1.0.0
  description: TTAPI Swapface API 接口服务，目前集成了市场上最为领先的视频大模型sora2。
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /insightFace/v1/swap:
    post:
      description: 创建换脸服务，此接口交互与 TTAPI Midjourney API 交互模式相同（Async）
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapRequest'
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse'
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    SwapRequest:
      type: object
      properties:
        targetImage:
          type: string
          description: 模板图像：换脸的模板图片url地址
        swapImage:
          type: string
          description: 人脸图像：要换脸的图片url地址，会将该地址的图片中的人脸，换到**targetImage**的人脸中
        hookUrl:
          type: string
          description: >-
            回调地址，任务完成或失败将通过请地址进行通知， <a href="fetch"
            target="_self">通知数据结构</a>与fetch结构一致。如果未设置，则需要请求<a href="fetch"
            target="_self">fetch</a>接口进行查询。
      required:
        - targetImage
        - swapImage
  responses:
    SuccessResponse:
      description: 请求成功
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: SUCCESS
              message:
                type: string
                example: success
              data:
                type: object
                example:
                  jobId: jobId
            required:
              - status
              - message
              - data
    400Response:
      description: 参数错误
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: 授权失败
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        请前往 <a href='https://dashboard.ttapi.io' target='_blank'>TTAPI 控制台</a>
        获取 API 密钥。

````