MusicAPI
HomeDocs
HomeDocs
  1. sonic
  • Introduction
  • Credits Usage Guide
  • Music API FAQ & Troubleshooting
  • Special Scenarios
  • Error handling
  • Webhook Integration Guide
  • sonic
    • Sonic Instructions
    • create / extend / cover / remaster / add vocals / add instrumental
      POST
    • upload and extend music
      POST
    • upload and cover music
      POST
    • create persona
      POST
    • sample
      POST
    • mashup
      POST
    • get BPM
      POST
    • get VOX
      POST
    • get wav
      POST
    • get midi
      POST
    • get lyrics timeline
      POST
    • upsample tags
      POST
    • stems basic
      POST
    • stems full
      POST
    • replace section
      POST
    • upload music
      POST
    • get music
      GET
  • riffusion(Deprecated)
    • Riffusion instructions
    • create music (with lyrics)
      POST
    • create music (with description)
      POST
    • cover music
      POST
    • extend music
      POST
    • replace music section
      POST
    • swap music sound
      POST
    • swap music vocals
      POST
    • upload
      POST
    • get music
      GET
  • producer
    • Producer instructions
    • Complete Request Examples
    • create music
    • upload
    • download
    • get music
  • studio(Unavailable)
    • Studio Instructions
    • description mode (Use case1)
    • extend mode (Use case2)
    • custom mode (Use case3)
    • instrumental mode (Use case4)
    • get music
  • lyrics generation
    • Make Lyrics
  • nuro
    • Nuro Instruction
    • Error handling
    • create vocal music
    • create instrument music
    • get music
  • get-credits
    GET
  • Schemas
    • 记录不存在
    • 参数不正确
HomeDocs
HomeDocs
  1. sonic

replace section

POST
https://api.musicapi.ai/api/v1/sonic/replace-section
Replace a section of lyrics in an existing song to generate new music. The new lyrics should overlap with the original lyrics, and the timing should correspond appropriately.
Credits cost: 15

How to Use#

Original lyrics:
[Verse 1]
Walking down the street
Feeling the beat

[Chorus]
This is my song
Singing all day long

[Verse 2]
Under the moonlight
Everything feels right

[Outro]
The night goes on
If you want to replace Verse 2 with new lyrics:
infill_lyrics: [Verse 2]\nDancing in the rain\nForgetting all the pain (the new lyrics to replace)
prompt: This is my song\nSinging all day long\n\n[Verse 2]\nDancing in the rain\nForgetting all the pain\n\n[Outro]\nThe night goes on (context with original lyrics before and after the new lyrics)
infill_start_s: 45 (start time of Verse 2)
infill_end_s: 60 (end time of Verse 2)
This way, the system can generate the best result based on the context and new lyrics fragment.

Auto Concat Feature#

When auto_concat is set to true, the system will automatically concatenate the replaced sections into complete songs:
1.
Replace Section: Generates 2 replaced music fragments
2.
Auto Concat: Automatically concatenates each fragment into a full song
3.
Result: Returns 2 sets of paired data, each containing:
replaced: The replaced section fragment
full: The complete concatenated song
Response format with auto_concat:
{
  "code": 200,
  "data": [
    {
      "replaced": { /* Fragment 1 data */ },
      "full": { /* Complete song 1 data */ }
    },
    {
      "replaced": { /* Fragment 2 data */ },
      "full": { /* Complete song 2 data */ }
    }
  ],
  "message": "success"
}
Without auto_concat (default): Returns only the 2 replaced fragments, you need to manually call the concat API to get complete songs.

Important Notes#

infill_start_s must be less than infill_end_s
Both time values must be non-negative
The new lyrics should have some overlap with the original lyrics
Timing should correspond appropriately for best results
When using auto_concat=true, polling may take longer as it waits for both replace and concat operations to complete

Polling Result#

Use the task query endpoint with the returned task_id to poll for results. Recommended polling interval: 15-25 seconds.
Status codes during auto_concat:
202: Task in progress (replace section or concat in progress)
200: Task completed successfully

Request

Authorization
JWT Bearer
Add the parameter
Authorization
to Headers
Example:
Authorization: ********************
or
Body Params application/json

Examples
{
    "clip_id": "ca537a0d-c5a5-45c2-871f-10b04b1530ab",
    "mv": "chirp-v4-5-plus",
    "prompt": "origin lyrics",
    "infill_lyrics": "new lyrics",
    "infill_start_s": 30,
    "infill_end_s": 45,
    "title": "My Song",
    "tags": "pop, upbeat"
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
cURL
curl --location --request POST 'https://api.musicapi.ai/api/v1/sonic/replace-section' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "clip_id": "ca537a0d-c5a5-45c2-871f-10b04b1530ab",
    "mv": "chirp-v4-5-plus",
    "prompt": "origin lyrics",
    "infill_lyrics": "new lyrics",
    "infill_start_s": 30,
    "infill_end_s": 45,
    "title": "My Song",
    "tags": "pop, upbeat"
}'

Responses

🟢200成功
application/json
success
Body

Example
{
    "message": "success",
    "task_id": "81ed9f60-56ae-48c1-9c46-33a8220dfca7"
}
Modified at 2026-01-31 16:45:53
Previous
stems full
Next
upload music
Built with