POST
/
inpaint
Python
import requests

url = "https://api.musicgpt.com/api/public/v1/inpaint"
headers = {"Authorization": "<API_KEY>"}
data = {
  "prompt": "Add a soft guitar solo here",
  "replace_start_at": 12.5,
  "replace_end_at": 20.0,
  "lyrics": "This is where my story begins",
  "gender": "male",
  "webhook_url": "https://example.com/webhook"
}

# Option 1: audio_url
data["audio_url"] = "https://mybucket.s3.amazonaws.com/song.mp3"
response = requests.post(url, headers=headers, data=data)

# Option 2: File Upload
# with open("song.mp3", "rb") as f:
#     files = {"audio_file": f}
#     response = requests.post(url, headers=headers, data=data, files=files)

# print(response.json())
{
  "success": true,
  "message": "Inpaint request submitted successfully",
  "task_id": "task-xyz-123",
  "conversion_id_1": "inpaint-abc",
  "conversion_id_2": "inpaint-def",
  "eta": 40,
  "credit_estimate": 45
}

Authorizations

Authorization
string
header
required

Body

multipart/form-data
audio_url
string
required

URL or S3 path to the input audio.

Example:

"https://mybucket.s3.amazonaws.com/song.mp3"

prompt
string
required

A description of how the replacement should sound.

Example:

"Replace this part with an opera-style vocal."

replace_start_at
number
required

Time in seconds to start replacing audio.

Example:

12.5

replace_end_at
number
required

Time in seconds to stop replacing audio.

Example:

20

audio_file
file

Uploaded input audio file.

lyrics
string

Lyrics to be used for inpainting.

Maximum length: 2000
Example:

"This is where my story begins"

gender
enum<string>

Voice style for the inpainted segment.

Available options:
male,
female,
neutral
Example:

"male"

webhook_url
string

Callback URL for async processing results.

Example:

"https://example.com/webhook"

Response

Successfully initiated inpaint task

success
boolean
message
string
task_id
string
conversion_id_1
string
conversion_id_2
string
eta
integer

Estimated processing time in seconds

credit_estimate
number