{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 腹肌滤镜",
    "description": "# 概览\n\nAI 腹肌滤镜接口（**AI Abs Filter 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- 支持单人处理。画面中有多人时，接口会自动选取肩部可见面积最大的那位。\n\n**流程：**\n\n1. 用 File 接口上传文件元数据。\n2. 从响应中取得签名的上传 URL。\n3. 把实际图片上传到该 URL。\n4. 创建腹肌增强的 AI 任务。\n5. 配置 Webhook，或轮询任务状态直到完成。\n6. 处理成功后下载生成的结果图片。\n\n---\n\n**第 1 步 — 用 File 接口上传文件元数据**\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 接口响应示例：**\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 接口响应内容**\n\n响应包含：\n\n| 字段 | 说明 |\n| --- | --- |\n| `file_id` | 用于创建 AI 任务的标识。 |\n| `requests.url` | 上传实际图片文件的签名 URL。 |\n| `requests.method` | 上传方式，通常为 `PUT`。 |\n| `requests.headers` | 上传请求所需的请求头。 |\n\n---\n\n**第 3 步 — 把图片上传到提供的 URL**\n\n用 File 接口响应中的 `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 接口上传流程返回的文件 ID。走上传文件流程时必填。 | `\"SaGaqpDgKwFrVBgMpQMA3HY0LeqdT9/13W5TOD8/u/FfjK3xgCQ+hRt9MJXBFaud\"` |\n| `src_file_url` | 源图的直接 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 任务接口响应：**\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 步 — 配置 Webhook 或轮询任务结果**\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` 中给出下载 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 密钥无效的响应：**\n\n访问令牌无效时，接口返回 `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| 多人处理 | 检测到多人时，接口会自动选取肩部可见面积最大的那位。 |\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-string）；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 腹肌滤镜接口，给上半身照片加上 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 鉴权。把您的 API 密钥放进请求头： `Authorization:Bearer YOUR_API_KEY`。请注意 'Bearer' 与 'YOUR_API_KEY' 之间有一个空格。"
      }
    },
    "schemas": {
      "BasicRunTaskV2SrcFileUrl": {
        "type": "object",
        "required": [
          "src_file_url"
        ],
        "properties": {
          "src_file_url": {
            "type": "string",
            "description": "用于运行任务的文件 URL，该 URL 需可公开访问。",
            "example": "https://example.com/selfie.jpg"
          }
        }
      },
      "BasicRunTaskV2SrcFileId": {
        "type": "object",
        "required": [
          "src_file_id"
        ],
        "properties": {
          "src_file_id": {
            "type": "string",
            "description": "用于运行任务的文件 ID，取自上传文件接口返回的 file_id。",
            "example": "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
          }
        }
      },
      "BasicRunTaskV2": {
        "title": "BasicRunTaskV2",
        "anyOf": [
          {
            "title": "用源文件 URL 运行任务",
            "allOf": [
              {
                "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
              }
            ]
          },
          {
            "title": "用源文件 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\\` - 为避免生成不适宜内容， 重试次数已用尽\n- \\`error_upload\\` - 上传结果图片出错\n- \\`unknown_internal_error\\` - 其他错误\n"
      },
      "TaskStatusResponseBodySingleUrlResultsV2": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "下载该结果的 URL，有效期 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"
                }
              }
            }
          }
        }
      }
    }
  }
}