{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 腹肌濾鏡",
    "description": "# 概述\n\n**AI 腹肌濾鏡 API** 可讓您為照片加入逼真的腹部線條，以最少的力氣生成運動感的塑形結果。上傳全身或上半身圖片，選擇想要的增強模式，設定強度等級，即可獲得編輯後的輸出圖片。\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2024-09-27/daf70f5e-a350-46a3-8b6c-f63bd60c6cf0.jpg)\n\n支援的模式：\n\n- `Six-pack`：加入可見的六塊肌，呈現更結實的軀幹外觀。\n- `Vest-line`：強化腹部中央肌肉線條，呈現健體、運動的外觀。\n\n---\n\n## 整合指南\n\n**輸入需求與處理標準：**\n\n- 上傳全身或上半身圖片。\n- 選擇增強模式：`Six-pack` 或 `Vest-line`。\n- 選擇想要的腹部增強強度等級。\n- 長邊影像解析度上限不得超過 **4096 px**。\n- 來源檔案大小必須低於 **10 MB**。\n- 至少需要一位可偵測的人物，且兩側肩膀都可見。\n- 腹部必須可見，穿著或未穿著皆可。\n- 支援的姿勢範圍：`−45° < yaw < 45°`。\n- 支援單人處理。若圖片中出現多人，API 會自動選擇可見肩膀面積最大的人。\n\n**工作流程：**\n\n1. 使用 File API 上傳檔案 metadata。\n2. 從回應中取得簽名的上傳網址。\n3. 將實際圖片上傳到回傳的網址。\n4. 建立腹部塑形增強的 AI 任務。\n5. 設定 Webhook 或輪詢任務狀態直到完成。\n6. 處理成功後下載生成的結果圖片。\n\n---\n\n**步驟 1 — 使用 File API 上傳檔案 metadata**\n\n使用 `POST /s2s/v2.0/file` 建立檔案記錄，並取得來源圖片的上傳細節。\n\n```bash\ncurl --request POST \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/file \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json' \\\n  --data '{\n    \"files\": [\n      {\n        \"content_type\": \"image/jpg\",\n        \"file_name\": \"full_body_photo_01_3dbd1b6683.jpg\",\n        \"file_size\": 547541\n      }\n    ]\n  }'\n```\n\n**File API 回應範例：**\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"files\": [\n      {\n        \"content_type\": \"image/jpg\",\n        \"file_name\": \"full_body_photo_01_3dbd1b6683.jpg\",\n        \"file_id\": \"SaGaqpDgKwFrVBgMpQMA3HY0LeqdT9/13W5TOD8/u/FfjK3xgCQ+hRt9MJXBFaud\",\n        \"requests\": [\n          {\n            \"method\": \"PUT\",\n            \"url\": \"https://yce-us.s3-accelerate.amazonaws.com/demo/ttl30/...signature...\",\n            \"headers\": {\n              \"Content-Length\": \"547541\",\n              \"Content-Type\": \"image/jpg\"\n            }\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n---\n\n**步驟 2 — 取得 File API 回應細節**\n\n回應包含：\n\n| 欄位 | 說明 |\n| --- | --- |\n| `file_id` | 用於建立 AI 任務的識別碼。 |\n| `requests.url` | 用於上傳實際圖片檔案的簽名網址。 |\n| `requests.method` | 上傳方法，通常為 `PUT`。 |\n| `requests.headers` | 上傳請求所需的標頭。 |\n\n---\n\n**步驟 3 — 上傳圖片到提供的網址**\n\n使用 File API 回應中的 `requests.url` 上傳來源圖片。\n\n```bash\ncurl --location --request PUT 'https://yce-us.s3-accelerate.amazonaws.com/demo/ttl30/...signature...' \\\n  --header 'Content-Type: image/jpg' \\\n  --header 'Content-Length: 547541' \\\n  --data-binary @'./full_body_photo_01_3dbd1b6683.jpg'\n```\n\n---\n\n**步驟 4 — 建立 AI 任務**\n\n使用 `POST /s2s/v2.0/task/abs-shape` 建立腹部增強任務。\n\n| 參數 | 說明 | 範例 |\n| --- | --- | --- |\n| `src_file_id` | 從 File API 上傳流程回傳的檔案 ID。使用上傳檔案工作流程時為必要。 | `\"SaGaqpDgKwFrVBgMpQMA3HY0LeqdT9/13W5TOD8/u/FfjK3xgCQ+hRt9MJXBFaud\"` |\n| `src_file_url` | 來源圖片的直接網址。作為 `src_file_id` 的替代方案。 | `\"https://example.com/selfie.jpg\"` |\n| `mode` | 增強模式。支援的值為 `Six-pack` 與 `Vest-line`。 | `\"Six-pack\"` |\n| `intensity` | 腹部增強強度等級。 | `1` |\n\n**請求範例：**\n\n```javascript\nconst resp = await fetch(\n  'https://yce-api-01.makeupar.com/s2s/v2.0/task/abs-shape',\n  {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application/json',\n      Authorization: 'Bearer <YOUR_TOKEN_HERE>'\n    },\n    body: JSON.stringify({\n      src_file_url: 'https://example.com/selfie.jpg',\n      mode: 'Six-pack',\n      intensity: 1\n    })\n  }\n);\n\nconst data = await resp.json();\nconsole.log(data);\n```\n\n**AI 任務 API 回應：**\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"task_id\": \"SaGaqpDgKwFrVBgMpQMA3HY0LeqdT9_13W5TOD8_u_GPi6NqQ3dhlmN-6ntFwhzT\"\n  }\n}\n```\n\n---\n\n**步驟 5 — 設定 W/ook 或輪詢任務結果**\n\n設定與驗證細節請參考 [webhook 整合指南](/develop/webhook.md)。\n\n輪詢時，使用回傳的 `task_id` 查詢任務狀態。\n\n```bash\ncurl --request GET \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/task/abs-shape/<YOUR_TASK_ID> \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json'\n```\n\n---\n\n**步驟 6 — 取得結果圖片**\n\n處理成功時，回應會在 `data.results.url` 中包含下載網址。\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"error\": null,\n    \"results\": {\n      \"url\": \"https://yce-us.s3-accelerate.amazonaws.com/demo/ttl30/...signature...\"\n    },\n    \"task_status\": \"success\"\n  }\n}\n```\n\n**API Key 無效的回應：**\n\n若 access token 無效，API 會回傳 `401` 回應。\n\n```json\n{\n  \"status\": 401,\n  \"error\": \"Unauthorized\",\n  \"error_code\": \"InvalidAccessToken\"\n}\n```\n\n應用案例：\n![](https://plugins-media.makeupar.com/smb/blog/post/2025-08-21/307f87b4-d31c-481c-86f1-478c93265a95.jpg)\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2025-08-21/8ab8eca4-b825-4692-aef0-6ffd6176e272.jpg)\n\n---\n\n## 檔案規格與錯誤\n\n**檔案規格：**\n\n| 規格 | 需求 |\n| --- | --- |\n| 圖片類型 | 全身或上半身圖片。 |\n| 來源主體 | 一位可偵測的人物，兩側肩膀與腹部都可見。 |\n| 姿勢需求 | 支援的姿勢範圍為 `−45° < yaw < 45°`。 |\n| 多人處理 | 若偵測到多人，API 會自動選擇可見肩膀面積最大的人。 |\n| 長邊解析度上限 | 長邊不得超過 **4096 px**。 |\n| 檔案大小限制 | 必須低於 **10 MB**。 |\n| 支援的格式 | `jpg`、`png`。 |\n\n**錯誤代碼：**\n\n| 錯誤代碼 | 說明 |\n| --- | --- |\n| `exceed_max_filesize` | 來源圖片超過允許的最大尺寸或檔案大小。長邊不得超過 4096 px，檔案大小必須低於 10 MB。 |\n| `error_pose` | 姿勢偵測失敗，原因可能是未偵測到人物、肩膀可見度問題、腹部可見度問題、腰部區域偵測失敗、臀部關鍵點偵測失敗，或不受支援的姿勢範圍。 |\n| `error_nsfw_content_detected` | 在來源圖片或生成的結果圖片中偵測到潛在的 NSFW 內容。 |\n| `invalid_parameter` | 來源鍵、目標鍵、動作、模式值、強度等級或任務設定提供了無效的參數。 |\n| `error_download_image` | 無法成功下載來源圖片。 |\n| `error_decode_image` | 無法成功解碼來源圖片。 |\n\n**環境與相依性：**\n\n| 工具 / 語言 | 建議的執行環境版本 |\n| --- | --- |\n| cURL | Bash ≥ 3.2；curl ≥ 7.58（具現代 TLS/HTTP 支援）；jq ≥ 1.6（穩健的 JSON 解析）。 |\n| Node.js | Node ≥ 18（支援全域 `fetch`）。 |\n| JavaScript 瀏覽器支援 | Chrome / Edge ≥ 80、Firefox ≥ 74、Safari ≥ 13.1。 |\n| PHP | PHP ≥ 7.4（具現代 TLS 相容性）；建議 ext-curl，或 `allow_url_fopen=On` 並具備 OpenSSL 與 JSON 支援。 |\n| Python | Python ≥ 3.10（支援 f-strings）；requests ≥ 2.20.0。 |\n| Java | Java 11+（支援 HttpClient）；Jackson Databind ≥ 2.12.0。 |\n\n---\n\n## 點數消耗\n\n| AI 功能 | 消耗的點數 |\n|---|---|\n| AI 腹肌濾鏡 V1.0 | 1 |\n\n---\n",
    "version": "",
    "termsOfService": "https://www.makeupar.com/perfectbeauty/youcam/terms-of-service-api",
    "contact": {
      "email": "YouCamOnlineEditor_API@perfectcorp.com"
    },
    "license": {
      "name": "Privacy policy",
      "url": "https://www.makeupar.com/perfectbeauty/youcam/privacy-policy-api"
    }
  },
  "servers": [
    {
      "url": "https://yce-api-01.makeupar.com"
    }
  ],
  "tags": [
    {
      "name": "V1.0",
      "description": "使用 AI 腹肌濾鏡 API，以 AI 生成的六塊肌改變您的上半身照片。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/abs-shape": {
      "post": {
        "summary": "執行 AI 腹肌濾鏡任務。",
        "description": "AI 任務是非同步的。當功能支援 webhook 時，請優先使用以 webhook 為基礎的完成處理。設定您的 webhook 端點、驗證 webhook 簽章，並在收到 `success` 或 `error` 通知後，使用收到的 `task_id` 查詢任務結果。設定與驗證細節請見 [webhook 整合指南](/develop/webhook.md)。\n\n若您的整合不支援 webhook 或無法使用 webhook，請實作輪詢。送出 AI 任務後，以固定間隔（例如每 10 秒）輪詢狀態端點，直到任務狀態為 `success` 或 `error`。\n",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/BasicRunTaskV2"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "description": "使用者要選擇的腹肌特效。\n",
                        "default": "Six-pack",
                        "example": "Six-pack",
                        "enum": [
                          "Six-pack",
                          "Vest-line"
                        ]
                      },
                      "intensity": {
                        "type": "integer",
                        "description": "使用者希望調整腹肌的強度，2 是較強的強度。\n",
                        "default": 1,
                        "example": 1,
                        "enum": [
                          1,
                          2
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任務執行成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicRunTaskResponseV2"
                }
              }
            }
          },
          "400": {
            "description": "任務執行失敗",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/RunError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/s2s/v2.0/task/abs-shape/{task_id}": {
      "get": {
        "summary": "查詢 AI 腹肌濾鏡任務的狀態。",
        "x-display-name": "AI Abs Filter",
        "x-engine-version": "V1.0",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
            },
            "description": "要查詢的任務 ID"
          }
        ],
        "responses": {
          "200": {
            "description": "成功查詢任務狀態",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskStatusResponseV2"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidTaskId"
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "500": {
            "$ref": "#/components/responses/TaskTimeout"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用標準的 'Bearer authentication'。請在標頭中放入您的 'API Key'：`Authorization:Bearer YOUR_API_KEY`。請注意 'Bearer' 與 'YOUR_API_KEY' 之間有一個空格。"
      }
    },
    "schemas": {
      "BasicRunTaskV2SrcFileUrl": {
        "type": "object",
        "required": [
          "src_file_url"
        ],
        "properties": {
          "src_file_url": {
            "type": "string",
            "description": "要執行任務的檔案網址。該網址應可公開存取。",
            "example": "https://example.com/selfie.jpg"
          }
        }
      },
      "BasicRunTaskV2SrcFileId": {
        "type": "object",
        "required": [
          "src_file_id"
        ],
        "properties": {
          "src_file_id": {
            "type": "string",
            "description": "要執行任務的檔案 ID。檔案 ID 來自上傳檔案 API。",
            "example": "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
          }
        }
      },
      "BasicRunTaskV2": {
        "title": "BasicRunTaskV2",
        "anyOf": [
          {
            "title": "Run task with src file url",
            "allOf": [
              {
                "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
              }
            ]
          },
          {
            "title": "Run task with src file ID",
            "allOf": [
              {
                "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
              }
            ]
          }
        ]
      },
      "BasicRunTaskResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "回應狀態",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "這個任務的 ID。任務結果可以此 ID 查詢，有效期限 24 小時。",
                "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
              }
            }
          }
        }
      },
      "RunError": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "回應狀態",
            "example": 400
          },
          "error": {
            "type": "string",
            "description": "錯誤訊息",
            "example": "The operation could not be completed"
          },
          "error_code": {
            "type": "string",
            "enum": [
              "InvalidParameters",
              "CreditInsufficiency",
              "InvalidStyleGroup",
              "InvalidStyle",
              "BadRequest"
            ],
            "description": "錯誤代碼：\n* InvalidParameters - 請求參數無效\n* CreditInsufficiency - 點數不足，無法執行\n* BadRequest - 非預期的請求參數\n* InvalidStyleGroup - 風格群組 id 無效\n* InvalidStyle - 風格 id 無效\n"
          }
        }
      },
      "EngineErrorCode": {
        "type": "string",
        "nullable": true,
        "enum": [
          "error_exceed_max_image_size",
          "exceed_max_filesize",
          "invalid_parameter",
          "error_download_image",
          "error_download_mask",
          "error_decode_image",
          "error_decode_mask",
          "error_nsfw_content_detected",
          "error_no_face",
          "error_pose",
          "error_face_parsing",
          "error_inference",
          "exceed_nsfw_retry_limits",
          "error_upload",
          "unknown_internal_error"
        ],
        "description": "錯誤：\n- \\`error_exceed_max_image_size\\`  - 輸入圖片尺寸超過上限\n- \\`exceed_max_filesize\\` - 輸入檔案大小超過上限\n- \\`invalid_parameter\\` - 參數值無效\n- \\`error_download_image\\` - 下載來源圖片錯誤\n- \\`error_download_mask\\` - 下載遮罩圖片錯誤\n- \\`error_decode_image\\` - 解析來源圖片錯誤\n- \\`error_decode_mask\\` - 解析遮罩圖片錯誤\n- \\`error_nsfw_content_detected\\` - 在來源圖片中偵測到 NSFW 內容\n- \\`error_no_face\\` - 來源圖片未偵測到臉部\n- \\`error_pose\\` - 無法偵測來源圖片的姿势\n- \\`error_face_parsing\\` - 無法對來源圖片進行臉部分割\n- \\`error_inference\\` - 推論流程錯誤\n- \\`exceed_nsfw_retry_limits\\` - 超過重試上限以避免產生 NSFW 圖片\n- \\`error_upload\\` - 上傳結果圖片錯誤\n- \\`unknown_internal_error\\` - 其他"
      },
      "TaskStatusResponseBodySingleUrlResultsV2": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "下載這個結果的網址。有效期限 2 小時",
            "example": "https://example.com/sample-result-url"
          }
        }
      },
      "TaskStatusResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "回應狀態",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_status": {
                "type": "string",
                "enum": [
                  "running",
                  "success",
                  "error"
                ],
                "description": "這個任務的狀態"
              },
              "error": {
                "$ref": "#/components/schemas/EngineErrorCode"
              },
              "error_message": {
                "type": "string",
                "description": "錯誤的詳細說明"
              },
              "results": null
            }
          }
        },
        "$ref": "#/components/schemas/TaskStatusResponseBodySingleUrlResultsV2"
      }
    },
    "responses": {
      "InvalidApiKey": {
        "description": "API 金鑰無效或缺失",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid API key"
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "請求過多",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 429,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Too many requests"
                }
              }
            }
          }
        }
      },
      "InvalidTaskId": {
        "description": "任務 ID 無效",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 400,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid task ID"
                }
              }
            }
          }
        }
      },
      "TaskTimeout": {
        "description": "任務執行逾時",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 500,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Task execution timed out"
                }
              }
            }
          }
        }
      }
    }
  }
}