# 一键替换成曲

**这是什么**：替换段落 + 自动合并的一站式版本：一次替换生成两个候选，再各自自动合并回整曲，直接产出 2 首完整歌曲，省去手动 replace_merge。

**什么时候用**：想改某一段又不想手动合并时用——直接拿两首可选的完整成品。

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

## 请求参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| task | string | 是 | 固定填 replace_auto |
| taskId | string | 是 | 源歌曲所属的任务 ID —— 来源：上一个生成任务提交后返回的 taskId（即那次响应的 data.id） |
| clipId | string | 是 | 要编辑的源歌曲片段 ID —— 来源：该 taskId 结果里某首歌的 id（会成为本次编辑锚点 edit_session_id） |
| rangeStartS | number | 是 | 被替换段落的开始秒数 —— 来源：你选定，需落在原曲时长内 |
| rangeEndS | number | 是 | 被替换段落的结束秒数 —— 来源：你选定，需大于 rangeStartS |
| infillLyrics | string | 是 | 替换段落要唱的新歌词 —— 来源：你自定义（回写到结果 concat_history.infill_lyrics） |
| tags | string | — | 风格标签 —— 来源：你自定义，影响替换段曲风（写入结果 metadata.tags） |
| title | string | — | 新曲标题 —— 来源：你自定义（回显在 data.param.title；成品 song.title 可能仍保留原名） |
| 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_auto",
    "taskId": "680886fa5bb94a8d8e4f8630a09f560e",
    "clipId": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
    "rangeStartS": 8,
    "rangeEndS": 16,
    "infillType": "smart",
    "infillLyrics": "窗前明月光光 疑是地上霜霜",
    "tags": "Happy",
    "title": "两只老虎(自动替换)"
  }'
