# 替换段落

**这是什么**：只重做歌曲中的某一段（如第二段主歌），其它部分不变。

**什么时候用**：一首歌大部分满意、只有某段想重做时用。

## 接口地址
- POST `/api/cqt/generator/suno` (task: `replace_section`)
- GET `/api/cqt/info/suno?id={taskId}`

## 请求参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| task | string | 是 | 固定填 replace_section |
| taskId | string | 是 | 源歌曲所属任务 ID |
| clipId | string | 是 | 源歌曲片段 ID |
| rangeStartS | number | 是 | 被替换段落的开始秒数 |
| rangeEndS | number | 是 | 被替换段落的结束秒数 |
| infillLyrics | string | 是 | 替换段落的新歌词 |
| tags | string | — | 风格标签 |
| title | string | — | 歌曲标题 |
| infillType | enum | — | smart（默认）/ classic / fixed |

## 请求示例
```bash
curl -X POST https://api.novapi.ai/api/cqt/generator/suno \
  -H 'Authorization: Bearer <API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{
    "task": "replace_section",
    "taskId": "d649231618784ee4b9cfa059ac50be5e",
    "clipId": "eb1c6c96-a102-4bbb-82c2-87c3b126a44e",
    "tags": "Happy",
    "title": "两只老虎(聪明)",
    "infillLyrics": "两只老虎 两只老虎跑得快 一只没有耳朵 一只没有尾巴 真奇怪",
    "rangeStartS": 7.56,
    "rangeEndS": 15.98
  }'
# -> { "code":200, "data":"<taskId>" }
```

## 响应示例
```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "id": "c8d1e607b5a84c41889e23981ffd6305",
    "taskType": "replace_section",
    "status": "succeeded",
    "errorMsg": "",
    "param": {
      "task": "replace_section",
      "taskId": "d649231618784ee4b9cfa059ac50be5e",
      "clipId": "eb1c6c96-a102-4bbb-82c2-87c3b126a44e",
      "tags": "Happy",
      "title": "两只老虎(聪明)",
      "infillLyrics": "两只老虎 两只老虎跑得快 …（完整歌词已省略）",
      "rangeStartS": 7.56,
      "rangeEndS": 15.98
    },
    "result": [
      {
        "id": "ad924885-4655-4ca4-ab36-e67c12e3f7e5",
        "title": "两只老虎(聪明)",
        "handle": "rositabadgercldrq",
        "status": "complete",
        "user_id": "8338d85e-0591-4277-a134-cc1080a107f5",
        "metadata": {
          "tags": "Happy",
          "task": "infill",
          "type": "gen",
          "infill": true,
          "prompt": "两只老虎 两只老虎跑得快 …（完整歌词已省略）",
          "duration": 14.44,
          "is_remix": true,
          "infill_lyrics": "两只老虎 两只老虎跑得快 …（完整歌词已省略）",
          "edited_clip_id": "eb1c6c96-a102-4bbb-82c2-87c3b126a44e",
          "lyrics_updated": false,
          "history": [
            {
              "id": "eb1c6c96-a102-4bbb-82c2-87c3b126a44e",
              "type": "gen",
              "infill": true,
              "infill_start_s": 7.56,
              "infill_end_s": 15.98,
              "infill_dur_s": 8.42,
              "infill_context_start_s": 0,
              "infill_context_end_s": 61,
              "include_history_s": 2,
              "include_future_s": 2
            }
          ]
        },
        "audio_url": "https://cdn1.suno.ai/ad924885-4655-4ca4-ab36-e67c12e3f7e5.mp3",
        "image_url": "https://cdn2.suno.ai/image_ad924885-4655-4ca4-ab36-e67c12e3f7e5.jpeg",
        "image_large_url": "https://cdn2.suno.ai/image_large_ad924885-4655-4ca4-ab36-e67c12e3f7e5.jpeg",
        "video_url": "",
        "clip_roots": {
          "clips": [
            { "user_handle": "playfulsubtlety0358", "user_display_name": "PlayfulSubtlety0358" }
          ],
          "clip_attribution_type": "remix"
        },
        "media_urls": [
          { "url": "https://d2lwuy8qc234o3.cloudfront.net/1/clip/ad924885-4655-4ca4-ab36-e67c12e3f7e5.m4a", "delivery": "progressive", "content_type": "m4a-opus" },
          { "url": "https://cdn1.suno.ai/ad924885-4655-4ca4-ab36-e67c12e3f7e5.mp3", "delivery": "progressive", "content_type": "mp3" }
        ],
        "model_name": "chirp-crow",
        "batch_index": 0,
        "created_at": "2026-07-08T07:27:11.972Z",
        "major_model_version": "v5"
      },
      {
        "id": "764ee8ad-5c6f-4d99-8b78-c6054712094d",
        "title": "两只老虎(聪明)",
        "status": "complete",
        "metadata": {
          "task": "infill",
          "infill": true,
          "duration": 17.52,
          "is_remix": true,
          "edited_clip_id": "eb1c6c96-a102-4bbb-82c2-87c3b126a44e"
        },
        "audio_url": "https://cdn1.suno.ai/764ee8ad-5c6f-4d99-8b78-c6054712094d.mp3",
        "image_url": "https://cdn2.suno.ai/image_764ee8ad-5c6f-4d99-8b78-c6054712094d.jpeg",
        "batch_index": 1,
        "major_model_version": "v5"
      }
    ],
    "createTime": "2026-07-08 15:27:09",
    "completeTime": "2026-07-08 15:27:44"
  }
}
```

