{
  "openapi": "3.0.0",
  "info": {
    "title": "笑顔補正",
    "description": "# 概要\nAI 笑顔補正では、表情を笑顔に変換します。\n\nAI 笑顔補正は 2 種類の笑顔スタイルをサポートしています。\n\n1.  **smile_with_teeth_visible**  \n    歯が見える笑顔を作成します。\n\n2.  **closed_mouth_smile**  \n    唇を閉じた控えめな笑顔を作成します。\n\n写真の内容に合わせて笑顔タイプを選択します。\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2024-03-22/5f25b0f7-5d43-421b-ae50-5def0de69f2a.jpg)\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2024-12-16/4f4397e0-9e87-429a-8e39-a9d399b6602b.jpg)\n\n## 統合ガイド\nこのガイドでは、以下を説明します。\n\nAI 笑顔補正 のワークフロー:\n\n**エンドポイント:** `/s2s/v2.0/task/ai-smile`\n\n**認証必須:** `Authorization: Bearer YOUR_API_KEY`\n\n**ワークフロー手順:**\n\n1. **画像アップロード準備:**\n    - アップロード用の自撮り画像を準備します。\n    - File API `/s2s/v2.0/file` を呼び出して、アップロード URL と関連する `file_id` を取得します。\n    - 提供されたアップロード URL を使用して、自撮り画像をアップロードします。\n\n2. **AI タスクの開始とタスク ID の取得:**\n    - `file_id` と選択したエフェクト設定を HTTP POST リクエストで `/s2s/v2.0/task/ai-smile` に送信します。\n    - このやり取りを識別する一意のタスク ID をレスポンスで待ちます。\n\n3. **タスクステータスのポーリング（継続的な確認）:**\n    - 取得した `task_id` を使用して、HTTP GET リクエスト（例: `GET /s2s/v2.0/task/ai-smile/${task_id}`）でタスクステータスを定期的にポーリングします。\n    - 以下を継続的に監視します:\n        - `Task_status = \"success\"`（処理完了）。\n        - `Task_status = \"error\"`（該当する場合、解決または再試行）。\n    - ステータスが success に遷移したら、ワークフローを適切に更新します。\n\n---\n\n1. 認証\n- **Bearer トークン** を使用して、リクエストヘッダーに API キーを含めます:\n    ```\n    Authorization: Bearer YOUR_API_KEY\n    ```\nAPI キーの確認場所: https://yce.makeupar.com/api-console/en/api-keys/.\n\n\n2. 画像のアップロード\n\n    サーバーへファイルを直接アップロードするか、AI タスクペイロードに有効な画像 URL を指定します。\n\n   * アップロードエンドポイント\n\n        ```\n        POST /s2s/v2.0/file\n        ```\n\n    すでに公開画像 URL がある場合は、この手順をスキップできます。\n\n---\n\n3. AI 笑顔タスクの作成と結果のポーリング\n\n    画像と完全なエフェクト設定が用意できたら、タスクを作成します。API はリクエストを非同期で処理します。ステータスが `success` または `error` になるまで、タスクステータスをポーリングする必要があります。\n\n    * タスク作成エンドポイント\n\n        ```\n        POST /s2s/v2.0/task/ai-smile\n        ```\n\n    * ポーリングエンドポイント\n\n        ```\n        GET /s2s/v2.0/task/ai-smile/{task_id}\n        ```\n\n---\n\n## ファイル仕様とエラー\n\n* AI 笑顔仕様\n\n**サポートされる自撮りビュー**\n単一人物の画像のみサポートされます。画像には、長辺が 640 ピクセルの場合に 32 x 32 ピクセルを超える十分なサイズの顔が明確に写っている必要があり、顔検出の失敗を避けるため、撮影角度はロールがプラスマイナス 75 度以内、ヨーがプラスマイナス 90 度以内である必要があります。\n\n![](https://plugins-media.makeupar.com/strapi/assets/thumbnail_face_reshape_01_85c8ffc055.jpg)\n\n\n---\n\n* サポートされる形式と寸法\n\n| AI 機能 | サポートされる寸法 | サポートされるファイルサイズ | サポートされる形式|\n|  ----  | ----  | ----  | ----  |\n| AI 笑顔 | 長辺 <= 4096 | < 10MB | jpg/jpeg/png/heic |\n\n\n* エラーコード\n\n| エラーコード | 説明 |\n| ---------- | ----------- |\n| EXCEED_MAX_FILESIZE  | 入力ファイルが最大許容サイズを超えています。 |\n| INVALID_PARAMETER     | 1 つ以上の必須パラメータが欠落、空、または不正な形式です。  |\n| ERROR_DOWNLOAD_IMAGE | ソース画像をダウンロードできませんでした。 |\n| ERROR_NO_FACE        | 提供された画像で顔が検出されませんでした。 |\n| ERROR_INFERENCE       | ワークフローの問題、実行エラー、エンコーディングエラー、または出力画像の欠落により、推論プロセスが失敗しました。 |\n| UNKNOWN_INTERNAL_ERROR | 予期しない内部エラーが発生しました。 |\n\n\n* 環境と依存関係\n\n| サンプルコード言語 / ツール | 推奨ランタイムバージョン |\n|---|---|\n| cURL | - bash >= 3.2</br>   - curl >= 7.58 (モダンな TLS/HTTP サポート)</br>   - jq >= 1.6 (堅牢な JSON 解析) |\n| Node.js (JavaScript) | Node >= 18 (グローバル fetch 用) |\n| JavaScript | - Chrome / Edge >= 80</br>   - Firefox >= 74</br>   - Safari >= 13.1 |\n| PHP | PHP >= 7.4 (モダンな TLS/互換性用), ext-curl (推奨) または allow_url_fopen=On + ext-openssl, ext-json |\n| Python | Python >= 3.10 (f-strings 用), requests >= 2.20.0 |\n| Java | Java 11+ (HttpClient 用), Jackson Databind >= 2.12.0 |\n\n---\n\n## ユニット消費\n\n| AI 機能 | 消費ユニット |\n|---|---|\n| AI 笑顔 V1.0 | 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/ai-smile": {
      "post": {
        "summary": "笑顔補正タスクを実行します。",
        "description": "AI タスクは非同期です。機能ごとに Webhook がサポートされている場合は、Webhook による完了処理を優先します。Webhook エンドポイントを設定し、Webhook 署名を検証したうえで、`success` または `error` の通知が来たら、受け取った `task_id` を使ってタスクの結果を照会します。設定と検証の詳細は [Webhook 統合ガイド](../develop/webhook.md) を参照してください。\n\nWebhook がサポートされていない場合、または統合に使えない場合は、ポーリングを実装します。AI タスクを送信した後、一定の間隔（例：10 秒ごと）でステータスエンドポイントをポーリングし、`success` または `error` になるまで待ちます。\n",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/BasicRunTaskV2"
                  },
                  {
                    "type": "object",
                    "required": [
                      "expression_type"
                    ],
                    "properties": {
                      "expression_type": {
                        "type": "string",
                        "enum": [
                          "smile_with_teeth_visible",
                          "closed_mouth_smile"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "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/ai-smile/{task_id}": {
      "get": {
        "summary": "笑顔補正タスクのステータスを確認します。",
        "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": {
                  "$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 authentication' を使用します。ヘッダーに 'API Key' を設定してください：`Authorization:Bearer YOUR_API_KEY`。'Bearer' と 'YOUR_API_KEY' の間にスペースが 1 つ必要です。"
      }
    },
    "schemas": {
      "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。ファイルアップロード API から取得したファイル ID です。",
            "example": "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
          }
        }
      },
      "BasicRunTaskV2": {
        "title": "BasicRunTaskV2",
        "anyOf": [
          {
            "title": "src ファイル URL でタスクを実行",
            "allOf": [
              {
                "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
              }
            ]
          },
          {
            "title": "src ファイル ID でタスクを実行",
            "allOf": [
              {
                "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
              }
            ]
          }
        ]
      },
      "BasicRunTaskResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "レスポンスステータス",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "このタスクの ID。タスクの結果は、この ID を使用して 24 時間以内にクエリできます。",
                "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"
          }
        }
      },
      "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` - NSFW 画像の生成を避けるための再試行制限を超えました\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"
      }
    },
    "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"
                }
              }
            }
          }
        }
      }
    }
  }
}