跳转到内容

執行 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必需

針對目標照片中每個被偵測到的臉部,要交換的參考圖片 id 與臉部位置資訊。

邏輯規則

  1. 索引對應:index 直接對應您參考清單中提供圖片的順序。
  2. 跳過交換:若要跳過交換來源中某個被偵測到的臉部,請將 index 與 position 都設為 -1。
  3. 陣列順序:陣列中物件的順序,應依據 position 對應。

使用範例

情境: 參考清單:提供 2 張圖片(圖片 A、圖片 B)。 來源照片:包含 3 個被偵測到的臉部(臉 0、臉 1、臉 2)。

目標: 將臉 0(來源)與圖片 1(參考)交換。 跳過交換臉 1(來源)。 將臉 2(來源)與圖片 0(參考)交換。

設定: "face_mapping": [ { "index": 1, // 使用第二張參考圖片 "position": 0 // 套用到來源中第一個被偵測到的臉 }, { "index": -1, // 跳過交換 "position": -1 // 跳過交換 }, { "index": 0, // 使用第一張參考圖片 "position": 2 // 套用到來源中第三個被偵測到的臉 } ]

src_file_urlstring必需

要執行任務的檔案網址。該網址應可公開存取。

示例:"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" } }