> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Suno API：上传音频扩展

> 使用上传的音频文件作为参考进行音乐扩展。集成了 Suno 的上传功能，预期结果是生成能够无缝衔接原始音频的更长音频。

### 重要说明

* 对于已有音乐，Suno 可能会上传失败。
* 支持两种扩展模式：`simple` 和 `custom`
* 在 `simple` 模式下，`prompt` 为必填项；其他可选参数均为可选
* 在 `custom` 模式下，`continue_at`、`title` 和 `tags` 为必填项，当 `instrumental=false` 时，`lyrics` 也为必填项

<Tip>
  如果你希望基于上传音频快速生成扩展内容，建议优先使用 `mode=simple`。
</Tip>

### 扩展音乐（Simple 模式）

使用你上传的音频文件和简短提示词进行扩展。

<CodeGroup>
  ```json 简单模式上传扩展 theme={null} theme={null}
  {
      "model": "suno/music-extend-upload",
      "callback_url": "",
      "input": {
          "audio_url": "https://example.com/uploaded-audio.mp3",
          "mode": "simple",
          "model": "v5",
          "instrumental": false,
          "prompt": "为这段音乐扩展一个梦幻般的尾奏，保持柔和温暖的氛围。",
          "continue_at": 180
      }
  }
  ```

  ```json 纯音乐扩展 theme={null} theme={null}
  {
      "model": "suno/music-extend-upload",
      "callback_url": "",
      "input": {
          "audio_url": "https://example.com/uploaded-audio.mp3",
          "mode": "simple",
          "model": "v5",
          "instrumental": true,
          "prompt": "Lo-fi 风格的纯音乐续写，柔和钢琴与黑胶噼啪声。"
      }
  }
  ```
</CodeGroup>

### 扩展音乐（Custom 模式）

自定义扩展允许你控制音乐风格和歌词。需要提供 `title`、`tags` 和 `lyrics`（纯音乐模式除外）。

<CodeGroup>
  ```json 自定义上传扩展 theme={null} theme={null}
  {
      "model": "suno/music-extend-upload",
      "callback_url": "",
      "input": {
          "audio_url": "https://example.com/uploaded-audio.mp3",
          "mode": "custom",
          "model": "v5",
          "instrumental": false,
          "continue_at": 30,
          "title": "Midnight Addiction (Extended)",
          "tags": "Western R&B, female vocal, dark, sensual",
          "lyrics": "[Verse 1]\nI still taste your words in the dark...",
          "vocal_gender": "f",
          "style_weight": 0.85,
          "audio_weight": 0.6,
          "weirdness_constraint": 0.2,
          "negative_tags": "metal, aggressive"
      }
  }
  ```
</CodeGroup>

### 获取任务结果

提交任务后，可以使用统一查询接口检查任务进度并获取生成结果：

<Card title="获取 Suno 任务信息" icon="magnifying-glass" href="/zh/suno-api/suno-task-info">
  了解如何查询 Suno 任务状态并获取生成结果
</Card>


## OpenAPI

````yaml zh/suno-api/extend-music-upload.json post /api/v1/client/job/CreateTask
openapi: 3.0.0
info:
  title: Crun Suno 上传音频扩展 API
  description: crun.ai Suno 上传音频扩展 API 文档
  version: 1.0.0
  contact:
    name: 技术支持
    email: support@crun.ai
servers:
  - url: https://api.crun.ai
    description: API 服务地址
security:
  - ApiKeyAuth: []
