POST
/
file_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())
{
  "success": true,
  "task_id": "convert789",
  "conversion_id": "conv456",
  "output_path": "https://storage.example.com/converted/audio.wav",
  "credit_estimate": 100.1
}

Authorizations

Authorization
string
header
required

Body

multipart/form-data
audio_url
string
required

URL of the audio file to convert

Example:

"https://example.com/audio.mp3"

target_format
enum<string>
required

Target format for conversion

Available options:
mp3,
wav,
flac,
ogg,
aac,
webm
Example:

"wav"

audio_file
file

Audio file to upload and convert directly

target_sr
enum<integer>
default:44100

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
enum<integer>

Target bit depth (16, 24, or 32)

Available options:
16,
24,
32
Example:

24

webhook_url
string

Callback URL for async processing results

Example:

"https://your-webhook-url.com/callback"

Response

Successfully initiated file conversion

success
boolean
task_id
string
conversion_id
string
output_path
string
credit_estimate
number