Skip to main content
POST
/
v1
/
extend
Python
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", 
  "lyrics_section_to_extend": "New_lyrics",
  "num_outputs": 1,
  "title": "My Generated Track",
  "webhook_url": "https://example.com/webhook"
}

# Option 1: audio_url
data["audio_url"] = "<YOUR_AUDIO_URL>"
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())
curl --request POST \
  --url https://api.musicgpt.com/api/public/v1/extend \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: multipart/form-data' \
  --form audio_url=https://mybucket.s3.amazonaws.com/song.mp3 \
  --form extend_after=35 \
  --form 'audio_file=<string>' \
  --form 'prompt=Add a calming piano outro' \
  --form 'lyrics=Let the journey fade away' \
  --form 'lyrics_section_to_extend=<string>' \
  --form gender=neutral \
  --form 'title=<string>' \
  --form num_outputs=123 \
  --form generate_album_cover=false \
  --form webhook_url=https://example.com/webhook \
  --form 0.audio_file='@example-file' \
  --form 1.audio_file='@example-file'
const form = new FormData();
form.append('audio_url', 'https://mybucket.s3.amazonaws.com/song.mp3');
form.append('extend_after', '35');
form.append('audio_file', '<string>');
form.append('prompt', 'Add a calming piano outro');
form.append('lyrics', 'Let the journey fade away');
form.append('lyrics_section_to_extend', '<string>');
form.append('gender', 'neutral');
form.append('title', '<string>');
form.append('num_outputs', '123');
form.append('generate_album_cover', 'false');
form.append('webhook_url', 'https://example.com/webhook');
form.append('0.audio_file', '{
  "fileName": "example-file"
}');
form.append('1.audio_file', '{
  "fileName": "example-file"
}');

const options = {method: 'POST', headers: {Authorization: '<api-key>'}};

options.body = form;

fetch('https://api.musicgpt.com/api/public/v1/extend', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.musicgpt.com/api/public/v1/extend",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://mybucket.s3.amazonaws.com/song.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extend_after\"\r\n\r\n35\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nAdd a calming piano outro\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics\"\r\n\r\nLet the journey fade away\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics_section_to_extend\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nneutral\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"num_outputs\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"generate_album_cover\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://example.com/webhook\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
  CURLOPT_HTTPHEADER => [
    "Authorization: <api-key>",
    "Content-Type: multipart/form-data; boundary=---011000010111000001101001"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.musicgpt.com/api/public/v1/extend"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://mybucket.s3.amazonaws.com/song.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extend_after\"\r\n\r\n35\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nAdd a calming piano outro\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics\"\r\n\r\nLet the journey fade away\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics_section_to_extend\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nneutral\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"num_outputs\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"generate_album_cover\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://example.com/webhook\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<api-key>")
	req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.musicgpt.com/api/public/v1/extend")
  .header("Authorization", "<api-key>")
  .header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://mybucket.s3.amazonaws.com/song.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extend_after\"\r\n\r\n35\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nAdd a calming piano outro\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics\"\r\n\r\nLet the journey fade away\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics_section_to_extend\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nneutral\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"num_outputs\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"generate_album_cover\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://example.com/webhook\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.musicgpt.com/api/public/v1/extend")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://mybucket.s3.amazonaws.com/song.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"extend_after\"\r\n\r\n35\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nAdd a calming piano outro\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics\"\r\n\r\nLet the journey fade away\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"lyrics_section_to_extend\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nneutral\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"num_outputs\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"generate_album_cover\"\r\n\r\nfalse\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://example.com/webhook\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"0.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"1.audio_file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "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
}
{
  "success": false,
  "error": "audio_file or audio_url and extend_after are required."
}
{
  "success": false,
  "error": "Internal Server Error"
}
Extend an existing audio file by generating new content after a specific timestamp.

Endpoint

POST /v1/extend
This endpoint allows users to extend an existing audio file or stream by appending new audio content after a specific timestamp. The new content is generated using a prompt and optional lyrics.

Request Parameters

