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

# 替换音乐片段：创建任务

> 创建 Suno 任务：`model` 选择接口，参数放在 `input` 中，可选 `callBackUrl` 接收完成回调。成功后返回 `data.taskId`，任务在后台异步执行，用查询任务接口轮询结果。所有响应的 HTTP 状态码都是 200，以 `code` 判断结果。



## OpenAPI

````yaml /openapi/zh/suno-replace-section.json post /api/v1/jobs/createTask
openapi: 3.1.0
info:
  description: 重新生成歌曲中指定时间段（至少 10 秒）的内容，新片段与前后部分自然衔接；可替换已生成的歌曲或上传的音频。
  title: Suno 替换音乐片段
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Suno 替换音乐片段
paths:
  /api/v1/jobs/createTask:
    post:
      tags:
        - Suno 替换音乐片段
      summary: 创建任务
      description: >-
        创建 Suno 任务：`model` 选择接口，参数放在 `input` 中，可选 `callBackUrl` 接收完成回调。成功后返回
        `data.taskId`，任务在后台异步执行，用查询任务接口轮询结果。所有响应的 HTTP 状态码都是 200，以 `code` 判断结果。
      operationId: sunoCreateTask
      requestBody:
        content:
          application/json:
            examples:
              替换已生成歌曲的副歌:
                description: '`task_id` + `audio_id` 指定歌曲，重写 10 ~ 20.5 秒的副歌。'
                summary: 替换已生成歌曲的副歌
                value:
                  model: ai-music-api/replace-section
                  input:
                    task_id: c2a81e5f09d34b7e8f61a2d4c9b03e75
                    audio_id: f924248f-e765-48fd-9ea9-c64290225e4e
                    prompt: |-
                      早安阳光，我们出发
                      一步一步，世界发亮
                    lyrics: |-
                      [Chorus]
                      早安阳光，我们出发
                      一步一步，世界发亮
                    tags: 欢快的原声民谣流行
                    title: 早安，阳光
                    infill_start_s: 10
                    infill_end_s: 20.5
                    full_lyrics: |-
                      [Verse]
                      水壶唱起小小的歌
                      晨光洒落在地板上
                      [Chorus]
                      早安阳光，我们出发
                      一步一步，世界发亮
                      [Outro]
                      早安，为今天干杯
              完整参数:
                description: 指定排除风格、男声、风格强度、多样性和 Persona，完成后回调。
                summary: 完整参数
                value:
                  model: ai-music-api/replace-section
                  callBackUrl: https://your-domain.com/api/callback
                  input:
                    task_id: c2a81e5f09d34b7e8f61a2d4c9b03e75
                    audio_id: f924248f-e765-48fd-9ea9-c64290225e4e
                    prompt: 一段舒缓放松的钢琴间奏
                    lyrics: |-
                      [Chorus]
                      修改后的这一段歌词
                    tags: Jazz
                    title: 放松钢琴
                    negative_tags: Rock
                    infill_start_s: 10.5
                    infill_end_s: 20.75
                    full_lyrics: |-
                      [Verse 1]
                      原有歌词
                      [Chorus]
                      修改后的这一段歌词
                      [Verse 2]
                      更多原有歌词
                    vocal_gender: m
                    style_weight: 0.65
                    weirdness_constraint: 0.65
                    audio_weight: 0.65
                    variety: 1
                    persona_id: persona_123
                    persona_model: style_persona
              替换上传音频的片段:
                description: '`upload_url` + `model` 指定自己的音频，重新生成 30 ~ 45 秒的桥段。'
                summary: 替换上传音频的片段
                value:
                  model: ai-music-api/replace-section
                  input:
                    upload_url: https://example.com/audio.mp3
                    model: V6
                    prompt: 桥段转为更有力量的鼓点和电吉他
                    tags: pop rock
                    title: 我的歌
                    infill_start_s: 30
                    infill_end_s: 45
                    full_lyrics: |-
                      [Verse]
                      原有主歌
                      [Bridge]
                      新的桥段歌词
                      [Chorus]
                      原有副歌
            schema:
              $ref: >-
                #/components/schemas/SunoCreateTaskRequestSunoReplaceSectionInput
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                创建成功:
                  description: '`data.taskId` 为任务 ID。'
                  summary: 创建成功
                  value:
                    code: 200
                    msg: success
                    data:
                      taskId: 7d3f0a9c41e85b2f6a1c9e04b8d27f53
                参数错误（422）:
                  description: 参数不合法，不建任务、不扣费。
                  summary: 参数错误（422）
                  value:
                    code: 422
                    msg: >-
                      input.infill_end_s - input.infill_start_s must be at least
                      10 seconds.
                    data: null
                源任务不可用（422）:
                  description: '`task_id` 不存在、不属于当前账号或不满足 `msg` 中的条件；不建任务、不扣费。'
                  summary: 源任务不可用（422）
                  value:
                    code: 422
                    msg: >-
                      input.task_id must be a succeeded task of this account
                      created in the last 14 days.
                    data: null
                未授权（401）:
                  description: API Key 缺失或无效。
                  summary: 未授权（401）
                  value:
                    code: 401
                    msg: >-
                      Unauthorized - Authentication credentials are missing or
                      invalid
                    data: null
                余额不足（402）:
                  description: 余额不足以支付本次任务。
                  summary: 余额不足（402）
                  value:
                    code: 402
                    msg: >-
                      Insufficient Credits - Account does not have enough
                      credits to perform the operation
                    data: null
                请求过于频繁（429）:
                  description: 超过频率限制，请稍后重试。
                  summary: 请求过于频繁（429）
                  value:
                    code: 429
                    msg: >-
                      Rate Limited - Request limit has been exceeded for this
                      resource
                    data: null
                服务器错误（500）:
                  description: 服务暂时不可用，可稍后重试，不扣费。
                  summary: 服务器错误（500）
                  value:
                    code: 500
                    msg: >-
                      Server Error - An unexpected error occurred while
                      processing the request
                    data: null
              schema:
                $ref: '#/components/schemas/SunoCreateTaskResponse'
          description: >-
            HTTP 状态码始终为 200。`code` 为 `200` 时创建成功，`data.taskId` 为任务 ID；其他 `code`
            为错误，`msg` 为原因，`data` 为 `null`。
          headers:
            X-Request-Id:
              description: 本次请求的 ID，排查问题时请提供。
              schema:
                type: string
