{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 发色虚拟试染",
    "description": "# 概览\n用 AI 发色虚拟试染玩遍各种发色！一直想试的发色尽管试，没试过的新鲜色号也能玩。拉一拉滑杆就能调整所选颜色的浓淡，做出专属您的效果。\n\n   * 上传图片\n\n上传您要改发色的照片。\n\n   * 选预设色，或按图案与配色自行调配\n\n从预设色里挑，也能微调渐变（ombre）的覆盖范围与融合度，玩法无穷！\n\n> **警告：** 若同时指定了预设色与图案 + 配色，以预设色优先。\n\n> **警告：** 源图必须包含您要染的头发区域，套用前请再确认一次。源图里没带上想染的头发区域，后果需由您自行承担。\n\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/hair_color_s2_poster_dt_v2_49198cabc0.png)\n\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/01_1_1_8365c3b503.jpg)\n\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/01_2_1_abfcdb7eba.jpg)\n\n## 文件规格与错误码\n* 支持的格式与尺寸\n\n|AI 功能|支持尺寸|支持文件大小|支持格式|\n|  ----  | ----  | ----  | ----  |\n|AI 发色虚拟试染|长边 < 1920，脸宽 >= 100|< 10MB|jpg/jpeg/png|\n\n* 错误码\n\n|错误码|说明|\n|  ----  | ----  |\n|error_below_min_image_size|源图尺寸小于下限（要求：宽 >= 320px，高 >= 320px）\n|error_exceed_max_image_size|源图尺寸超过上限（要求：宽 < 1920px，高 < 1080px）\n\n* 运行环境与依赖\n\n| 示例代码语言 / 工具 | 建议运行时版本 |\n|---|---|\n| cURL | - bash >= 3.2</br>   - curl >= 7.58 (modern TLS/HTTP support)</br>   - jq >= 1.6 (robust JSON parsing) |\n| Node.js (JavaScript) | Node >= 18 (for global fetch) |\n| JavaScript | - Chrome / Edge >= 80</br>   - Firefox >= 74</br>   - Safari >= 13.1 |\n| PHP | PHP >= 7.4 (for modern TLS/compat), ext-curl (recommended) or allow_url_fopen=On + ext-openssl, ext-json |\n| Python | Python >= 3.10 (for f-strings), requests >= 2.20.0 |\n| Java | Java 11+ (for HttpClient), Jackson Databind >= 2.12.0 |\n\n---\n\n## 点数消耗\n\n| AI 功能 | 消耗点数 |\n|---|---|\n| AI 发色虚拟试染虚拟试戴 V1.0 | 全头模式 1 点数 <br> 渐变模式 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 处理上传的图片更换发色，支持预设配色与自定义色板。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/hair-color": {
      "post": {
        "summary": "执行 AI 发色虚拟试染 任务。",
        "description": "本接口用于发起 AI 发色虚拟试染流程。您需要提供源文件（URL 或文件 ID），并指定上色方式（预设 preset、图案 pattern 或色板 palettes）。任务会异步处理，您可以使用本响应返回的 task_id 查询其状态。\n",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunHairColorTaskV2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AI 发色虚拟试染 任务执行成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicRunTaskResponseV2"
                }
              }
            }
          },
          "400": {
            "description": "任务执行失败",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/responses/RunError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/s2s/v2.0/task/hair-color/{task_id}": {
      "get": {
        "summary": "查询 AI 发色虚拟试染 任务的状态。",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
            },
            "description": "要查询的任务 ID"
          }
        ],
        "responses": {
          "200": {
            "description": "AI 发色虚拟试染 任务状态查询成功",
            "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": {
      "EngineErrorCode": {
        "type": "string",
        "nullable": true,
        "enum": [
          "exceed_max_filesize",
          "invalid_parameter",
          "error_download_image",
          "error_decode_image",
          "error_nsfw_content_detected",
          "error_inference",
          "unknown_internal_error"
        ],
        "description": "错误码：\n\n- `exceed_max_filesize` - 输入文件大小超出上限\n\n- `invalid_parameter` - 参数取值无效\n\n- `error_download_image` - 下载原图出错\n\n- `error_decode_image` - 解码原图出错\n\n- `unknown_internal_error` - 其他错误\n"
      },
      "FileV1.1": {
        "title": "File V1.1",
        "description": "该对象表示一个文件。",
        "type": "object",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "content_type",
                "file_name",
                "file_size"
              ],
              "properties": {
                "content_type": {
                  "type": "string",
                  "example": "image/jpg",
                  "description": "该文件的 MIME 类型。当前支持的取值见上方的枚举。"
                },
                "file_name": {
                  "type": "string",
                  "example": "my-selfie.jpg",
                  "description": "文件名"
                },
                "file_size": {
                  "type": "integer",
                  "example": 50000,
                  "description": "该文件的大小（字节）。不应超过 10MB。"
                }
              }
            }
          }
        }
      },
      "BasicFileResponse": {
        "type": "object",
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "content_type": {
                  "type": "string",
                  "example": "image/jpg",
                  "description": "该文件的 MIME 类型。"
                },
                "file_name": {
                  "type": "string",
                  "example": "my-selfie.jpg",
                  "description": "文件名"
                },
                "file_id": {
                  "type": "string",
                  "example": "U8aqJbsXGT537jtGnEDFHqxdDXqh8+oTF/cSkLimzuvVwMP+Jb1XbjPsf7ZgUgLY",
                  "description": "该文件的 ID。其他运行任务的接口需要用到这个 `file_id`。"
                },
                "requests": {
                  "type": "array",
                  "description": "请用下面的 `url`、`headers`、`method` 上传文件。上传完成后，用 `file_id` 继续调用运行任务接口。",
                  "items": {
                    "type": "object",
                    "properties": {
                      "headers": {
                        "type": "object",
                        "example": {
                          "Content-Type": "image/jpg",
                          "Content-Length": 50000
                        },
                        "description": "上传文件时需携带的请求头"
                      },
                      "url": {
                        "type": "string",
                        "example": "https://example.com/presigned-upload-url",
                        "description": "上传该文件的 URL"
                      },
                      "method": {
                        "type": "string",
                        "example": "PUT",
                        "description": "上传该文件所用的 HTTP 方法"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "FileResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 200,
            "description": "响应状态"
          },
          "data": {
            "$ref": "#/components/schemas/BasicFileResponse"
          }
        }
      },
      "BasicRunTaskV2SrcFileUrl": {
        "title": "用源文件 URL 运行任务",
        "type": "object",
        "required": [
          "src_file_url"
        ],
        "properties": {
          "src_file_url": {
            "type": "string",
            "description": "用于运行任务的文件 URL，该 URL 需可公开访问。",
            "example": "https://example.com/selfie.jpg"
          }
        }
      },
      "BasicRunTaskV2SrcFileId": {
        "title": "用源文件 ID 运行任务",
        "type": "object",
        "required": [
          "src_file_id"
        ],
        "properties": {
          "src_file_id": {
            "type": "string",
            "description": "用于运行任务的文件 ID，取自上传文件接口返回的 file_id。",
            "example": "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
          }
        }
      },
      "BasicRunTaskV2": {
        "title": "BasicRunTaskV2",
        "anyOf": [
          {
            "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
          },
          {
            "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
          }
        ]
      },
      "RunHairColorTaskParams": {
        "type": "object",
        "properties": {
          "preset": {
            "type": "string",
            "description": "（可选；当 pattern 与 palettes 都未提供时必填）\n默认发色预设。全头模式可选：['Jet Black', 'Chocolate Brown',\n'Honey Blonde', 'Platinum Blonde', 'Ash Gray', 'Rose Gold',\n'Burgundy', 'Copper Red', 'Lavender', 'Teal Blue']\n渐层模式可选：['Dark Brown/Caramel Blonde', 'Jet Black/Silver Gray',\n'Ash Brown/Lavender', 'Rose Gold/Peach Blonde', 'Burgundy/Magenta Pink',\n'Deep Blue/Teal Green', 'Plum Purple/Pastel Lilac',\n'Copper Red/Golden Blonde', 'Dark Gray/Ice Blonde',\n'Midnight Blue/Denim Blue']\n",
            "enum": [
              "Jet Black",
              "Chocolate Brown",
              "Honey Blonde",
              "Platinum Blonde",
              "Ash Gray",
              "Rose Gold",
              "Burgundy",
              "Copper Red",
              "Lavender",
              "Teal Blue",
              "Dark Brown/Caramel Blonde",
              "Jet Black/Silver Gray",
              "Ash Brown/Lavender",
              "Rose Gold/Peach Blonde",
              "Burgundy/Magenta Pink",
              "Deep Blue/Teal Green",
              "Plum Purple/Pastel Lilac",
              "Copper Red/Golden Blonde",
              "Dark Gray/Ice Blonde",
              "Midnight Blue/Denim Blue"
            ]
          },
          "pattern": {
            "type": "object",
            "description": "（可选；未提供 preset 时必填）",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "enum": [
                  "ombre",
                  "full"
                ],
                "description": "图案类型（必填）"
              },
              "blend_strength": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "description": "（可选；做渐层时必填）融合强度（0–100）"
              },
              "line_offset": {
                "type": "number",
                "minimum": -0.99,
                "maximum": 0.99,
                "description": "（可选；做渐层时必填）垂直偏移（–0.99 到 0.99）。\n0.99：上层颜色覆盖下半部分的 99%；–0.99：下层颜色覆盖上半部分的 99%\n"
              },
              "coloring_section": {
                "type": "string",
                "enum": [
                  "top"
                ],
                "description": "（可选；做渐层时必填）要上色的区域"
              }
            }
          },
          "palettes": {
            "type": "array",
            "description": "（可选；未提供 preset 时必填）数组长度：全头模式为 1，渐层模式为 2\n",
            "minItems": 1,
            "maxItems": 2,
            "items": {
              "type": "object",
              "required": [
                "color"
              ],
              "properties": {
                "color": {
                  "type": "string",
                  "pattern": "^#([A-Fa-f0-9]{6})$",
                  "description": "十六进制色值"
                },
                "color_intensity": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100,
                  "description": "上色强度（0–100）"
                },
                "shine_intensity": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100,
                  "description": "光泽强度（0–100）"
                }
              }
            }
          }
        }
      },
      "RunHairColorTaskV2": {
        "title": "RunHairColorTaskV2",
        "description": "该对象表示一次 AI 发色虚拟试染任务的运行。",
        "type": "object",
        "allOf": [
          {
            "$ref": "#/components/schemas/BasicRunTaskV2"
          },
          {
            "$ref": "#/components/schemas/RunHairColorTaskParams"
          }
        ]
      },
      "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"
              }
            }
          }
        }
      },
      "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": {
                "$ref": "#/components/schemas/TaskStatusResponseBodySingleUrlResultsV2"
              }
            }
          }
        }
      }
    },
    "responses": {
      "InvalidParameters": {
        "description": "请求参数无效",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 400,
                  "description": "响应状态"
                },
                "error": {
                  "type": "string",
                  "description": "错误信息",
                  "example": "The operation could not be completed"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidParameters"
                  ]
                }
              }
            }
          }
        }
      },
      "InvalidApiKey": {
        "description": "API 密钥无效、已停用或已过期",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "响应状态"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidApiKey",
                    "InactiveApiKey",
                    "ExpiredApiKey"
                  ]
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "单位时间内请求过多"
      },
      "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": [
              "CreditInsufficiency",
              "InvalidStyleGroup",
              "InvalidStyle",
              "BadRequest",
              "InvalidParameters"
            ]
          }
        }
      },
      "TaskTimeout": {
        "description": "任务在预期时间内没有响应",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "响应状态",
                  "example": 500
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "TaskTimeout"
                  ]
                }
              }
            }
          }
        }
      },
      "InvalidTaskId": {
        "description": "任务 ID 无效",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "响应状态",
                  "example": 400
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidTaskId"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}