Suno · Replace Section
ai-music-api/replace-section changes one part of a song: give the start and end time (infill_start_s / infill_end_s) and the model regenerates that range from the new lyrics in prompt and the style in tags, blending it with the original parts before and after while the rest of the song stays unchanged. Use it to rewrite a verse, swap a chorus or fix a passage you do not like.
The song comes from one of two sources:
The endpoint always works in custom mode: prompt, tags, title, full_lyrics and the time range are required. The result is the complete song with the section replaced, ready for the other endpoints.
Authentication
- Base URL
https://api.dreamto.ai- Authorization
Authorization: Bearer YOUR_API_KEY- Content-Type
application/json- Model name (model)
ai-music-api/replace-section
- A generated song:
task_id(the source task) +audio_id(one of its songs). - An uploaded audio file:
upload_url(a public audio URL) +model(the model version).
Setup
The Suno endpoints use an asynchronous task protocol: every endpoint creates its task with POST /api/v1/jobs/createTask (model selects the endpoint and the parameters go in input) and is queried with GET /api/v1/jobs/recordInfo?taskId=; with callBackUrl the result is pushed to that URL when the task finishes. See the Suno introduction for the flow, chaining tasks and how long files are kept. The base URL is https://api.dreamto.ai; send the API Key in the Authorization: Bearer header.
Every response has HTTP status 200; the code in the body tells the outcome: 200 is success, anything else an error (see the response examples of each endpoint).
| Endpoint | Purpose |
|---|---|
POST /api/v1/jobs/createTask | Create task |
GET /api/v1/jobs/recordInfo?taskId=... | Get task |
POST callBackUrl | Task callback |
Parameters
model is ai-music-api/replace-section; the parameters go in input. Requests that break a rule return code: 422; no task is created or charged.
| Field | Values |
|---|---|
task_id + audio_id | Required for a generated song; cannot be combined with upload_url or model |
upload_url + model | Required for an uploaded audio file; model is V6 / V6_MINI / V6_WILD |
prompt | Required: the new lyrics or description of the replaced section |
tags | Required: the music style of the replaced section |
title | Required: the song title |
infill_start_s / infill_end_s | Required, >= 0 seconds with at most 2 decimals; start must be less than end, the range at least 10 seconds and at most 50% of the original song |
full_lyrics | Required: the complete lyrics of the whole song after the replacement |
lyrics | Optional lyrics of the replaced section, up to 5,000 characters |
negative_tags | Optional styles to keep out of the replaced section |
vocal_gender | Optional, m / f |
style_weight / weirdness_constraint / audio_weight | Optional, 0–1 with at most 2 decimals |
variety | Optional integer from 0 to 4, default 1 |
persona_id / persona_model | Optional Persona ID or custom voice ID and its type (style_persona / voice_persona) |
Pricing
Billed per request: each succeeded task is charged once at the model price shown in the console. The balance is checked for that price when the task is created (code: 402 when insufficient); invalid requests and failed tasks are not charged.
Quick start
Create a task to get data.taskId, poll about every 10 seconds and read response once state is success; or pass callBackUrl to be called back when the task finishes. $DREAMTO_API_KEY is your API Key.
# 1. Create the task
curl -X POST "https://api.dreamto.ai/api/v1/jobs/createTask" \
-H "Authorization: Bearer $DREAMTO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ai-music-api/replace-section",
"input": {
"task_id": "c2a81e5f09d34b7e8f61a2d4c9b03e75",
"audio_id": "f924248f-e765-48fd-9ea9-c64290225e4e",
"prompt": "Good morning, sunshine, here we go\nOne bright step and the whole world glows",
"lyrics": "[Chorus]\nGood morning, sunshine, here we go\nOne bright step and the whole world glows",
"tags": "cheerful acoustic folk-pop",
"title": "Good Morning, Sunshine",
"infill_start_s": 10,
"infill_end_s": 20.5,
"full_lyrics": "[Verse]\nKettle starts its little song\nFirst light slips across the floor\n[Chorus]\nGood morning, sunshine, here we go\nOne bright step and the whole world glows\n[Outro]\nGood morning, cheers to today!"
}
}'
# 2. Query the task
curl "https://api.dreamto.ai/api/v1/jobs/recordInfo?taskId=7d3f0a9c41e85b2f6a1c9e04b8d27f53" \
-H "Authorization: Bearer $DREAMTO_API_KEY"Callback
Pass callBackUrl (a public http / https URL) when creating the task; when the task succeeds or fails DreamTo POSTs the result there once (callback format): on success code is 200, data.callbackType is complete, data.task_id is the task ID and data.data the result; on failure code is the failure code (not 200), msg the reason, and data has only callbackType and task_id. DreamTo calls back once when the task finishes and sends no intermediate-stage (text / first) callbacks.
The request carries X-DreamTo-Event: task.completed, X-DreamTo-Timestamp (UTC, RFC 3339) and X-DreamTo-Signature:
X-DreamTo-Signature = hex( HMAC-SHA256( secret, X-DreamTo-Timestamp + "." + data.task_id + "." + status ) )status is success when the task succeeded and failed when it failed. The secret is generated in the DreamTo console; without one no signature header is sent. Answer with any 2xx to acknowledge; otherwise the callback is retried.
Notes
- Use exactly one source:
task_id+audio_id, orupload_url+model; the two groups cannot be mixed, and a group with a missing field returnscode: 422. - Time range:
infill_start_smust be less thaninfill_end_s, at least 10 seconds apart, with at most 2 decimals (such as10.50). The replaced range must not exceed 50% of the original song; otherwise the task fails. full_lyricsis the lyrics of the whole song after the replacement (the unchanged parts plus the changed part);prompt/lyricsare the content of the replaced section itself.- The results are in
response.data, usually two complete songs with the section replaced, each with a newid(usable as theaudio_idof follow-up endpoints). The files are kept for 14 days. - With
persona_model: voice_persona,persona_idmust be a ready custom voice of this account (the task ID of a succeeded validation-phrase task), otherwisecode: 422is returned; withstyle_personathepersona_idis used as is. taskIdis issued by DreamTo (32 hex digits) and can only be queried with an API Key of the same account; an unknown or expired task returnscode: 422withmsg: recordInfo is null.- The body accepts only
model,callBackUrlandinput; undeclaredinputfields, wrong types and values that break a rule returncode: 422with an English reason inmsg; no task is created or charged. - Every file link in a result (audio, cover image, video and so on) is a DreamTo download link (
/v1/tasks/{task_id}/artifacts/...) that works without an API Key and supportsRange; files are kept for 14 days after the task is created, so download them promptly. paramechoes the create request, withinputas a JSON string that needs a second parse; the credits used are not returned, and the charge is shown in the DreamTo console bills.failCode/failMsgof a failed task come from the model service (content moderation, a source audio that cannot be downloaded and so on); internal errors are reported asfailCode: "500"withfailMsg: "Internal Error, Please try again later.".