import requests
url = "https://api.musicgpt.com/api/public/v1/extend"
headers = {"Authorization": "<API_KEY>"}
data = {
"extend_after": 35.0,
"prompt": "Add a calming piano outro",
"lyrics": "Let the journey fade away",
"gender": "neutral",
"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": "Extend request submitted successfully",
"task_id": "task-extend-789",
"conversion_id_1": "extend-a1b2",
"conversion_id_2": "extend-c3d4",
"eta": 38,
"credit_estimate": 42
}
This endpoint allows users to extend an existing audio file or stream by appending new audio content after a specific timestamp. The new audio is generated using a prompt (e.g., describing the desired sound) and optional lyrics.
import requests
url = "https://api.musicgpt.com/api/public/v1/extend"
headers = {"Authorization": "<API_KEY>"}
data = {
"extend_after": 35.0,
"prompt": "Add a calming piano outro",
"lyrics": "Let the journey fade away",
"gender": "neutral",
"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": "Extend request submitted successfully",
"task_id": "task-extend-789",
"conversion_id_1": "extend-a1b2",
"conversion_id_2": "extend-c3d4",
"eta": 38,
"credit_estimate": 42
}
Successfully initiated extend task
The response is of type object
.