ParameterTypeRequiredDescription
audio_fileUploadFileOptionalUpload the audio file to extend. Required if audio_url is not provided.
audio_urlStringOptionalPublic or S3 URL to the input audio. Required if audio_file is not provided.
extend_afterFloatRequiredTime (in seconds) after which new audio is generated.
promptStringOptionalDescribes the desired extension sound. Example: “Add a melodic flute section”
titleStringOptionalTitle of the generated music
lyricsStringOptionalOriginal lyrics of song. Max 2000 characters.
lyrics_section_to_extendStringOptionalOptional lyrics for the extended segment. Max 3000 characters.
genderStringOptionalVoice style if vocals are generated. Must be one of male, female, neutral.
num_outputsintOptionalThe number of outputs to generate (1 or 2 only, default : 2).
webhook_urlStringOptionalCallback URL for async result delivery.
💡 Note: You must provide either audio_file or audio_url — at least one is required.
content-type: multipart/form-data

Sample Output

Listen to the extended audio. Prompt: loud drums sound - audio input : Rose and Bruno Mars - APT extend after: 6 Download Audio

Try it Yourself

Visit the Extend Endpoint Explorer to play around — set your payload, hit send, and listen to the generated results live.

Sample Request

cURL

curl -X POST "https://api.musicgpt.com/api/public/v1/extend" \
-H "accept: application/json" \
-H "Authorization: <api_key>" \
-F "audio_file=@/path/to/audio.mp3" \
-F "extend_after=35.0" \
-F "prompt=Add a calming piano outro" \
-F "lyrics=Let the journey fade away" \
-F "gender=neutral" \
-F "webhook_url=https://example.com/webhook"

Python

import requests

url = "https://api.musicgpt.com/api/public/v1/extend"
headers = {"Authorization": "<API_KEY>"}
data = {
  "prompt": "Add a calming piano outro",
  "lyrics": "Let the journey fade away",
  "extend_after": 35.0,
  "gender": "neutral",
  "webhook_url": "https://example.com/webhook"
}

# Option 1: audio_url
files = {}
data["audio_url"] = "https://lalals.s3.amazonaws.com/audio/example.mp3"
response = requests.post(url, headers=headers, data=data, files=files)

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

# print(response.json())
🔐 Replace {path_to_your_audio_file}, api_key, and webhook_url before executing.

Sample Response

Success (200 OK)

{
  "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
}

Webhook Response

When the extension process completes, the webhook receives:
{
  "success": true,
  "conversion_type": "Extend",
  "task_id": "task-extend-789",
  "conversion_id": "extend-a1b2",
  "conversion_path": "https://lalals.s3.amazonaws.com/conversions/extend-a1b2.mp3",
  "conversion_path_wav": "https://lalals.s3.amazonaws.com/conversions/extend-a1b2.wav",
  "conversion_duration": 192.12,
  "is_flagged": false,
  "reason": "",
  "lyrics": "Let the journey fade away",
  "lyrics_timestamped": [],
  "title": "Outro Symphony"
}

Webhook Delivery

Once the generation is complete, webhooks will be triggered to deliver the following:

Standard Requests (non-instrumental):

  • 2 (webhooks) x Extend conversion details (one per version)
  • 2 (webhooks) x Lyrics with timestamp data
  • 1 Album Cover Image
Webhook responses include detailed metadata including task_id, conversion_id, audio files (conversion_path), lyrics etc.

Common Errors

  • 422 Unprocessable Entity: Missing required fields like extend_after, or neither audio_file nor audio_url provided.
  • 500 Internal Server Error: An unexpected error occurred during processing.

The response provides a downloadable or streamable extended audio file.

Authorizations

Authorization
string
header
required

Body

multipart/form-data
audio_url
string
required

Input audio URL (supported format: YouTube URL).

Example:

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

extend_after
number<float>
required

Time in seconds after which to start the extension.

Example:

35

audio_file
file

Uploaded audio file to be extended.

prompt
string

Describes how the extended section should sound.

Example:

"Add a calming piano outro"

lyrics
string

Original lyrics of song

Maximum string length: 2000
Example:

"Let the journey fade away"

lyrics_section_to_extend
string

Lyrics to be used for the extended portion(optional, max 3000 characters).

Maximum string length: 3000
gender
enum<string>

Voice style if vocal content is generated.

Available options:
male,
female,
neutral
Example:

"neutral"

title
string

Title of the generated music track

num_outputs
number<integer>

The number of outputs to generate (1 or 2 only):default is 2.

generate_album_cover
boolean
default:false

Whether to generate an album cover for the generated audio

webhook_url
string

Callback URL for async processing results.

Example:

"https://example.com/webhook"

Response

Successfully initiated extend 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<float>