paths:
  /api/v1/client/job/CreateTask:
    post:
      summary: 基于上传音频的 Suno 音乐扩展
      operationId: suno/music-extend-upload
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  enum:
                    - suno/music-extend-upload
                  description: |-
                    用于生成的模型名称。必填字段。

                    - 此接口必须使用 `suno/music-extend-upload`
                callback_url:
                  type: string
                  format: uri
                  description: |-
                    可选。用于接收任务完成通知的回调 URL。

                    - 当生成完成后，系统会向该 URL 发送任务状态和结果
                    - 回调数据结构与任务状态查询接口返回的 `data` 对象一致
                    - 你的回调接口应支持接收包含 JSON 数据的 POST 请求
                    - 成功接收后需返回 HTTP 200 状态码
                  example: https://your-domain.com/api/callback
                input:
                  $ref: '#/components/schemas/SunoMusicExtendUploadInput'
            example:
              model: suno/music-extend-upload
              callback_url: https://your-domain.com/api/callback
              input:
                audio_url: https://example.com/uploaded-audio.mp3
                mode: custom
                model: v5
                instrumental: false
                continue_at: 30
                title: Midnight Addiction (Extended)
                tags: Western R&B, female vocal, dark, sensual
                lyrics: |-
                  [Verse 1]
                  I still taste your words in the dark...
                vocal_gender: f
                style_weight: 0.85
                audio_weight: 0.6
                weirdness_constraint: 0.2
                negative_tags: metal, aggressive
      responses:
        '200':
          description: 请求成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          task_id:
                            type: string
                            description: 任务 ID，可用于通过获取任务详情接口查询任务状态
                            example: task_12345678
              example:
                code: 200
                message: success
                data:
                  task_id: task_12345678
        '422':
          description: 参数验证错误
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      errors:
                        type: array
                        description: 详细的参数验证错误信息
                        items:
                          type: string
                        example:
                          - specific error field message
              example:
                code: 422
                message: Missing Params or Type Error
                errors:
                  - specific error field message
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    SunoMusicExtendUploadInput:
      type: object
      description: |-
        基于上传音频文件扩展音乐的输入参数。

        规则：
        - `audio_url` 为必填项，且必须指向已上传的音频文件。
        - `mode=simple`：`prompt` 为必填项。
        - `mode=custom`：`continue_at`、`title` 和 `tags` 为必填项。
        - `mode=custom` 且 `instrumental=false`：`lyrics` 为必填项。
        - `model=v4`：`tags` 最大长度为 200，`lyrics` 最大长度为 3000。
      properties:
        audio_url:
          type: string
          format: uri
          description: 需要扩展的音频文件 URL。请确保上传的音频时长不超过 8 分钟。
          example: https://example.com/uploaded-audio.mp3
        continue_at:
          type: integer
          minimum: 1
          description: 从第几秒开始扩展。必须大于 0 且小于上传音频的总时长。在 `custom` 模式下为必填项。
          example: 30
        mode:
          type: string
          enum:
            - simple
            - custom
          description: 扩展模式。
          example: simple
        model:
          type: string
          enum:
            - v5.5
            - v5
            - v4.5plus
            - v4.5
            - v4.5all
            - v4
          description: |-
            Suno 音乐模型版本。

            - **v5.5**：专为匹配你的独特音乐品味而打造的定制模型。
            - **v5**：更优秀的音乐表现力，更快的生成速度。
            - **v4.5plus**：v4.5+ 提供更丰富的音质、全新的创作方式，最长支持 8 分钟。
            - **v4.5**：支持更智能的提示词与更快的生成速度，最长支持 8 分钟。
            - **v4.5all**：支持更智能的提示词与更快的生成速度，最长支持 8 分钟。
            - **v4**：提升人声质量，最长支持 4 分钟。
          example: v5
        instrumental:
          type: boolean
          description: 是否仅生成纯音乐（无歌词）。
          example: false
        title:
          type: string
          maxLength: 100
          description: 音乐标题。在 `custom` 模式下为必填项。
          example: Midnight Addiction (Extended)
        prompt:
          type: string
          maxLength: 500
          description: 用于 `simple` 模式下引导音乐生成的提示词。当 `mode=simple` 时为必填项。
          example: 为这段音乐扩展一个梦幻般的尾奏，保持柔和温暖的氛围。
        lyrics:
          type: string
          maxLength: 5000
          description: >-
            自定义模式下使用的歌词。当 `mode=custom` 且 `instrumental=false` 时为必填项。对于 `v4`
            模型最大长度为 3000，其他模型为 5000。
          example: |-
            [Verse 1]
            I still taste your words in the dark...
        tags:
          type: string
          maxLength: 1000
          description: 音乐风格标签。在 `custom` 模式下为必填项。对于 `v4` 模型最大长度为 200，其他模型为 1000。
          example: Western R&B, female vocal, dark, sensual, slow tempo
        vocal_gender:
          type: string
          enum:
            - m
            - f
          description: 人声性别偏好：`m` 表示男声，`f` 表示女声。仅在 `custom` 模式下生效。
          example: f
        negative_tags:
          type: string
          maxLength: 1000
          description: 需要排除的音乐风格。
          example: metal, aggressive, harsh vocals
        style_weight:
          type: number
          minimum: 0
          maximum: 1
          description: 风格参考强度，范围为 0.0 到 1.0。
          example: 0.85
        audio_weight:
          type: number
          minimum: 0
          maximum: 1
          description: 音频特征与其他因素之间的平衡权重，范围为 0.0 到 1.0。
          example: 0.6
        weirdness_constraint:
          type: number
          minimum: 0
          maximum: 1
          description: 控制实验性/创意偏离程度，范围为 0.0 到 1.0。
          example: 0.2
        persona_id:
          type: string
          description: >-
            所选 Persona 模型对应的 Persona ID。可通过 [Suno Persona
            Generate](/zh/suno-api/suno-persona-generate) 创建。
          example: persona_123456
        persona_model:
          type: string
          enum:
            - style_persona
            - voice_persona
          description: |-
            Persona 模型类型。需与 `persona_id` 搭配使用以应用已保存的 Persona。

             - **style_persona**：应用偏向风格的 Persona 特征。
             - **voice_persona**：应用偏向声音的 Persona 特征（仅 v5 模型支持）。
          default: style_persona
          example: style_persona
      required:
        - audio_url
        - mode
        - model
        - instrumental
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 401
            - 402
            - 404
            - 422
            - 429
            - 455
            - 500
            - 501
            - 505
          description: |-
            响应状态码

            - **200**：成功 - 请求已成功处理
            - **401**：未授权 - 缺少认证信息或认证无效
            - **402**：余额不足 - 账户积分不足，无法执行当前操作
            - **404**：未找到 - 请求的资源或接口不存在
            - **422**：参数验证错误 - 请求参数未通过校验
            - **429**：请求过于频繁 - 当前资源已超出请求限制
            - **455**：服务不可用 - 系统正在维护中
            - **500**：服务器错误 - 处理请求时发生未知错误
            - **501**：生成失败 - 内容生成任务失败
            - **505**：功能已禁用 - 当前功能暂不可用
        message:
          type: string
          description: 响应消息，失败时为错误描述
          example: success
  responses:
    Error:
      description: 服务器错误
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |-
        所有 API 均需通过 API Key 进行身份认证。

        获取 API Key：
        1. 访问 [API Key 管理页面](https://crun.ai/zh/user-api-key) 获取你的 API Key

        使用方式：
        在请求头中添加：

        x-api-key: YOUR_API_KEY

        注意：
        - 请妥善保管你的 API Key，不要泄露给他人
        - 如果怀疑 API Key 已泄露，请立即在管理页面中重置

````