# 上传并扩展音乐

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /api/v1/generate/upload-extend:
    post:
      summary: 上传并扩展音乐
      deprecated: false
      description: >
        此 API 在保留音频轨道原始样式的同时扩展了音轨。它包括 Suno
        的上传功能，允许用户上传音频文件进行处理。预期的结果是更长的音轨，无缝地延续输入的风格。


        ### 模型版本


        - **当前模型**：`V6`（默认）、`V6_WILD`、`V6_MINI`

        - **已废弃模型**：`V5_5`、`V5`、`V4_5PLUS`、`V4_5ALL`、`V4_5`、`V4`

        - 废弃值仅为向后兼容保留，新接入请使用 V6 系列模型。


        ### 参数使用指南

        - 本接口固定为自定义模式，简单模式不可用。提供源音频（`uploadUrl`）即可生成；`lyrics`（或
        `prompt`）、`title`、`style` 均为选填。

        - **必填**：`uploadUrl`、`model`、`callBackUrl`

        - instrumental（boolean，可选）：决定是否生成纯音乐，默认值为 false

        - `prompt` 按歌词语义使用。可选。若同时传入 `lyrics`，优先使用 `lyrics`，`prompt` 不再作为歌词。

        - **字符限制（基于模型）：**
          - **V4 模型（已废弃）**：prompt 最多 3000 字符，style 最多 200 字符
          - **V4_5、V4_5PLUS、V5、V5_5 和 V4_5ALL 模型（已废弃）**：prompt 最多 5000 字符，style 最多 1000 字符
          - **V6、V6_WILD 和 V6_MINI 模型**：lyrics/prompt 最多 5000 字符，style 最多 1000 字符，title 最多 100 字符
        -
        **model**（string，必填）：`V6`、`V6_WILD`、`V6_MINI`。已废弃：`V4_5ALL`、`V4`、`V4_5`、`V4_5PLUS`、`V5`、`V5_5`。

        - continueAt：音频开始扩展的秒数（需大于 0，且小于所上传音频的时长）

        - uploadUrl 用于指定源音频文件；确保上传的音频长度不超过 8 分钟。


        ### 可选参数


        :::note[]

        以下字段为可选控制项：


        - <b>lyrics</b>（string）：歌词内容。可选。V6 系列最多 5000 字符。优先于 `prompt` 作为歌词。

        - <b>prompt</b>（string）：歌词内容。可选。未传入 `lyrics` 时作为歌词使用。V6 系列最多 5000 字符。

        - <b>style</b>（string）：音乐风格。可选。V6 系列最多 1000 字符。

        - <b>title</b>（string）：曲目标题。可选。最多 100 字符。

        - <b>continueAt</b>（number）：开始延长的时间点（秒）。需大于 0 且小于上传音频时长。

        - <b>vocalGender</b>（string）：可选。允许值：`m`（男）、`f`（女）

        - <b>styleWeight</b>（number）：风格贴合权重，范围 0–1（建议保留两位小数）

        - <b>weirdnessConstraint</b>（number）：创造性/新颖度约束，范围 0–1（建议保留两位小数）

        - <b>audioWeight</b>（number）：音频一致性相对权重，范围 0–1（建议保留两位小数）

        - <b>variety</b>（number）：生成结果的多样性。范围 0–4 的整数，默认 1。`0` 关闭，`1` 普通（默认），`2`
        高，`3` 额外，`4` 最大。

        - <b>personaId</b>（string）：Persona ID 或 Suno Voice 生成的 `voiceId`。如果使用
        Voice 生成的 ID，`personaModel` 必须设置为 `voice_persona`。

        - <b>personaModel</b>（string）：Persona 类型。生成 Persona 接口返回的 ID 使用
        `style_persona`，Suno Voice 生成的 ID 使用 `voice_persona`。默认 `style_persona`。

        :::


        **请求示例**


        **请求示例**


        ```json

        {
          "instrumental": false,
          "lyrics": "[Verse] 夜晚城市 灯火辉煌",
          "style": "Electropop",
          "title": "Shimmer (Extended)",
          "continueAt": 45,
          "uploadUrl": "https://storage.example.com/upload",
          "variety": 1,
          "model": "V6",
          "callBackUrl": "https://example.com/callback",
          "styleWeight": 0.61,
          "weirdnessConstraint": 0.72,
          "audioWeight": 0.65
        }

        ```


        ### 开发者注意事项

        1. 生成的文件将保留14天

        2. 模型版本必须与源音乐保持一致

        3. 此功能非常适合通过延长现有音乐创作更长的作品

        4. 请注意 lyrics/prompt、style 和 title 的字符长度限制，确保成功处理

        5. uploadUrl 参数用于指定源音频文件；请提供有效的 URL。
      operationId: upload-and-extend-audio
      tags:
        - docs/zh-CN/Suno API/Generate Music
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - callBackUrl
                - model
                - uploadUrl
              properties:
                uploadUrl:
                  type: string
                  format: uri
                  description: >-
                    用于延长的源音频文件 URL。必填。提供源音频即可生成；`lyrics`（或
                    `prompt`）、`title`、`style` 均为选填。确保上传的音频长度不超过 8 分钟。
                  examples:
                    - https://api.example.com/upload
                instrumental:
                  type: boolean
                  description: 决定音频是否为纯音乐（无歌词）。可选。默认 `false`。
                  default: false
                  examples:
                    - false
                prompt:
                  type: string
                  description: >-
                    歌词内容。可选。未传入 `lyrics` 时作为歌词使用；若同时传入 `lyrics`，优先使用
                    `lyrics`，本字段不再作为歌词。

                    - **V4（已废弃）**：最多 3000 字符

                    - **V4_5、V4_5PLUS、V4_5ALL、V5、V5_5（已废弃）**：最多 5000 字符

                    - **V6、V6_WILD、V6_MINI**：最多 5000 字符
                  examples:
                    - '[Verse] 夜晚城市 灯火辉煌'
                lyrics:
                  type: string
                  description: >-
                    歌词内容。可选。V6、V6_MINI、V6_WILD 最多 5000 字符。优先于 `prompt`
                    作为歌词；未传入时使用 `prompt` 作为歌词。
                  examples:
                    - '[Verse] 夜晚城市 灯火辉煌'
                style:
                  type: string
                  description: |-
                    音乐风格，例如爵士、古典、电子等。可选。V6、V6_WILD、V6_MINI 最多 1000 字符。
                    - **V4（已废弃）**：最多 200 字符
                    - **V4_5、V4_5PLUS、V4_5ALL、V5、V5_5（已废弃）**：最多 1000 字符
                  examples:
                    - 古典
                title:
                  type: string
                  description: 音乐标题。可选。最多 100 字符。
                  maxLength: 100
                  examples:
                    - 宁静钢琴延长版
                continueAt:
                  type: number
                  description: |-
                    音频开始扩展的时间点（以秒为单位）。可选。
                    - 取值范围：大于 0 且小于上传音频的总时长。
                    - 指定从原始音频的哪个时间点开始进行扩展。
                  examples:
                    - 60
                personaId:
                  type: string
                  description: >-
                    应用到生成音乐的 Persona ID，可选。你可以传入以下两类 ID：


                    - 通过 [生成
                    Persona](https://docs.api.box/cn/suno-api/generate-persona)
                    接口生成的 Persona ID。此时可使用 `personaModel: style_persona`，或省略
                    `personaModel` 使用默认值。

                    - 通过 [Suno
                    Voice](https://docs.api.box/cn/suno-api/suno-voice-generate)
                    流程生成的 `voiceId`。当使用 Voice 生成的 ID 时，必须设置 `personaModel:
                    voice_persona`。
                  examples:
                    - persona_123
                personaModel:
                  type: string
                  description: >-
                    使用 `personaId` 时应用的 Persona 模型类型，可选。

                    - `style_persona`（默认）：用于生成 Persona 接口返回的 Persona ID。

                    - `voice_persona`：当 `personaId` 使用 Suno Voice 生成的 `voiceId`
                    时必须选择该值。该选项仅在 V5（已废弃）、V5_5（已废弃）、V6、V6_WILD 和 V6_MINI 模型下可用。
                  enum:
                    - style_persona
                    - voice_persona
                  default: style_persona
                  examples:
                    - style_persona
                model:
                  type: string
                  description: >-
                    AI 模型版本。默认值：`V6`。

                    - **`V6`**：当前标准模型，推荐默认使用。

                    - **`V6_WILD`**：当前实验性、创造性更强的模型。

                    - **`V6_MINI`**：当前轻量模型。

                    -
                    **已废弃**：`V5_5`、`V5`、`V4_5PLUS`、`V4_5ALL`、`V4_5`、`V4`。这些值仅为向后兼容保留，新接入请使用
                    V6 系列模型。
                  enum:
                    - V6
                    - V6_WILD
                    - V6_MINI
                    - V5_5
                    - V5
                    - V4_5PLUS
                    - V4_5ALL
                    - V4_5
                    - V4
                  default: V6
                  examples:
                    - V6
                negativeTags:
                  type: string
                  description: 需要在生成中排除的音乐风格
                  examples:
                    - 舒缓钢琴
                callBackUrl:
                  type: string
                  format: uri
                  description: >-
                    在音乐延长完成时接收任务完成通知的URL。

                    - 详细的回调格式和实现指南，请参见
                    [上传并扩展音频回调](https://docs.api.box/cn/suno-api/upload-and-extend-audio-callbacks)

                    - 或者，您也可以使用获取音乐生成详情接口来轮询任务状态
                  examples:
                    - https://api.example.com/callback
                vocalGender:
                  type: string
                  description: 偏好人声性别。可选。允许值：`m`（男）、`f`（女）。`instrumental` 为 `true` 时无需填写。
                  enum:
                    - m
                    - f
                  examples:
                    - m
                styleWeight:
                  type: number
                  description: 风格贴合权重。可选。范围：0-1。建议保留两位小数。
                  minimum: 0
                  maximum: 1
                  multipleOf: 0.01
                  examples:
                    - 0.65
                weirdnessConstraint:
                  type: number
                  description: 创造性/新颖度约束。可选。范围：0-1。建议保留两位小数。
                  minimum: 0
                  maximum: 1
                  multipleOf: 0.01
                  examples:
                    - 0.65
                audioWeight:
                  type: number
                  description: 音频一致性与其他控制项的相对权重。可选。范围：0-1。建议保留两位小数。
                  minimum: 0
                  maximum: 1
                  multipleOf: 0.01
                  examples:
                    - 0.65
                variety:
                  type: number
                  description: >-
                    控制生成结果的多样性和风格差异程度。可选。范围 0–4 的整数，默认值为 1。


                    - **`0`**：off（exact style），完全关闭，严格用同一风格

                    - **`1`**：normal（balanced variety），默认值，在稳定性和多样性之间保持平衡

                    - **`2`**：high（distinct styles），生成风格差异明显的结果

                    - **`3`**：extra（bold exploration），提供更高程度的变化，鼓励大胆探索不同风格

                    - **`4`**：max（unreasonably
                    varied），最大程度增加多样性，生成结果可能具有非常明显的风格差异
                  minimum: 0
                  maximum: 4
                  multipleOf: 1
                  default: 1
                  examples:
                    - 1
              x-apidog-orders:
                - uploadUrl
                - instrumental
                - prompt
                - lyrics
                - style
                - title
                - continueAt
                - personaId
                - personaModel
                - model
                - negativeTags
                - callBackUrl
                - vocalGender
                - styleWeight
                - weirdnessConstraint
                - audioWeight
                - variety
      responses:
        '200':
          description: 请求成功
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      code:
                        type: integer
                        description: |-
                          # 状态码说明

                          - ✅ 200 - 请求成功
                          - ⚠️ 400 - 参数错误
                          - ⚠️ 401 - 没有访问权限
                          - ⚠️ 404 - 请求方式或者路径错误
                          - ⚠️ 405 - 调用超过限制
                          - ⚠️ 413 - 主题或者prompt过长
                          - ⚠️ 429 - 积分不足
                          - ⚠️ 430 - 您的调用频率过高。请稍后再试。
                          - ⚠️ 455 - 网站维护
                          - ❌ 500 - 服务器异常
                        enum:
                          - 200
                          - 400
                          - 401
                          - 404
                          - 405
                          - 413
                          - 429
                          - 430
                          - 455
                          - 500
                        examples:
                          - 200
                      msg:
                        type: string
                        description: 当 code != 200 时，展示错误信息
                        examples:
                          - success
                    x-apidog-orders:
                      - code
                      - msg
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          taskId:
                            type: string
                            description: 任务ID，用于后续查询任务状态
                            examples:
                              - 5c79****be8e
                        x-apidog-orders:
                          - taskId
                    x-apidog-orders:
                      - data
          headers: {}
          x-apidog-name: 成功
        '500':
          description: 服务器异常
          headers: {}
          x-apidog-name: 服务器错误
      security: []
      callbacks:
        audioExtend:
          '{$request.body#/callBackUrl}':
            post:
              description: |-
                当音频生成完成时，系统会调用此回调通知结果。

                ### 回调示例
                ```json
                {
                  "code": 200,
                  "msg": "All generated successfully.",
                  "data": {
                    "callbackType": "complete",
                    "task_id": "2fac****9f72",
                    "data": [
                      {
                        "id": "8551****662c",
                        "audio_url": "https://example.cn/****.mp3",
                        "source_audio_url": "https://example.cn/****.mp3",
                        "stream_audio_url": "https://example.cn/****",
                        "source_stream_audio_url": "https://example.cn/****",
                        "image_url": "https://example.cn/****.jpeg",
                        "source_image_url": "https://example.cn/****.jpeg",
                        "prompt": "[Verse] 夜晚城市 灯火辉煌",
                        "model_name": "chirp-v3-5",
                        "title": "钢铁侠",
                        "tags": "electrifying, rock",
                        "createTime": "2025-01-01 00:00:00",
                        "duration": 198.44
                      }
                    ]
                  }
                }
                ```
              requestBody:
                content:
                  application/json:
                    schema:
                      type: object
                      properties:
                        code:
                          type: integer
                          description: 状态码
                          example: 200
                        msg:
                          type: string
                          description: 返回消息
                          example: All generated successfully
                        data:
                          type: object
                          properties:
                            callbackType:
                              type: string
                              description: >-
                                回调类型：text（文本生成完成）、first（第一首生成完成）、complete（全部生成完成）
                              enum:
                                - text
                                - first
                                - complete
                            task_id:
                              type: string
                              description: 任务ID
                            data:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                    description: 音频唯一标识
                                  audio_url:
                                    type: string
                                    description: 音频文件URL
                                  source_audio_url:
                                    type: string
                                    description: （已废弃）原始音频文件URL
                                    deprecated: true
                                  stream_audio_url:
                                    type: string
                                    description: 流式音频URL
                                  source_stream_audio_url:
                                    type: string
                                    description: 原始流式音频URL
                                  image_url:
                                    type: string
                                    description: 封面图片URL
                                  source_image_url:
                                    type: string
                                    description: 原始封面图片URL
                                  prompt:
                                    type: string
                                    description: 生成提示词/歌词
                                  model_name:
                                    type: string
                                    description: 使用的模型名称
                                  title:
                                    type: string
                                    description: 音乐标题
                                  tags:
                                    type: string
                                    description: 音乐标签
                                  createTime:
                                    type: string
                                    description: 创建时间
                                    format: date-time
                                  duration:
                                    type: number
                                    description: 音频时长（秒）
              responses:
                '200':
                  description: 回调接收成功
      x-apidog-folder: docs/zh-CN/Suno API/Generate Music
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1412907/apis/api-46842297-run
components:
  schemas: {}
  securitySchemes:
    BearerAuth:
      type: bearer
      scheme: bearer
      bearerFormat: API Key
      description: >-
        # 🔑 API Authentication


        All endpoints require authentication using Bearer Token.


        ## Get API Key


        1. Visit the [API Key Management Page](https://sunoapi.org/api-key) to
        obtain your API Key


        ## Usage


        Add to request headers:


        ```

        Authorization: Bearer YOUR_API_KEY

        ```


        > **⚠️ Note:**

        > - Keep your API Key secure and do not share it with others

        > - If you suspect your API Key has been compromised, reset it
        immediately from the management page
servers:
  - url: https://apibox.erweima.ai
    description: 正式环境
security: []

```
