{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 擴圖",
    "description": "# 概述\n透過我們尖端的 AI 擴圖，體驗生動的 AI Outpainting。以任何比例無縫擴展圖片，用我們先進的 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 擴圖\")\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 擴圖\")\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 擴圖 API 可透過在圖片周圍生成新內容（Outpainting），擴展圖片的尺寸。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/out-paint": {
      "post": {
        "summary": "執行 AI 擴圖任務。",
        "description": "查詢任務狀態請參考輪詢指南。這個 API 需要 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 類型。目前可用的值列於 enum 中。"
                },
                "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。其他執行任務的 API 會需要這個 `file_id`。"
                },
                "requests": {
                  "type": "array",
                  "description": "使用下方的 `url`、`headers`、`method` 上傳檔案。完成後，使用 `file_id` 繼續呼叫執行任務的 API。",
                  "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": "上傳這個檔案的網址"
                      },
                      "method": {
                        "type": "string",
                        "example": "PUT",
                        "description": "上傳這個檔案所用的 HTTP 方法"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "FileResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 200,
            "description": "回應狀態"
          },
          "data": {
            "$ref": "#/components/schemas/BasicFileResponse"
          }
        }
      },
      "BasicRunTaskV2SrcFileUrl": {
        "title": "以來源檔案網址執行任務",
        "type": "object",
        "required": [
          "src_file_url"
        ],
        "properties": {
          "src_file_url": {
            "type": "string",
            "description": "要執行任務的檔案網址。該網址應可公開存取。",
            "example": "https://example.com/selfie.jpg"
          }
        }
      },
      "BasicRunTaskV2SrcFileId": {
        "title": "以來源檔案 ID 執行任務",
        "type": "object",
        "required": [
          "src_file_id"
        ],
        "properties": {
          "src_file_id": {
            "type": "string",
            "description": "要執行任務的檔案 ID。檔案 ID 來自上傳檔案 API。",
            "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 擴圖 API 需要 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": "下載這個結果的網址。有效期限 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` - 超過重試上限，以避免生成 NSFW 圖片\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 Key，或 API Key 無效\n  * InactiveApiKey - API Key 已停用\n  * ExpiredApiKey - API Key 已到期\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 Key 無效、已停用或已到期",
        "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 authentication'。請在標頭中放入您的 'API Key'：`Authorization:Bearer YOUR_API_KEY`。請注意 'Bearer' 與 'YOUR_API_KEY' 之間有一個空格。"
      }
    }
  }
}