{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 音乐生成",
    "description": "# 概览 (Overview)\n主题、歌词和/或音乐风格，任给一样就能完成一首歌。每个 AI 音乐生成任务会作曲一首成品歌曲（mp3），并一并返回封面图、歌名、定稿歌词与歌词同步时间轴。\n\n* 有声乐、纯音乐都行：生成带人声的歌曲，或无人声、无歌词的纯音乐（`instrumental: true`）。\n* 手上有什么就从什么开始：主题（`idea`）、自己的歌词（`lyrics`），或两者都给。纯音乐歌曲必须给 `idea`。\n* 歌词语言：直接在 `idea` 文字里提要求（例如 \"with Japanese lyrics\"）。支持的歌词语言：英语、日语、韩语、葡萄牙语、西班牙语、德语、法语、意大利语、繁体中文、简体中文、印地语、土耳其语。\n\n使用示例：\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2026-10-15/webp_b29b16b3-6f1f-4f94-b0f3-ef7955d1b3e0.webp)\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2026-09-24/webp_90715cdb-e955-4501-9290-0869981b3f43.webp)\n\n---\n\n## 接入指南 (Integration Guide)\n\n* AI 音乐生成使用指南\n\n本指南说明如何运行 AI 音乐生成任务并解读结果。\n\n不需要上传图像或音频，所以用不上 File API：跑任务前没有\"创建新文件\"这一步。输入你的 `idea` 或 `lyrics`，选好 `music_style`，就能做出令人惊艳的歌曲。\n\n***\n\n   * 第 1 步：创建任务\n\n用 **AI 任务 API**（`/s2s/v2.0/task/ai-song`），传入主题、歌词和/或音乐风格：\n\n```bash\ncurl --request POST \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/task/ai-song \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json' \\\n  --data '{\"idea\":\"A song about a small cafe that stays open late for people who cannot sleep\",\"music_style\":{\"genre\":\"Acoustic Pop\",\"mood\":\"Calm, hopeful\",\"vocal\":\"female\",\"description\":\"soft piano, brushed drums\"},\"instrumental\":false}'\n```\n\n响应会返回这个任务的 `task_id`：\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"task_id\": \"grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe\"\n  }\n}\n```\n\n***\n\n   * 第 2 步：轮询任务结果\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/ai-song/YOUR_TASK_ID \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json'\n```\n\n***\n\n   * 第 3 步：获取结果\n\n成功的响应会包含歌曲，以及封面图、标题、定稿歌词与歌词同步时间戳：\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"error\": null,\n    \"results\": {\n      \"url\": \"https://example.com/sample-song-url\",\n      \"cover_urls\": [\n        \"https://example.com/sample-cover-url\"\n      ],\n      \"title\": \"Leave the Light On\",\n      \"lyrics\": \"[verse]\\nTwo a.m., the neon hums\\nSteam on the glass, the night still runs\",\n      \"duration\": 154.3,\n      \"timestamps\": \"{\\\"lyrics_lrc_timestamps\\\": \\\"[00:23.98]Two a.m., the neon hums\\\"}\"\n    },\n    \"task_status\": \"success\"\n  }\n}\n```\n\n---\n\n## 输入与输出 (Inputs & Outputs)\n\n* 请求体\n\n| 字段 | 类型 | 说明 |\n|---|---|---|\n| idea | string（最多 500 字符） | 歌曲主题。`instrumental` 为 `true` 时必填。带人声的歌曲请提供 `idea`、`lyrics` 或两者。 |\n| lyrics | string（最多 3000 字符） | 歌曲歌词。支持 `[intro]`、`[verse]`、`[chorus]`、`[outro]` 等段落标签。 |\n| music_style | object | 歌曲音乐风格：`genre`（最多 100）、`mood`（最多 100）、`vocal`（`female` 或 `male`，纯音乐时忽略），以及放乐器、节奏等其他细节的 `description`（最多 300）。所有字段均可选。 |\n| instrumental | boolean | `true` 表示生成无人声、无歌词的纯音乐。默认 `false`。 |\n\n每个请求必须以下面两种方式之一描述歌曲：从主题出发（`idea` 不为空），或从带人声歌曲的歌词出发（`lyrics` 不为空且 `instrumental` 不是 `true`）。\n\n* 结果（`data.results`）\n\n| 字段 | 类型 | 说明 |\n|---|---|---|\n| url | string | 下载生成歌曲（mp3）的 URL。有效期 2 小时 |\n| cover_urls | string 数组 | 下载封面图（jpg）的 URL。目前为一张。有效期 2 小时 |\n| title | string | 生成出来的歌曲标题 |\n| lyrics | string | 歌曲定稿歌词。纯音乐时为空 |\n| duration | number | 歌曲时长（秒） |\n| timestamps | string | 一个对象 JSON 编码后的字符串，其中 `lyrics_lrc_timestamps` 字段放 LRC 格式的歌词同步内容，例如 `[00:08.54]Lyrics text`。纯音乐时 LRC 内容为空 |\n\n---\n\n## 文件规格与错误码 (File Specs & Errors)\n\n* 支持上限\n\n| 类型 | 上限 |\n|---|---|\n| idea（主题） | 最多 500 字符。`instrumental` 为 `true` 时必填 |\n| lyrics | 最多 3000 字符。支持 `[intro]`、`[verse]`、`[chorus]`、`[outro]` 等段落标签 |\n| music_style `genre` / `mood` | 各最多 100 字符 |\n| music_style `description` | 最多 300 字符 |\n| 输入文件 | 无。不需要图像或音频输入，因此不必走 File API 步骤 |\n| 输出 | 歌曲：mp3。封面图：jpg。结果 URL 有效期 2 小时 |\n\n* 错误码\n\n| 错误码 | 说明 |\n|---|---|\n| invalid_parameter | 参数值无效，例如 `idea` 和 `lyrics` 都没给、纯音乐任务少了 `idea`、或字段超过长度上限 |\n\n    > 任务级的失败会在状态响应中体现：`data.error` 是错误码，`data.error_message` 是错误的详细说明。\n\n---\n\n## 点数消耗 (Unit Consumption)\n\n按歌曲类型计价。\n\n| 歌曲类型 | 消耗点数 |\n|---|---|\n| 带人声的歌曲（`instrumental: false`） | 每首 10 点 |\n| 纯音乐（`instrumental: true`） | 每首 20 点 |\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 音乐生成 API 把主题、歌词和/或音乐风格变成一首完整的歌。每个任务返回一首成品歌曲（mp3），附封面图、标题、歌词与歌词同步时间戳。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/ai-song": {
      "post": {
        "summary": "运行 AI 音乐生成任务。",
        "description": "AI 任务是异步处理的。功能支持 Webhook 时，优先用 Webhook 来接收完成通知。配置好您的 Webhook 端点、校验 Webhook 签名，收到 `success` 或 `error` 通知后，用收到的 `task_id` 查询任务结果。配置与校验的细节请见 [Webhook 接入指南](/develop/webhook.md)。\n\n若功能不支持 Webhook，或您的接入方式用不了 Webhook，就请实现轮询。提交 AI 任务后，按固定间隔（例如每 10 秒）轮询状态接口，直到任务状态变为 `success` 或 `error`。\n",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idea": {
                    "type": "string",
                    "maxLength": 500,
                    "default": "",
                    "description": "歌曲主题。instrumental 为 true 时必填。带人声的歌曲请提供 idea、lyrics 或两者。 想要特定语言的歌词，就在这里提出（例如 \"with Japanese lyrics\"）。",
                    "example": "A song about a small café that stays open late for people who can't sleep"
                  },
                  "lyrics": {
                    "type": "string",
                    "maxLength": 3000,
                    "default": "",
                    "description": "歌曲歌词。支持 [intro]、[verse]、[chorus]、[outro] 等段落标签。支持的歌词语言： 英语、日语、韩语、葡萄牙语、西班牙语、德语、法语、意大利语、繁体中文、简体中文、印地语、土耳其语。",
                    "example": "[verse]\nTwo a.m., the neon hums\nSteam on the glass, the night still runs\n\n[chorus]\nLeave the light on, leave the light on\nFor the ones who don't go home"
                  },
                  "music_style": {
                    "type": "object",
                    "description": "歌曲的音乐风格。所有字段均可选。",
                    "properties": {
                      "genre": {
                        "type": "string",
                        "maxLength": 100,
                        "description": "歌曲曲风，例如 Pop、Lo-fi Hip Hop",
                        "example": "Acoustic Pop"
                      },
                      "mood": {
                        "type": "string",
                        "maxLength": 100,
                        "description": "歌曲情绪，例如 Calm、Uplifting",
                        "example": "Calm, hopeful"
                      },
                      "vocal": {
                        "type": "string",
                        "enum": [
                          "female",
                          "male"
                        ],
                        "description": "人声类型。instrumental 为 true 时忽略。",
                        "example": "female"
                      },
                      "description": {
                        "type": "string",
                        "maxLength": 300,
                        "description": "其他细节，例如乐器或节奏。",
                        "example": "soft piano, brushed drums"
                      }
                    }
                  },
                  "instrumental": {
                    "type": "boolean",
                    "default": false,
                    "description": "设为 true 生成无人声、无歌词的纯音乐。",
                    "example": false
                  }
                },
                "anyOf": [
                  {
                    "title": "从主题生成歌曲",
                    "required": [
                      "idea"
                    ],
                    "properties": {
                      "idea": {
                        "minLength": 1
                      }
                    }
                  },
                  {
                    "title": "从歌词生成带人声歌曲",
                    "required": [
                      "lyrics"
                    ],
                    "properties": {
                      "lyrics": {
                        "minLength": 1
                      },
                      "instrumental": {
                        "enum": [
                          false
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "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-song/{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": "任务状态查询成功",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/TaskStatusResponseV2"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "object",
                              "properties": {
                                "cover_urls": {
                                  "type": "array",
                                  "description": "下载封面图（jpg）的 URL。目前为一张。有效期 2 小时",
                                  "items": {
                                    "type": "string",
                                    "example": "https://example.com/sample-cover-url"
                                  }
                                },
                                "title": {
                                  "type": "string",
                                  "description": "生成出来的歌曲标题",
                                  "example": "Leave the Light On"
                                },
                                "lyrics": {
                                  "type": "string",
                                  "description": "歌曲定稿歌词。纯音乐时为空"
                                },
                                "duration": {
                                  "type": "number",
                                  "description": "歌曲时长（秒）",
                                  "example": 154.3
                                },
                                "timestamps": {
                                  "type": "string",
                                  "description": "一个对象 JSON 编码后的字符串，其中 lyrics_lrc_timestamps 字段放 LRC 格式的同步歌词，例如 [00:08.54]Lyrics text。纯音乐时 LRC 内容为空",
                                  "example": "{\"lyrics_lrc_timestamps\": \"[00:23.98]Two a.m., the neon hums\\n[00:28.26]Steam on the glass, the night still runs\"}"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "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": {
      "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"
              }
            }
          }
        }
      },
      "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 无效\n"
          }
        }
      },
      "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\\` - 为避免生成不适宜内容， 重试次数已用尽\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"
                }
              }
            }
          }
        }
      }
    }
  }
}