Replace Section APIInpaint & Regenerate Part of a Song
Fix or rewrite just one part of a track without regenerating the whole song. Set an infill window on a clip, regenerate that section, poll for the result, and download — with API keys, free trial credits, pricing, webhooks, and production-ready docs.
What is the Replace Section API?
Think of it as inpainting for audio: you pick a time window with infill_start_s and infill_end_s, and only that part of the song is regenerated while the rest is preserved. It's the surgical alternative to re-rolling the whole track.
- Surgical Edits
Regenerate just a verse, chorus, or rough patch — the rest of the song stays exactly as it was.
- Precise Window
Specify the exact seconds to replace with
infill_start_s/infill_end_s.- Steerable
Pass a prompt (and optional vocal gender) to control the new content for that window.
API Examples
Replace a window on a clip, then poll the task until the edit is ready.
1curl -X POST 'https://api.musicapi.ai/api/v1/sonic/replace-section' \
2--header 'Authorization: Bearer YOUR_API_KEY' \
3--header 'Content-Type: application/json' \
4--data '{
5 "clip_id": "YOUR_CLIP_ID",
6 "mv": "sonic-v5",
7 "infill_start_s": 30,
8 "infill_end_s": 45,
9 "prompt": "soaring chorus with layered harmonies"
10}'Why Build Section Edits on MusicAPI?
Keep the Good Parts
Only the chosen window changes; the rest is untouched.
Async + Fast
Returns a task id instantly; edits finish in 1-3 min.
Auto-Refunds
Failed upstream tasks are refunded; polling is free.
Blends Seamlessly
New audio is rendered to fit the surrounding track.
Replace Section API: Pricing, Free Access & API Keys
Developers adding section edits usually want three answers: how to test for free, how to get an API key, and how cost scales after the prototype works.
Free trial
Use free credits to test replace-section, polling, and downloads before choosing a paid plan.
Pricing
Credit-based, same as generation. Estimate per-edit cost on the pricing page.
API keys
Generate a bearer token in your account, keep it server-side, and call the replace-section endpoint.
Ready to Edit Songs Surgically?
Add section-level editing to your app with a single endpoint. Start free, then scale with predictable credit pricing.
Frequently Asked Questions
Everything you need to know about replacing a section with the API.
What is a replace section (inpainting) API?
A replace section API regenerates only a chosen time window of an existing AI song — like inpainting for audio. With MusicAPI you POST a clip id and an infill start/end to /api/v1/sonic/replace-section and only that section is re-rendered while the rest stays intact.
How do I replace a section of a song with the API?
POST to https://api.musicapi.ai/api/v1/sonic/replace-section with clip_id, mv (model version), infill_start_s and infill_end_s (the window in seconds), and optionally a prompt for the new content. The call returns a task_id; poll GET /api/v1/sonic/task/{id} until the edited track is ready.
What are infill_start_s and infill_end_s?
They define the time window (in seconds) that gets regenerated — for example infill_start_s 30 and infill_end_s 45 replaces the audio between 0:30 and 0:45. Everything outside the window is preserved.
Can I change the lyrics or style of the replaced part?
Yes — pass a prompt to steer the new content for that window, and optionally vocal_gender. The model fills the window to blend with the surrounding audio.
How much does replacing a section cost?
Replace section runs on credit-based pricing like generation. Test with free trial credits, estimate per-task cost on the pricing page, and upgrade as volume grows. Failed upstream tasks are auto-refunded and polling task status is free.
Is replace section synchronous or asynchronous?
Asynchronous. The call returns a task_id immediately and the edited track is produced in the background, typically within 1-3 minutes. Use polling on the task endpoint or webhooks to detect completion.
Do the results include commercial rights?
Yes, audio generated through the API comes with commercial rights included. You own the generated content and can use it for commercial purposes.