## 响应字段说明
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| code | number | 状态码，200 表示成功 |
| msg | string | 提示信息 |
| data.id | string | 任务 ID（= 提交时拿到的 taskId，用于轮询查询） |
| data.taskType | string | 任务类型，与提交的 task 一致 |
| data.status | string | 任务状态：pending 处理中 / succeeded 成功 / failed 失败 |
| data.errorMsg | string | 失败原因，成功时为空 |
| data.param | object | 原样回显你提交的请求参数 |
| data.result | array | 生成结果，一次返回 2 条候选片段 |
| data.result[].id | string | 生成片段的 clipId，可继续用于再次 extend / cover 等 |
| data.result[].audio_url | string | 音频文件地址（mp3） |
| data.result[].video_url | string | 视频文件地址（mp4），有时为空需稍后再查 |
| data.result[].image_url | string | 封面图地址（image_large_url 为大图） |
| data.result[].title | string | 歌曲标题 |
| data.result[].status | string | 片段状态，complete 表示可下载 |
| data.result[].metadata.duration | number | 音频总时长（秒） |
| data.result[].metadata.tags | string | 风格标签 |
| data.result[].metadata.task | string | replace_section 的片段 metadata.task 显示为 infill（局部重绘） |
| data.result[].metadata.infill | bool | 是否局部重绘，replace_section 恒为 true |
| data.result[].metadata.infill_lyrics | string | 被替换段落的新歌词（回显 infillLyrics） |
| data.result[].metadata.edited_clip_id | string | 被编辑的源片段 ID（= 你传的 clipId） |
| data.result[].metadata.history[].infill_start_s / infill_end_s / infill_dur_s | number | 被替换段落的起止秒与时长 |
| data.result[].metadata.history[].infill_context_start_s / infill_context_end_s | number | 生成时参考的上下文范围（秒） |
| data.result[].metadata.is_remix | bool | 是否二次创作，replace_section 恒为 true |
| data.result[].clip_roots | object | 源片段（父曲）信息：标题 / 封面 / 作者 |
| data.result[].media_urls | array | 多格式音频地址（m4a-opus / mp3） |
| data.result[].batch_index | number | 候选序号（0、1） |
| data.result[].major_model_version | string | 生成所用模型版本，如 v4.5 / v5.5 |
| data.createTime / completeTime | string | 任务提交时间 / 完成时间 |
| 其它字段 | — | action_config / model_badges / secondary_badges / ownership / avatar_image_url 等为 Suno 前端展示用，可忽略 |

## OpenAI 协议写法
同一个 task 也可用 `POST /v1/audio/generations` 调用（body 加 `task: "replace_section"`，model 写成 suno-v6 形式），用 `GET /v1/audio/generations/{id}` 轮询，非音频类结果在 `result` 字段。

```bash
curl -X POST https://api.novapi.ai/v1/audio/generations \
  -H 'Authorization: Bearer <API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "suno",
  "task": "replace_section",
  "taskId": "d649231618784ee4b9cfa059ac50be5e",
  "clipId": "eb1c6c96-a102-4bbb-82c2-87c3b126a44e",
  "tags": "Happy",
  "title": "两只老虎(聪明)",
  "infillLyrics": "两只老虎 两只老虎跑得快 一只没有耳朵 一只没有尾巴 真奇怪",
  "rangeStartS": 7.56,
  "rangeEndS": 15.98
}'
# -> { "id":"audio_<taskId>", "object":"audio.generation", "status":"queued", ... }
# poll: GET https://api.novapi.ai/v1/audio/generations/audio_<taskId>
```
