{"templateId":"api_docs","sharedDataIds":{"apiDocsStore":"api-docs-@l10n/zh-CN/reference/ai_outfit_mix_and_match.yaml","sidebar":"sidebar-@l10n/zh-CN/reference/sidebars.yaml"},"props":{"definitionId":"@l10n/zh-CN/reference/ai_outfit_mix_and_match.yaml","settings":{"baseUrlPath":"/zh-cn/reference/ai_outfit_mix_and_match"},"disableAutoScroll":true,"seo":{"title":"AI 时装虚拟试穿 Mix & Match","description":"YouCam API documentation by Perfect Corp. Learn how to use Skin analysis API, Virtual try-on API, Image editing API, and Video generative AI APIs.","siteUrl":"https://docs.perfectcorp.com","keywords":"AI Skin Analysis, AI Clothes, AI Hairstyle, AI Outfits","image":"/assets/favicon.cd6fa4d833b2a573b3c6dae68386b293da205b203402cb0c97b80bd2acc07ea2.8351e24f.png"},"dynamicMarkdocComponents":[],"metadata":{"type":"openapi","title":"AI 时装虚拟试穿 Mix & Match","version":"","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"},"compilationErrors":[],"markdown":{"partials":{},"variables":{"rbac":{"teams":["anonymous"]},"user":{},"remoteAddr":{"hostname":"docs.perfectcorp.com","port":4000,"ipAddress":"216.73.216.89"},"lang":"zh-CN","env":{"PUBLIC_REDOCLY_BRANCH_NAME":"master"}}},"pagePropGetterError":{"message":"","name":""}},"slug":"/zh-cn/reference/ai_outfit_mix_and_match","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}