跳转到内容

执行 AI 换脸 任务。

请求

AI 任务是异步处理的。功能支持 Webhook 时,优先用 Webhook 来接收完成通知。配置好您的 Webhook 端点、校验 Webhook 签名,收到 success 或 error 通知后,用收到的 task_id 查询任务结果。配置与校验的细节请见 Webhook 接入指南。

若功能不支持 Webhook,或您的接入方式用不了 Webhook,就请实现轮询。提交 AI 任务后,按固定间隔(例如每 10 秒)轮询状态接口,直到任务状态变为 success 或 error。

安全
BearerAuthenticationV2
正文application/json必需
Any of:
face_mappingArray of objects必需

指定要在目标图片每张已检测到的人脸上替换的参考图标识与人脸位置信息。

对应规则

  1. 下标对应:index 直接对应您参考图中图片的顺序。
  2. 跳过替换:要跳过源图中某一张人脸,把 index 和 position 都设为 -1。
  3. 数组顺序:数组中各对象的顺序应按 position 对齐。

示例场景

场景: 参考图:提供 2 张(图 A、图 B)。 源图:检测到 3 张人脸(Face 0、Face 1、Face 2)。

目标: 把 Face 0(源图)与图 1(参考图)替换。 跳过 Face 1(源图)。 把 Face 2(源图)与图 0(参考图)替换。

配置: "face_mapping": [ { "index": 1, // Use the second reference image "position": 0 // Apply to the first detected face in source }, { "index": -1, // Skip swapping "position": -1 // Skip swapping }, { "index": 0, // Use the first reference image "position": 2 // Apply to the third detected face in source } ]

src_file_urlstring必需

用于运行任务的文件 URL,该 URL 需可公开访问。

示例:"https://example.com/selfie.jpg"
ref_file_urlsArray of strings, non-empty必需
curl -i -X POST \
  https://yce-api-01.makeupar.com/s2s/v2.0/task/face-swap \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "src_file_url": "https://example.com/selfie.jpg",
    "ref_file_urls": [
      "https://example.com/accessory.jpg"
    ],
    "face_mapping": [
      {
        "index": 0,
        "position": 0
      }
    ]
  }'

响应

任务执行成功

正文application/json
statusinteger

响应状态

示例:200
dataobject
响应
{ "status": 200, "data": { "task_id": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe" } }