Python
import requests
url = "https://api.musicgpt.com/api/public/v1/file_convert"
headers = {
"Authorization": "<API_KEY>"
}
data = {
"target_format": "wav",
"target_sr": 44100,
"webhook_url": "https://example.com/my-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/file_convert \
--header 'Authorization: <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form audio_url=https://example.com/audio.mp3 \
--form target_format=wav \
--form 'audio_file=<string>' \
--form target_sr=44100 \
--form target_bit_depth=24 \
--form webhook_url=https://your-webhook-url.com/callback \
--form 0.audio_file='@example-file' \
--form 1.audio_file='@example-file'const form = new FormData();
form.append('audio_url', 'https://example.com/audio.mp3');
form.append('target_format', 'wav');
form.append('audio_file', '<string>');
form.append('target_sr', '44100');
form.append('target_bit_depth', '24');
form.append('webhook_url', 'https://your-webhook-url.com/callback');
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/file_convert', 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/file_convert",
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://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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/file_convert"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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/file_convert")
.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://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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/file_convert")
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://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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,
"task_id": "convert789",
"conversion_id": "conv456",
"output_path": "https://storage.example.com/converted/audio.wav",
"credit_estimate": 100.1
}{
"success": false,
"error": "Either audio_url or audio_file must be provided"
}{
"success": false,
"error": "Internal Server Error"
}Features
File Conversion
Initiate a file conversion task using either an audio URL or file upload with optional format parameters and webhook callback.
POST
/
v1
/
file_convert
Python
import requests
url = "https://api.musicgpt.com/api/public/v1/file_convert"
headers = {
"Authorization": "<API_KEY>"
}
data = {
"target_format": "wav",
"target_sr": 44100,
"webhook_url": "https://example.com/my-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/file_convert \
--header 'Authorization: <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form audio_url=https://example.com/audio.mp3 \
--form target_format=wav \
--form 'audio_file=<string>' \
--form target_sr=44100 \
--form target_bit_depth=24 \
--form webhook_url=https://your-webhook-url.com/callback \
--form 0.audio_file='@example-file' \
--form 1.audio_file='@example-file'const form = new FormData();
form.append('audio_url', 'https://example.com/audio.mp3');
form.append('target_format', 'wav');
form.append('audio_file', '<string>');
form.append('target_sr', '44100');
form.append('target_bit_depth', '24');
form.append('webhook_url', 'https://your-webhook-url.com/callback');
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/file_convert', 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/file_convert",
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://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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/file_convert"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio_url\"\r\n\r\nhttps://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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/file_convert")
.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://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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/file_convert")
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://example.com/audio.mp3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_format\"\r\n\r\nwav\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=\"target_sr\"\r\n\r\n44100\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"target_bit_depth\"\r\n\r\n24\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webhook_url\"\r\n\r\nhttps://your-webhook-url.com/callback\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,
"task_id": "convert789",
"conversion_id": "conv456",
"output_path": "https://storage.example.com/converted/audio.wav",
"credit_estimate": 100.1
}{
"success": false,
"error": "Either audio_url or audio_file must be provided"
}{
"success": false,
"error": "Internal Server Error"
}Convert audio files to different formats with optional webhook support for asynchronous updates.
This endpoint processes an uploaded or linked audio file and converts it to a specified output format. You may also define optional parameters like sample rate and bit depth.
Endpoint
POST /v1/file_convert
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
audio_url | String | Optional | The URL of an audio file to convert. Either audio_url or audio_file must be provided. |
audio_file | UploadFile | Optional | Upload the audio file directly. Either audio_url or audio_file must be provided. |
target_format | String | Yes | Desired output format. Supported: mp3, wav, flac, ogg, aac, webm. |
target_sr | Integer | Optional | Target sample rate in Hz. Defaults to original if not specified. |
target_bit_depth | Integer | Optional | Target bit depth. Options: 16, 24, 32. Defaults to 16. |
webhook_url | String | Optional | Callback URL to receive the result once conversion is complete. |
content-type: multipart/form-data
Sample Output
Listen to a real sample output: Download AudioTry it Yourself
Visit the File Conversion Endpoint Explorer to try your own text samples.
💡 Tip: Set a webhook_url to receive results automatically when your audio is ready.
Sample Request
cURL
curl -X POST \
-F "audio_file=@input.mp3" \
-F "target_format=wav" \
-F "target_sr=44100" \
-F "webhook_url=https://yourdomain.com/webhook" \
https://api.musicgpt.com/api/public/v1/convert
Python
import requests
url = "https://api.musicgpt.com/api/public/v1/file_convert"
headers = {
"Authorization": "<<<api key>>>"
}
# Option 1: URL
payload = {
"audio_url": "https://example.com/audio.mp3",
"target_format": "wav",
"target_sr": 44100,
"webhook_url": "https://your-webhook-url.com/callback"
}
response = requests.post(url, headers=headers, data=payload)
print(response.json())
# Option 2: File Upload
# payload = {
# "target_format": "flac",
# "target_bit_depth": 24,
# "webhook_url": "https://your-webhook-url.com/callback"
# }
# with open("audio.mp3", "rb") as f:
# files = {"audio_file": f}
# response = requests.post(url, headers=headers, data=payload, files=files)
# print(response.json())
🔐 Replace{path_to_your_audio_file},api_key, andwebhook_urlbefore executing.
Sample Response
Success (200 OK)
{
"success":true,
"task_id":"7024eac0-02e2-4811-96e3-7031f007f97f",
"conversion_id":"a1286a84-d886-47d9-a717-77af15894cb9",
"eta":-1,
"credit_estimate":19.833,
"message":"",
"status":"IN_QUEUE"
}
Webhook Response
Success (200 OK)
{
"success": true,
"conversion_id": "a1286a84-d886-47d9-a717-77af15894cb9",
"output_file_path": "https://lalals.s3.us-east-1.amazonaws.com/FileConversions/059ab1ef-c92d-4be4-b2f3-4fe57d26ae87.mp3",
"conversion_type": "File Conversion",
"task_id": "7024eac0-02e2-4811-96e3-7031f007f97f"
}
Common Errors
- 400 Bad Request: Invalid request. Possibly due to missing parameters or unsupported formats.
- 500 Internal Server Error: Server encountered an error during processing.
Webhook Response
Once the file conversion is completed, the webhook receives:{
"success": true,
"conversion_id": "teststagetestapril26",
"output_file_path": "https://musicgpt.s3.amazonaws.com/conversions/123abc-denoise_no_noise.mp3",
"conversion_type": "File Conversion"
}
Output Fields
output_file_path: Direct URL to download the converted audio file.conversion_type: AlwaysFile Conversionfor this endpoint.conversion_id: A unique ID to track the request status.
Authorizations
Body
multipart/form-data
- Option 1
- Option 2
Input audio URL (supported format: YouTube URL).
Example:
"https://example.com/audio.mp3"
Target format for conversion
Available options:
mp3, wav, flac, ogg, aac, webm Example:
"wav"
Audio file to upload and convert directly
Target sample rate in Hz (optional) - can be any of [8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 192000]
Available options:
8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 192000 Example:
44100
Target bit depth (16, 24, or 32)
Available options:
16, 24, 32 Example:
24
Callback URL for async processing results
Example:
"https://your-webhook-url.com/callback"
⌘I