POST
/
audio_mastering
Python
import requests

url = "https://api.musicgpt.com/api/public/v1/audio_mastering"
headers = {"Authorization": "<<<api key>>>"}

# Option 1: Using URLs
payload = {
    "audio_url": "https://example.com/input_audio.mp3",
    "reference_audio_url": "https://example.com/reference_track.wav",
    "output_extension": "wav",
    "webhook_url": "http://your-webhook-url.com/callback"
}
response = requests.post(url, headers=headers, data=payload)
print(response.json())

# Option 2: Upload files
# with open("input.mp3", "rb") as input_file, open("ref.wav", "rb") as ref_file:
#     files = {
#         "audio_file": input_file,
#         "reference_audio_file": ref_file
#     }
#     data = {
#         "output_extension": "wav",
#         "webhook_url": "http://your-webhook-url.com/callback"
#     }
#     response = requests.post(url, headers=headers, files=files, data=data)
#     print(response.json())
{
  "success": true,
  "task_id": "master123",
  "conversion_id": "conv456",
  "credit_estimate": 150.75,
  "eta": 300,
  "message": "Mastering task queued successfully"
}

Master your audio files professionally using a reference track.

Audio Mastering uses intelligent processing to match the sonic quality of your track to a reference file — perfect for music production, podcasts, and post-production work.

  • šŸŽ›ļø Match tone, loudness, and clarity
  • šŸŽµ Supports formats like MP3, WAV, FLAC, and more
  • šŸš€ Quick, accurate mastering with webhook support

Endpoint

POST /audio_mastering

Use this endpoint to master an audio file based on a reference track.


Sample Output

Listen to the mastered audio:


Try it Yourself

Visit the Audio Mastering Endpoint Explorer to upload an audio and reference track for instant mastering.

Tip: Use a professionally mastered song as your reference for best results!


Request Parameters

ParameterTypeRequiredDescription
audio_pathStringYesURL path of the input audio file to be mastered
conversion_idStringYesUnique identifier for this conversion request
reference_audio_pathStringYesURL path of the reference audio file to match
output_extensionStringOptionalDesired output format (mp3, wav, flac, ogg, aac, webm)
audio_durationFloatYesDuration of input audio in seconds (for credit calculation)
webhook_urlStringOptionalURL to receive callback notification when processing completes
user_idStringOptionalUser ID for tracking (from authentication token)

Sample Request

Python

import requests

url = "https://api.musicgpt.com/api/public/v1/audio_mastering"
headers = {"Authorization": "<<<api key>>>"}

# Option 1: Using URLs
payload = {
    "audio_url": "https://example.com/input_audio.mp3",
    "reference_audio_url": "https://example.com/reference_track.wav",
    "output_extension": "wav",
    "webhook_url": "http://your-webhook-url.com/callback"
}
response = requests.post(url, headers=headers, data=payload)
print(response.json())

# Option 2: Upload files
# with open("input.mp3", "rb") as input_file, open("ref.wav", "rb") as ref_file:
#     files = {
#         "audio_file": input_file,
#         "reference_audio_file": ref_file
#     }
#     data = {
#         "output_extension": "wav",
#         "webhook_url": "http://your-webhook-url.com/callback"
#     }
#     response = requests.post(url, headers=headers, files=files, data=data)
#     print(response.json())

Sample Response

Success (200 OK)

{
  "success": true,
  "task_id": "0d12ef34-5678-4abc-9123-456def7890ab",
  "conversion_id": "user_master_12345",
  "credit_estimate": 0.02,
  "eta": 120,
  "message": "Mastering request accepted"
}

Webhook Response

If a webhook_url is provided, you will receive the following once processing completes:

{
  "success": true,
  "task_id": "0d12ef34-5678-4abc-9123-456def7890ab",
  "conversion_id": "user_master_12345",
  "conversion_path": "https://musicgpt.s3.us-east-1.amazonaws.com/conversions/sample-mastered.mp3",
  "credit_cost": 0.02
}

šŸ“‚ If no webhook is provided, you can fetch the final mastered audio manually later using the conversion_id.


Payload and Request Formation

Authorizations

Authorization
string
header
required

Body

multipart/form-data

Response

200
application/json

Successfully queued for mastering

The response is of type object.