components:
  schemas:
    SunoCreateTaskRequestSunoReplaceSectionInput:
      additionalProperties: false
      description: 创建任务的请求体。
      properties:
        model:
          default: ai-music-api/replace-section
          description: |-
            接口名称，决定 `input` 的字段。

            **可选值：**
            - `ai-music-api/replace-section`：Suno 替换音乐片段
          enum:
            - ai-music-api/replace-section
          type: string
        callBackUrl:
          description: >-
            可选，任务完成（成功或失败）后接收回调的地址，须为公网可访问的 `http` / `https`
            地址；推荐生产环境使用，也可以只轮询查询任务接口。回调格式和签名见“任务完成回调”。
          type: string
        input:
          $ref: '#/components/schemas/SunoReplaceSectionInput'
          description: 任务参数，字段由 `model` 决定。
      required:
        - model
        - input
      type: object
    SunoCreateTaskResponse:
      additionalProperties: false
      description: 创建任务的响应。HTTP 状态码始终为 200。
      properties:
        code:
          description: |-
            结果代码：
            - `200`：成功
            - `401`：API Key 缺失或无效
            - `402`：余额不足
            - `404`：模型不存在或未开通
            - `405`：请求方法错误
            - `422`：参数错误，`msg` 为原因，不建任务、不扣费
            - `429`：请求过于频繁，请稍后重试
            - `455`：服务维护中
            - `500`：服务器错误，可稍后重试
            - `501`：生成失败
            - `505`：功能已停用
          format: int64
          type: integer
        msg:
          description: 结果说明：成功时为 `success`，错误时为英文原因。
          type: string
        data:
          $ref: '#/components/schemas/SunoCreateTaskData'
          description: 成功时为任务信息；错误时为 `null`。
      required:
        - code
        - msg
        - data
      type: object
    SunoReplaceSectionInput:
      additionalProperties: false
      description: >-
        `ai-music-api/replace-section` 的参数。歌曲来源二选一（`task_id` + `audio_id`，或
        `upload_url` +
        `model`）；`prompt`、`tags`、`title`、`infill_start_s`、`infill_end_s`、`full_lyrics`
        必填。
      properties:
        task_id:
          description: >-
            替换已生成歌曲时必填，不能与 `upload_url`、`model` 同时使用。必填，源任务 ID：本账号在 DreamTo 上 14
            天内成功的 Suno 任务（createTask 返回的 `data.taskId`）。任务不存在、不属于当前账号、未成功、超过 14
            天或不是可用的源任务类型时返回 `code: 422`，不建任务、不扣费。
          type: string
        audio_id:
          description: 替换已生成歌曲时必填，要替换片段的那首歌。必填，源任务中一首音频的 ID，即查询结果 `response.data[].id`。
          type: string
        upload_url:
          description: >-
            替换上传音频时必填，公网可访问的 `http` / `https` 音频地址；不能与 `task_id`、`audio_id`
            同时使用。
          type: string
        model:
          description: >-
            替换上传音频时必填（仅与 `upload_url` 一起使用）。必填，Suno 模型版本：`V6`、`V6_MINI` 或
            `V6_WILD`。已下线的 V4 ~ V5_5 不再支持。


            **可选值：**

            - `V6`：Suno V6：音乐表现力更强，人声更自然，细节更丰富

            - `V6_MINI`：Suno V6 Mini：轻量快速，兼顾质量与速度

            - `V6_WILD`：Suno V6 Wild：突破创作边界，表达更大胆、更有个性
          enum:
            - V6
            - V6_MINI
            - V6_WILD
          type: string
        prompt:
          description: 必填，替换片段的新歌词或描述，模型据此重新生成这段内容。
          type: string
        lyrics:
          description: 可选，替换片段的歌词，最多 5000 个字符，可用 `[Chorus]` 等标记段落。
          maxLength: 5000
          type: string
        tags:
          description: 必填，替换片段的音乐风格标签，如 `Jazz`、`Electronic`。
          type: string
        title:
          description: 必填，歌名。
          type: string
        negative_tags:
          description: 可选，替换片段中要排除的音乐风格，如 `Rock`。
          type: string
        infill_start_s:
          description: 必填，替换开始时间（秒），`>= 0`，最多 2 位小数；必须小于 `infill_end_s`，且两者之差至少 10 秒。
          format: double
          minimum: 0
          multipleOf: 0.01
          type: number
        infill_end_s:
          description: >-
            必填，替换结束时间（秒），`>= 0`，最多 2 位小数；必须大于 `infill_start_s`，且两者之差至少 10
            秒。替换时长不能超过原曲总时长的 50%。
          format: double
          minimum: 0
          multipleOf: 0.01
          type: number
        full_lyrics:
          description: 必填，替换后整首歌的完整歌词，由未修改的部分和修改后的部分组成。
          type: string
        vocal_gender:
          description: |-
            可选，人声性别偏好。只提高对应性别出现的概率，不保证一定生效。

            **可选值：**
            - `m`：男声
            - `f`：女声
          enum:
            - m
            - f
          type: string
        style_weight:
          description: 可选，对风格 `tags` 的遵循强度，`0` ~ `1`，最多 2 位小数。
          format: double
          maximum: 1
          minimum: 0
          multipleOf: 0.01
          type: number
        weirdness_constraint:
          description: 可选，创意 / 实验性偏离程度，`0` ~ `1`，最多 2 位小数；越大越大胆。
          format: double
          maximum: 1
          minimum: 0
          multipleOf: 0.01
          type: number
        audio_weight:
          description: 可选，音频特征的相对权重，`0` ~ `1`，最多 2 位小数。
          format: double
          maximum: 1
          minimum: 0
          multipleOf: 0.01
          type: number
        variety:
          default: 1
          description: >-
            可选，结果的多样性，`0` ~ `4` 的整数，默认 `1`：`0` 关闭（严格保持风格）、`1` 正常（兼顾稳定与多样）、`2`
            高（风格明显不同）、`3` 更高（大胆探索）、`4` 最大（差异可能非常大）。
          format: double
          maximum: 4
          minimum: 0
          multipleOf: 1
          type: number
        persona_id:
          description: >-
            可选，Persona ID 或 Voice ID，让生成的音乐沿用该 Persona 的风格或该自定义音色。Persona 由“生成
            Persona”接口创建，Voice 由“自定义音色”接口创建。`persona_model` 为 `voice_persona`
            时必须是本账号已就绪的自定义音色（成功的“生成验证短语”任务 ID），否则返回 `code: 422`；`style_persona`
            时原样使用。
          type: string
        persona_model:
          description: |-
            可选，`persona_id` 的类型。

            **可选值：**
            - `style_persona`：风格 Persona：沿用 Persona 的整体音乐风格
            - `voice_persona`：音色 Persona：沿用 Persona 或自定义音色的声音
          enum:
            - style_persona
            - voice_persona
          type: string
      required:
        - prompt
        - tags
        - title
        - infill_start_s
        - infill_end_s
        - full_lyrics
      type: object
    SunoCreateTaskData:
      additionalProperties: false
      description: 新建的任务。
      properties:
        taskId:
          description: 任务 ID（32 位十六进制），用于查询任务，也作为后续接口的 `task_id`。
          type: string
      required:
        - taskId
      type: object
  securitySchemes:
    bearerAuth:
      description: 'DreamTo 控制台创建的 API Key，格式 `Authorization: Bearer <API Key>`。'
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.