# Replace & Auto-merge

**What**：One-shot replace_section + auto-merge: one replace produces two candidates, each is auto-merged back into a full track, directly yielding 2 complete songs — no manual replace_merge needed.

**When**：Use when you want to redo a section but skip the manual merge step — get two finished full songs to pick from.

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

## Request params
| Param | Type | Required | Description |
| --- | --- | --- | --- |
| task | string | Yes | Fixed value: replace_auto |
| taskId | string | Yes | Task ID the source song belongs to — source: the taskId returned by the prior generation task (that response’s data.id) |
| clipId | string | Yes | Source song clip ID to edit — source: a song id from that taskId’s result (becomes this edit’s edit_session_id) |
| rangeStartS | number | Yes | Start second of the section to replace — source: chosen by you, must fall within the source track |
| rangeEndS | number | Yes | End second of the section to replace — source: chosen by you, must be greater than rangeStartS |
| infillLyrics | string | Yes | New lyrics for the replaced section — source: your input (echoed to result concat_history.infill_lyrics) |
| tags | string | — | Style tags — source: your input, shapes the replaced section’s style (written to result metadata.tags) |
| title | string | — | New song title — source: your input (echoed in data.param.title; the finished song.title may keep the original name) |
| infillType | enum | — | smart (default, smart stitching) / classic / fixed — source: your choice |

## Request example
```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>" }
```

## Response example
```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
  }
}
```

## Response fields
| Field | Type | Description |
| --- | --- | --- |
| code | number | Status code; 200 = success |
| msg | string | Message |
| data.id | string | Task ID (the taskId returned on submit; used to poll) |
| data.taskType | string | Task type; always "replace_auto" |
| data.status | string | Status: pending / succeeded / failed |
| data.errorMsg | string | Failure reason; empty on success |
| data.param | object | Echo of your request params, plus the auto-merge progress and results |
| data.param.mergeTotal / mergeDone | number | Candidates to auto-merge / already merged (both = 2 means both full songs are ready) |
| data.param.mergedResults | array | Array of merged full songs; same content as data.result |
| data.result | array | An array of 2 full songs (NOT replace_merge’s {clips:[…]} object) — each candidate auto-merged into a full track |
| data.result[].id | string | Full-song clipId; reusable for extend / cover / export |
| data.result[].audio_url | string | Full-song audio URL (mp3) |
| data.result[].image_url | string | Cover image URL (image_large_url is the large one) |
| data.result[].metadata.type | string | Always "concat_infilling" (replaced section merged back into the full song; carries a Full Song badge) |
| data.result[].metadata.duration | number | Full-song duration (seconds); the two songs may match or differ |
| data.result[].metadata.edit_session_id | string | Edit session ID (= the clipId you passed); both songs share the same source |
| data.result[].metadata.concat_history[] | array | Concat lineage: entry 1 (type=gen) is the replaced section (infill_start_s / infill_end_s / infill_dur_s / infill_lyrics / infill_context_start_s·end_s, matching the request); entry 2 is the source clip id it was stitched with |
| data.result[].batch_index | number | Always 0 — each song is merged independently, not indexed 0 / 1 like candidates |
| data.result[].media_urls | array | Multi-format audio URLs (m4a-opus / mp3) |
| data.result[].major_model_version | string | Model version used, e.g. v5 / v4.5 |
| data.createTime / completeTime | number | Task submit / completion time (epoch millis) |

## OpenAI-style call
This task is also available via `POST /v1/audio/generations` (add `task: "replace_auto"` to the body, write model as suno-v6); poll `GET /v1/audio/generations/{id}`, non-audio results are in `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>
```
