{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 时装虚拟试穿 Mix & Match",
    "description": "# 概览 (Overview)\n一次调用试穿整套穿搭。送一张用户照片加上 1 到 9 张单品参考图，AI Outfit Virtual Try-On Mix & Match API 会一次为人物穿上所有单品，返回一张完整造型照。\n\n* 一次调用、一套造型：单个任务就让人物穿上全部参考单品，结果照片恰好一张。\n* 八类单品：`upper_body`、`lower_body`、`full_body`、`outer`、`shoes`、`bag`、`headwear`、`accessory`。\n* 穿法备注：可以说明怎么穿，例如\"外套敞开穿\"\"上衣扎进裤腰\"。只改变穿法，不会动单品本身、人物或姿势。\n\n使用示例：\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2026-10-22/webp_23606d07-1943-449d-93d5-9ee8fa69dc38.webp)\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2026-10-16/webp_972912f5-866d-4134-9347-45bde4991724.webp)\n\n---\n\n## 接入指南 (Integration Guide)\n\n* AI 时装虚拟试穿 Mix & Match 使用指南\n\n本指南说明如何上传用户照片与参考单品、创建试穿任务并解读结果。任务采用异步：创建任务的响应会给出任务 ID，您轮询状态端点获取结果。\n\n***\n\n   * 第 1 步：用 File API 上传照片\n\n用 **File API**（`/s2s/v2.0/file`）上传一张用户照片和 1 到 9 张参考图，每张图一个单品。响应会给出每个文件的 `file_id` 和 `requests.url`，把文件内容上传到该 URL 即可。您也可以把照片放在公开网址，直接传 URL。\n\n请保持参考图与单品类别的顺序一致：第 n 张参考图对应 `garment_categories` 第 n 个类别的单品。\n\n***\n\n   * 第 2 步：创建试穿任务\n\n用 **AI 任务 API**（`/s2s/v2.0/task/cloth-mix-v2`），传入用户照片、参考图、每张图的类别，以及可选的穿法备注：\n\n```bash\ncurl --request POST \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/task/cloth-mix-v2 \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json' \\\n  --data '{\n    \"src_file_url\": \"https://example.com/selfie.jpg\",\n    \"ref_file_urls\": [\n      \"https://example.com/1.jpg\",\n      \"https://example.com/2.jpg\",\n      \"https://example.com/3.jpg\"\n    ],\n    \"garment_categories\": [\"upper_body\", \"lower_body\", \"shoes\"],\n    \"styling_note\": \"tuck the top in\"\n  }'\n```\n\n    > `garment_categories` 必填，长度必须与参考图数组一致；长度不符会返回 `invalid_parameter`。任务大约需要 40 到 50 秒，附穿法备注会多 3 到 4 秒。超过 400 秒仍未完成的任务会以 `unknown_internal_error` 失败，可重试。\n\n***\n\n   * 第 3 步：轮询任务结果\n\n用创建任务响应里的 `task_id` 查询状态，直到 `task_status` 变成 `success` 或 `error`：\n\n```bash\ncurl --request GET \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/task/cloth-mix-v2/YOUR_TASK_ID \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json'\n```\n\n***\n\n   * 第 4 步：获取结果\n\n成功的响应会返回一张造型照。带了穿法备注时，`not_applied` 会列出没有照做的部分及原因；其余一律照常套用。\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"error\": null,\n    \"results\": {\n      \"url\": \"https://example.com/sample-result-url\",\n      \"not_applied\": \"bottom high-waisted: the trousers are already high-waisted\"\n    },\n    \"task_status\": \"success\"\n  }\n}\n```\n\n    > 只有返回结果照片时才消耗点数。以错误结束的任务不扣点。\n\n---\n\n## 输入与输出 (Inputs & Outputs)\n\n* 请求体\n\n`src_file_url` / `src_file_id`：二选一。`ref_file_urls` / `ref_file_ids`：二选一。\n\n| 字段 | 类型 | 必填 | 默认 | 说明 |\n|---|---|---|---|---|\n| src_file_url / src_file_id | string | 是* | - | 用户照片，公开可访问的 URL 或 File API 的文件 ID |\n| ref_file_urls / ref_file_ids | string 数组 | 是* | - | 1 到 9 张参考图，每张一个单品，顺序与 `garment_categories` 一致 |\n| garment_categories | string 数组（enum） | 是 | - | 每张参考图的类别，顺序和长度与参考图数组一致：`upper_body`、`lower_body`、`full_body`、`outer`、`shoes`、`bag`、`headwear`、`accessory` |\n| styling_note | string | 否 | `\"\"` | 穿法备注，最多 300 字符自由文字，例如 \"tuck the top in\"、\"wear the jacket open\"、\"carry the bag crossbody\" |\n\n* 单品类别\n\n| garment_category | 内容 | 上限 |\n|---|---|---|\n| upper_body | 上装 | 1 |\n| lower_body | 下装 | 1 |\n| full_body | 连身款，例如连衣裙 | 1，不可与 `upper_body` 或 `lower_body` 并用 |\n| outer | 外套、马甲 | 1 |\n| shoes | 鞋子 | 1 |\n| bag | 包 | 1 |\n| headwear | 帽子、发带 | 1 |\n| accessory | 眼镜、项链、耳环、手表、腰带、围巾 | 3 |\n\n    > 您发送的类别会照原样使用，引擎不会重新分类。配饰的摆放位置由引擎决定，新配饰会替换人物在同一位置佩戴的既有配饰。\n\n* 结果（`data.results`）\n\n| 字段 | 类型 | 说明 |\n|---|---|---|\n| url | string | 下载结果照片的 URL。有效期 2 小时 |\n| not_applied | string | `styling_note` 中未套用的部分及原因。只在给了 `styling_note` 时返回 |\n\n---\n\n## 文件规格与错误码 (File Specs & Errors)\n\n* 支持格式与尺寸\n\n| 项目 | 支持尺寸 | 支持文件大小 | 支持格式 |\n|---|---|---|---|\n| 用户照片 | 正面照片。最小 512 x 384，最长边 4096 px。宽高比上限 3:1，超出部分从中间裁切 | < 10MB | JPEG, PNG, HEIC |\n| 参考图 | 最小 512 x 384，最长边 4096 px。不裁切（腰带、项链类可超过 3:1） | < 10MB | JPEG, PNG, HEIC |\n| 结果照片 | 保持用户照片的宽高比，上限约 1.5 MP（1024 x 1536）；最长边低于 1024 会放大到 1024。例：3000 x 4000 -> 1072 x 1440、4000 x 1000 -> 2160 x 720 | - | JPEG |\n\n    > 透明背景的照片会在白底上合成。结果照片带有 C2PA 签名。\n\n* 错误码\n\n| 错误码 | 说明 |\n|---|---|\n| invalid_parameter | 参数缺失或无效；消息会指明是哪个参数 |\n| error_download_image | 无法下载用户照片或参考图 |\n| error_invalid_src | 无法读取用户照片 |\n| error_invalid_ref | 无法读取参考图 |\n| error_analyze_failed | 单品分析失败或超时 |\n| error_ref_categories | 这些单品无法一起穿：类别重复、`full_body` 与 `upper_body`/`lower_body` 并用、`bag` 或 `headwear` 超过 1 个、`accessory` 超过 3 个 |\n| error_nsfw_content_detected | 检测到不当内容，拒绝生成 |\n| unknown_internal_error | 其他错误，含 400 秒内未完成的任务 |\n\n---\n\n## 点数消耗 (Unit Consumption)\n\n| 参考单品数 | 消耗点数 |\n|---|---|\n| 1 件试穿 | 3 点 |\n| 2 件试穿 | 4 点 |\n| 3 件试穿 | 5 点 |\n| 4 件试穿 | 6 点 |\n| 5 件试穿 | 7 点 |\n| 6 件试穿 | 8 点 |\n| 7 件试穿 | 9 点 |\n| 8 件试穿 | 10 点 |\n| 9 件试穿 | 11 点 |\n\n    > 只有返回结果照片时才消耗点数；以错误结束的任务不扣点。\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 时装虚拟试穿 Mix & Match API 在单个任务中，让一张用户照片穿上 1 到 9 张单品参考图。每张参考图附上单品类别，用穿法备注说明怎么穿，就能拿到一张完整造型照。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/cloth-mix-v2": {
      "post": {
        "summary": "运行 AI 时装虚拟试穿 Mix & Match 任务。",
        "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": {
                "anyOf": [
                  {
                    "allOf": [
                      {
                        "title": "用 src file url 与 ref file urls 运行任务",
                        "required": [
                          "ref_file_urls"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileUrls"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "title": "用 src file url 与 ref file IDs 运行任务",
                        "required": [
                          "ref_file_ids"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileIds"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "title": "用 src file ID 与 ref file urls 运行任务",
                        "required": [
                          "ref_file_urls"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileUrls"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "title": "用 src file ID 与 ref file IDs 运行任务",
                        "required": [
                          "ref_file_ids"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileIds"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "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/cloth-mix-v2/{task_id}": {
      "get": {
        "summary": "查询 AI 时装虚拟试穿 Mix & Match 任务状态。",
        "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": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/TaskStatusResponseV2"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "object",
                              "properties": {
                                "not_applied": {
                                  "type": "string",
                                  "description": "styling_note 中未套用的部分及原因。只在给了 styling_note 时返回"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidTaskId"
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "500": {
            "$ref": "#/components/responses/TaskTimeout"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClothMixRefFileUrls": {
        "type": "object",
        "properties": {
          "ref_file_urls": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "description": "1 到 9 张参考图的 URL，每张一个单品。第 n 张图对应 garment_categories 第 n 个类别的单品。URL 必须可公开访问。",
            "example": [
              "https://example.com/full_body.jpg",
              "https://example.com/shoes.jpg"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ClothMixRefFileIds": {
        "type": "object",
        "properties": {
          "ref_file_ids": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "description": "1 到 9 张参考图的 ID，每张一个单品。第 n 张图对应 garment_categories 第 n 个类别的单品。ID 来自上传文件 API。",
            "example": [
              "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ClothMixTaskParams": {
        "type": "object",
        "required": [
          "garment_categories"
        ],
        "properties": {
          "garment_categories": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "description": "每张参考图的类别，顺序和长度与 ref_file_urls（或 ref_file_ids）一致。除 accessory 最多 3 个外，每个类别以一个单品为限；full_body 不可与 upper_body 或 lower_body 并用。",
            "example": [
              "full_body",
              "shoes"
            ],
            "items": {
              "type": "string",
              "enum": [
                "upper_body",
                "lower_body",
                "full_body",
                "outer",
                "shoes",
                "bag",
                "headwear",
                "accessory"
              ]
            }
          },
          "styling_note": {
            "type": "string",
            "maxLength": 300,
            "default": "",
            "description": "单品的穿法，例如 \"jacket open\"（外套敞开）、\"top tucked in\"（上衣扎进裤腰）、 \"bag cross body\"（包斜挎）。只改变穿法，不会动单品本身、人物或姿势。无法套用的部分会被跳过， 并列在结果的 not_applied 中。",
            "example": "top tucked in"
          }
        }
      },
      "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="
          }
        }
      },
      "BasicRunTaskResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "响应状态",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "该任务的 ID。凭这个 ID 可在 30 天内查询任务结果。",
                "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"
      }
    },
    "securitySchemes": {
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用标准的 Bearer 鉴权。把您的 API 密钥放进请求头： `Authorization:Bearer YOUR_API_KEY`。请注意 'Bearer' 与 'YOUR_API_KEY' 之间有一个空格。"
      }
    },
    "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"
                }
              }
            }
          }
        }
      }
    }
  }
}