# 合并片段

**这是什么**：把多个音频片段拼接/合并成一个。

**什么时候用**：想把分段生成的音乐合成完整一首时用。

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

## 请求参数
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| task | string | 是 | 固定填 replace_merge |
| clipId | string | 是 | 要合并的片段 ID |
| editSessionId | string | 是 | 编辑会话 ID（来自替换段落任务） |

## 请求示例
```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_merge",
    "clipId": "214f6b75-81c9-46a4-9e68-2f8e496ce5c0",
    "editSessionId": "2d2991ed-401e-4926-9e7e-9963108e850c"
  }'
# -> { "code":200, "data":"<taskId>" }
```

## 响应示例
```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "id": "a99ab659a9104c118f2e608a6131d8dc",
    "taskType": "replace_merge",
    "status": "succeeded",
    "errorMsg": "",
    "param": {
      "task": "replace_merge",
      "clipId": "214f6b75-81c9-46a4-9e68-2f8e496ce5c0",
      "editSessionId": "2d2991ed-401e-4926-9e7e-9963108e850c"
    },
    "result": {
      "clips": [
        {
          "id": "836f89ad-6812-42fe-9116-73e86fcfaf4e",
          "title": "两只老虎",
          "handle": "azqrxeykoa",
          "status": "complete",
          "user_id": "ab75d2ee-a55b-405d-8606-d51e8720a4fe",
          "metadata": {
            "tags": "Happy",
            "type": "concat_infilling",
            "prompt": "空",
            "duration": 99.88,
            "is_remix": false,
            "can_remix": true,
            "edit_session_id": "2d2991ed-401e-4926-9e7e-9963108e850c",
            "concat_history": [
              {
                "id": "2d2991ed-401e-4926-9e7e-9963108e850c",
                "type": "gen",
                "infill": true,
                "infill_start_s": 6.36,
                "infill_end_s": 30.8,
                "infill_dur_s": 24.44,
                "infill_lyrics": "聪明老虎 聪明老虎跑得慢 …（完整歌词已省略）",
                "infill_context_start_s": 0,
                "infill_context_end_s": 99.92
              },
              { "id": "214f6b75-81c9-46a4-9e68-2f8e496ce5c0" }
            ],
            "can_publish_with_vocal": true
          },
          "audio_url": "https://cdn1.suno.ai/836f89ad-6812-42fe-9116-73e86fcfaf4e.mp3",
          "image_url": "https://cdn2.suno.ai/image_214f6b75-81c9-46a4-9e68-2f8e496ce5c0.jpeg",
          "image_large_url": "https://cdn2.suno.ai/image_large_214f6b75-81c9-46a4-9e68-2f8e496ce5c0.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/836f89ad-6812-42fe-9116-73e86fcfaf4e.m4a", "delivery": "progressive", "content_type": "m4a-opus" },
            { "url": "https://cdn1.suno.ai/836f89ad-6812-42fe-9116-73e86fcfaf4e.mp3", "delivery": "progressive", "content_type": "mp3" }
          ],
          "model_name": "chirp-auk",
          "batch_index": 0,
          "created_at": "2026-07-08T07:29:29.831Z",
          "major_model_version": "v4.5"
        }
      ]
    },
    "createTime": "2026-07-08 15:29:24",
    "completeTime": "2026-07-08 15:29:50"
  }
}
```

## 响应字段说明
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| code | number | 状态码，200 表示成功 |
| msg | string | 提示信息 |
| data.id | string | 任务 ID（= 提交时拿到的 taskId） |
| data.taskType | string | 任务类型，恒为 replace_merge |
| data.status | string | 任务状态：pending 处理中 / succeeded 成功 / failed 失败 |
| data.param | object | 原样回显你提交的请求参数 |
| data.result | object | ⚠ 这里是对象（不是数组），成品在 result.clips 里 |
| data.result.clips | array | 合并后的成品片段（通常 1 条完整歌） |
| data.result.clips[].id | string | 成品片段的 clipId |
| data.result.clips[].audio_url | string | 完整歌音频地址（mp3） |
| data.result.clips[].image_url | string | 封面图地址（image_large_url 为大图） |
| data.result.clips[].status | string | 片段状态，complete 表示可下载 |
| data.result.clips[].metadata.type | string | 合并类型，concat_infilling（拼接局部重绘段） |
| data.result.clips[].metadata.duration | number | 合并后总时长（秒） |
| data.result.clips[].metadata.edit_session_id | string | 编辑会话 ID（= 你传的 editSessionId） |
| data.result.clips[].metadata.concat_history | array | 拼接溯源：由哪些片段 / 哪段 infill 合并而来 |
| data.result.clips[].media_urls | array | 多格式音频地址（m4a-opus / mp3） |
| data.result.clips[].major_model_version | string | 生成所用模型版本，如 v4.5 |
| data.createTime / completeTime | string | 任务提交时间 / 完成时间 |
| 其它字段 | — | action_config / model_badges / secondary_badges / avatar_image_url 等为 Suno 前端展示用，可忽略 |

## OpenAI 协议写法
同一个 task 也可用 `POST /v1/audio/generations` 调用（body 加 `task: "replace_merge"`，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_merge",
  "clipId": "214f6b75-81c9-46a4-9e68-2f8e496ce5c0",
  "editSessionId": "2d2991ed-401e-4926-9e7e-9963108e850c"
}'
# -> { "id":"audio_<taskId>", "object":"audio.generation", "status":"queued", ... }
# poll: GET https://api.novapi.ai/v1/audio/generations/audio_<taskId>
```