# -> { "code":200, "data":"<taskId>" }
```

## 响应示例
```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "id": "680886fa5bb94a8d8e4f8630a09f560e",
    "taskType": "replace_auto",
    "status": "succeeded",
    "errorMsg": "",
    "param": {
      "task": "replace_auto",
      "taskId": "680886fa5bb94a8d8e4f8630a09f560e",
      "clipId": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
      "rangeStartS": 8,
      "rangeEndS": 16,
      "infillType": "smart",
      "infillLyrics": "窗前明月光光 疑是地上霜霜",
      "tags": "Happy",
      "title": "两只老虎(自动替换)",
      "mergeTotal": 2,
      "mergeDone": 2,
      "mergedResults": [
        { "id": "6d4ba59f-f409-4148-a597-eeea04c6c6a7", "title": "两只老虎", "audio_url": "https://cdn1.suno.ai/6d4ba59f-f409-4148-a597-eeea04c6c6a7.mp3", "batch_index": 0 },
        { "id": "de32f599-1379-4421-9833-97e7774648f5", "title": "两只老虎", "audio_url": "https://cdn1.suno.ai/de32f599-1379-4421-9833-97e7774648f5.mp3", "batch_index": 0 }
      ]
    },
    "result": [
      {
        "id": "6d4ba59f-f409-4148-a597-eeea04c6c6a7",
        "title": "两只老虎",
        "handle": "t43vcfowv8aq3",
        "status": "complete",
        "user_id": "f1e1b014-33db-4d8b-88c2-a9acaeb1d7b6",
        "metadata": {
          "tags": "Happy",
          "type": "concat_infilling",
          "prompt": "无",
          "duration": 24.96,
          "is_remix": true,
          "can_remix": true,
          "concat_history": [
            {
              "id": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
              "type": "gen",
              "infill": true,
              "source": "ios",
              "infill_dur_s": 8,
              "infill_end_s": 16,
              "infill_start_s": 8,
              "infill_lyrics": "窗前明月光光 疑是地上霜霜",
              "include_future_s": 2,
              "include_history_s": 2,
              "infill_context_end_s": 24.96,
              "infill_context_start_s": 0
            },
            { "id": "b3f18617-a00a-48f0-91d0-eca6c21ae24f" }
          ],
          "edit_session_id": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
          "secondary_badges": [ { "icon_key": "full_song", "display_name": "Full Song" } ]
        },
        "audio_url": "https://cdn1.suno.ai/6d4ba59f-f409-4148-a597-eeea04c6c6a7.mp3",
        "image_url": "https://cdn2.suno.ai/image_b3f18617-a00a-48f0-91d0-eca6c21ae24f.jpeg",
        "video_url": "",
        "clip_roots": { "clip_attribution_type": "remix" },
        "media_urls": [
          { "url": "https://d2lwuy8qc234o3.cloudfront.net/1/clip/6d4ba59f-f409-4148-a597-eeea04c6c6a7.m4a", "delivery": "progressive", "content_type": "m4a-opus" },
          { "url": "https://cdn1.suno.ai/6d4ba59f-f409-4148-a597-eeea04c6c6a7.mp3", "delivery": "progressive", "content_type": "mp3" }
        ],
        "model_name": "chirp-crow",
        "batch_index": 0,
        "created_at": "2026-07-30T09:18:44.943Z",
        "image_large_url": "https://cdn2.suno.ai/image_large_b3f18617-a00a-48f0-91d0-eca6c21ae24f.jpeg",
        "major_model_version": "v5"
      },
      {
        "id": "de32f599-1379-4421-9833-97e7774648f5",
        "title": "两只老虎",
        "handle": "mv78d6mpj5tpr",
        "status": "complete",
        "user_id": "4274bb10-a9a7-4ca2-aa30-b3b02e63d568",
        "metadata": {
          "tags": "Happy",
          "type": "concat_infilling",
          "prompt": "无",
          "duration": 24.96,
          "is_remix": true,
          "can_remix": true,
          "concat_history": [
            {
              "id": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
              "type": "gen",
              "infill": true,
              "source": "ios",
              "infill_dur_s": 8,
              "infill_end_s": 16,
              "infill_start_s": 8,
              "infill_lyrics": "窗前明月光光 疑是地上霜霜",
              "include_future_s": 2,
              "include_history_s": 2,
              "infill_context_end_s": 24.96,
              "infill_context_start_s": 0
            },
            { "id": "ca564b42-af29-472e-a3df-fb7828c94366" }
          ],
          "edit_session_id": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
          "secondary_badges": [ { "icon_key": "full_song", "display_name": "Full Song" } ]
        },
        "audio_url": "https://cdn1.suno.ai/de32f599-1379-4421-9833-97e7774648f5.mp3",
        "image_url": "https://cdn2.suno.ai/image_ca564b42-af29-472e-a3df-fb7828c94366.jpeg",
        "video_url": "",
        "media_urls": [
          { "url": "https://d2lwuy8qc234o3.cloudfront.net/1/clip/de32f599-1379-4421-9833-97e7774648f5.m4a", "delivery": "progressive", "content_type": "m4a-opus" },
          { "url": "https://cdn1.suno.ai/de32f599-1379-4421-9833-97e7774648f5.mp3", "delivery": "progressive", "content_type": "mp3" }
        ],
        "model_name": "chirp-crow",
        "batch_index": 0,
        "created_at": "2026-07-30T09:18:45.472Z",
        "image_large_url": "https://cdn2.suno.ai/image_large_ca564b42-af29-472e-a3df-fb7828c94366.jpeg",
        "major_model_version": "v5"
      }
    ],
    "createTime": 1785403004000,
    "completeTime": 1785403125472
  }
}
```

## 响应字段说明
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| code | number | 状态码，200 表示成功 |
| msg | string | 提示信息 |
| data.id | string | 任务 ID（= 提交时拿到的 taskId，用于轮询查询） |
| data.taskType | string | 任务类型，恒为 replace_auto |
| data.status | string | 任务状态：pending 处理中 / succeeded 成功 / failed 失败 |
| data.errorMsg | string | 失败原因，成功时为空 |
| data.param | object | 回显你提交的请求参数，并额外带自动合并的进度与结果 |
| data.param.mergeTotal / mergeDone | number | 需自动合并 / 已完成合并的候选数（都为 2 即两首整曲已产出） |
| data.param.mergedResults | array | 已合并完成的整曲数组，内容与 data.result 一致 |
| data.result | array | ⚠ 直接是 2 首完整歌曲的数组（非 replace_merge 的 {clips:[…]} 对象）——两个候选各自合并后的整曲 |
| data.result[].id | string | 整曲 clipId，可继续 extend / cover / 导出 |
| data.result[].audio_url | string | 整曲音频地址（mp3） |
| data.result[].image_url | string | 封面图地址（image_large_url 为大图） |
| data.result[].metadata.type | string | 恒为 concat_infilling（替换段落已拼接回整曲，带 Full Song 徽标） |
| data.result[].metadata.duration | number | 整曲时长（秒），两首可能相同或不同 |
| data.result[].metadata.edit_session_id | string | 编辑会话 ID（= 你传的 clipId），两首整曲同源 |
| data.result[].metadata.concat_history[] | array | 拼接血缘：第 1 条 type=gen 为替换段（infill_start_s / infill_end_s / infill_dur_s / infill_lyrics / infill_context_start_s·end_s，与请求对应），第 2 条为被拼接的原曲片段 id |
| data.result[].batch_index | number | 恒为 0——两首各自独立合并，不像候选那样是 0 / 1 |
| data.result[].media_urls | array | 多格式音频地址（m4a-opus / mp3） |
| data.result[].major_model_version | string | 生成所用模型版本，如 v5 / v4.5 |
| data.createTime / completeTime | number | 任务提交 / 完成时间（毫秒时间戳） |

## OpenAI 协议写法
同一个 task 也可用 `POST /v1/audio/generations` 调用（body 加 `task: "replace_auto"`，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_auto",
  "taskId": "680886fa5bb94a8d8e4f8630a09f560e",
  "clipId": "31732e8d-996c-4b4a-b2ae-ca3efaed5af9",
  "rangeStartS": 8,
  "rangeEndS": 16,
  "infillType": "smart",
  "infillLyrics": "窗前明月光光 疑是地上霜霜",
  "tags": "Happy",
  "title": "两只老虎(自动替换)"
}'
# -> { "id":"audio_<taskId>", "object":"audio.generation", "status":"queued", ... }
# poll: GET https://api.novapi.ai/v1/audio/generations/audio_<taskId>
```
