{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 图片扩展",
    "description": "# 概览\n用尖端的 AI 图片扩展体验出色的画面延展。任意比例都能无损扩展，配合先进 AI 技术，让创意彻底放开。扩图同时保住最高画质，风格与美感都不打折。这款好用的 AI 工具支持一键自动扩展背景，照片即刻换貌。多亏先进的上下文感知技术，每位观者都能看到连贯入画的画面。\n\n![AI Image Extender](https://bcw-media.s3.ap-northeast-1.amazonaws.com/yce_web_outpainting_S1_img_03_cf19a018d9.jpg \"AI Image Extender\")\n\n不管是为了发 Instagram，还是想裱起来当数码作品，都有多种尺寸与比例供您挑选。您尽管调、尽管改，AI 会在旁边无缝收尾，保证扩展出来的区域与原图严丝合缝。\n\n![AI Image Extender](https://bcw-media.s3.ap-northeast-1.amazonaws.com/yce_web_outpainting_S1_img_01_1876fb85a5.jpg \"AI Image Extender\")\n\n\n## 文件规格与错误码\n* 支持的格式与尺寸\n\n| AI 功能 | 支持尺寸 | 支持文件大小 | 支持格式 |\n| ---- | ---- | ----  | ---- |\n| AI 图片扩展 | 长边 <= 4096 | < 10MB | jpg/jpeg |\n\n* 错误码\n\n|错误码|说明|\n|  ----  | ----  |\n| exceed_max_filesize |\t输入文件大小超出上限 |\n| invalid_parameter |\t参数取值无效 |\n| error_download_image\t| 下载原图出错 |\n| error_decode_image\t| 解码原图出错 |\n| error_nsfw_content_detected\t| 在原图中检测到不适宜内容（NSFW） |\n\n---\n\n## 点数消耗\n\n| AI 功能 | 消耗点数 |\n|---|---|\n| AI 图片扩展 V2.0 | 2 |\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": "V2.0",
      "description": "AI 图片扩展接口通过在图片四周生成新内容（扩图）来扩大画面尺寸。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/out-paint": {
      "post": {
        "summary": "执行 AI 图片扩展 任务。",
        "description": "查询任务状态请参见轮询指南。本接口需要 3 个关键参数：输入图片、锚点、输出图片。",
        "tags": [
          "V2.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunOutPaintTaskRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务执行成功",
            "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": {
            "description": "单位时间内请求过多",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/s2s/v2.0/task/out-paint/{task_id}": {
      "get": {
        "summary": "查询 AI 图片扩展 任务的状态。",
        "tags": [
          "V2.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": {
    "schemas": {
      "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"
          }
        ]
      },
      "OutPaintTaskParams": {
        "type": "object",
        "required": [
          "output_width",
          "output_height",
          "input_x",
          "input_y",
          "input_width",
          "input_height",
          "crop_input_x",
          "crop_input_y",
          "crop_input_width",
          "crop_input_height"
        ],
        "properties": {
          "output_width": {
            "type": "integer",
            "description": "输出图片宽度，取值范围 [1 - 4096]",
            "example": 960,
            "minimum": 1,
            "maximum": 4096
          },
          "output_height": {
            "type": "integer",
            "description": "输出图片高度，取值范围 [1 - 4096]",
            "example": 1280,
            "minimum": 1,
            "maximum": 4096
          },
          "input_x": {
            "type": "integer",
            "description": "源图片在输出图片中的左侧位置。坐标按从上到下、从左到右排列。取值范围：[0 - 4096]",
            "example": 240,
            "minimum": 0,
            "maximum": 4096
          },
          "input_y": {
            "type": "integer",
            "description": "源图片在输出图片中的顶部位置。坐标按从上到下、从左到右排列。取值范围：[0 - 4096]",
            "example": 320,
            "minimum": 0,
            "maximum": 4096
          },
          "input_width": {
            "type": "integer",
            "description": "源图片宽度。input_x + input_width 必须 <= output_width。取值范围：[1 - 4096]",
            "example": 480,
            "minimum": 1,
            "maximum": 4096
          },
          "input_height": {
            "type": "integer",
            "description": "源图片高度。input_y + input_height 必须 <= output_height。取值范围：[1 - 4096]",
            "example": 640,
            "minimum": 1,
            "maximum": 4096
          },
          "crop_input_x": {
            "type": "integer",
            "description": "从 x 处裁切源图片。坐标按从上到下、从左到右排列。取值范围：[0 - 4096]",
            "example": 0,
            "minimum": 0,
            "maximum": 4096
          },
          "crop_input_y": {
            "type": "integer",
            "description": "从 y 处裁切源图片。坐标按从上到下、从左到右排列。取值范围：[0 - 4096]",
            "example": 0,
            "minimum": 0,
            "maximum": 4096
          },
          "crop_input_width": {
            "type": "integer",
            "description": "按 crop_input_width 的宽度裁切源图片。取值范围：[1 - 4096]",
            "example": 480,
            "minimum": 1,
            "maximum": 4096
          },
          "crop_input_height": {
            "type": "integer",
            "description": "按 crop_input_height 的高度裁切源图片。取值范围：[1 - 4096]",
            "example": 640,
            "minimum": 1,
            "maximum": 4096
          }
        }
      },
      "RunOutPaintTaskRequest": {
        "title": "RunOutPaintTaskRequest",
        "description": "AI 图片扩展接口需要 3 个关键参数：输入图片、锚点与输出图片。 输出图片的尺寸必须大于输入图片。",
        "allOf": [
          {
            "$ref": "#/components/schemas/BasicRunTaskV2"
          },
          {
            "$ref": "#/components/schemas/OutPaintTaskParams"
          }
        ]
      },
      "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"
              }
            }
          }
        }
      },
      "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"
              }
            }
          }
        }
      },
      "TaskStatusResponseBodySingleUrlResultsV2": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "下载该结果的 URL，有效期 2 小时",
            "example": "https://example.com/sample-result-url"
          }
        }
      },
      "EngineErrorCode": {
        "type": "string",
        "nullable": true,
        "enum": [
          "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- `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"
      },
      "InvalidParametersSchema": {
        "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"
            ],
            "description": "错误码：\n  * InvalidParameters - 请求参数或请求体无效\n"
          }
        }
      },
      "InvalidApiKeySchema": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 401,
            "description": "响应状态"
          },
          "error_code": {
            "type": "string",
            "enum": [
              "InvalidApiKey",
              "InactiveApiKey",
              "ExpiredApiKey"
            ],
            "description": "错误码：\n  * InvalidApiKey - 未提供 API 密钥，或密钥无效\n  * InactiveApiKey - API 密钥已被停用\n  * ExpiredApiKey - API 密钥已过期\n"
          }
        }
      },
      "RunErrorSchema": {
        "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"
            ],
            "description": "错误码：\n  * CreditInsufficiency - 点数不足，无法运行\n  * BadRequest - 请求参数不符合预期\n  * InvalidStyleGroup - 风格分组 ID 无效\n  * InvalidStyle - 风格 ID 无效\n  * InvalidParameters - 请求参数无效\n"
          }
        }
      },
      "InvalidTaskIdSchema": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "响应状态",
            "example": 400
          },
          "error_code": {
            "type": "string",
            "enum": [
              "InvalidTaskId"
            ],
            "description": "错误码：\n  * InvalidTaskId - 任务 ID 无效\n"
          }
        }
      },
      "TaskTimeoutSchema": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "响应状态",
            "example": 500
          },
          "error_code": {
            "type": "string",
            "enum": [
              "TaskTimeout"
            ],
            "description": "错误码：\n  * TaskTimeout - 任务在预期时间内没有响应\n"
          }
        }
      }
    },
    "responses": {
      "InvalidParameters": {
        "description": "请求参数无效",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/InvalidParametersSchema"
            }
          }
        }
      },
      "InvalidApiKey": {
        "description": "API 密钥无效、已停用或已过期",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/InvalidApiKeySchema"
            }
          }
        }
      },
      "RunError": {
        "description": "任务执行失败",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/RunErrorSchema"
            }
          }
        }
      },
      "InvalidTaskId": {
        "description": "任务 ID 无效",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/InvalidTaskIdSchema"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "单位时间内请求过多"
      },
      "TaskTimeout": {
        "description": "任务在预期时间内没有响应",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TaskTimeoutSchema"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用标准的 Bearer 鉴权。把您的 API 密钥放进请求头： `Authorization:Bearer YOUR_API_KEY`。请注意 'Bearer' 与 'YOUR_API_KEY' 之间有一个空格。"
      }
    }
  }
}