How to Generate Your First AI Music Track in Under 5 Minutes Using the MusicGPT API

Learn how to integrate a Music API into your app and generate AI powered music with Python. Follow this tutorial to get started with MusicGPT.

Jul 29, 2026
Want to integrate Music into your product but struggling with expensive licensing libraries??
Hiring professional songwriters and composers or building an AI music model from scratch can both be costly, but there is a solution for this problem: Using an existing Music AI API.
Whether you’re building a game, content creation platform, meditation app, or any product that relies on engaging audio experiences, integrating music can instantly enhance the user experience.
You can use a single API to handle your music generation work in minutes without having to build everything from scratch.
You’ll start by creating a MusicGPT API account, getting your API key, and start generating.

Prerequisites

To follow this tutorial, you'll need:
  • A MusicGPT API account.
  • An active API package.
  • Your MusicGPT API key.
  • Python 3.8 or later installed on your machine.
  • The request library (or your preferred HTTP client).
  • A basic understanding of REST APIs and making HTTP requests with Python.
notion image

Get your API keys

  • Log in to MusicGPT.
  • Go to the MusicGPT API Dashboard.
  • Enter your card details to activate API access. No charges will be deducted from your card during this step.
  • In your dashboard, navigate to the API Keys section.
  • Click Create API Key.
  • Once your account is ready and you have your keys, you can now generate your first song. As a new user, you can generate up to 10 songs for free.

Generate Your First Song with the MusicGPT API

Once you have your API key, replace <API_KEY> and <WEBHOOK_URL> in the example below with your own values.
import requests url = "https://api.musicgpt.com/api/public/v2/MusicAI" headers = {     "Authorization": "<YOUR_API_KEY>",     "Content-Type": "application/json" } payload = { "prompt": "Create a relaxing lo-fi song for studying",     "music_style": "Lo-fi",     "lyrics": "It's a brand new day",     "make_instrumental": False,     "vocal_only": False,     "voice_id": "e1cb7380-e3db-433a-b186-a996d7545986",     "title": "My Generated Track",     "gender": "female",     "generate_album_cover": False,     "model": "v7-pro",     "webhook_url": "<YOUR_WEBHOOK_URL>" } response = requests.post(url, headers=headers, json=payload) print(response.json())

See the Results

After submitting your request, you can retrieve the generated song in one of two ways:
Receive the result via a webhook (Recommended)
  • Provide a webhook_url in your request to automatically receive the completed result at your endpoint. Detail here.
Poll the Get By ID endpoint
  • Copy the task_id from the response.
  • Use Get By ID to fetch the result.

What’s Next?

You've successfully generated your first AI-powered music track using the MusicGPT API. But music generation is only one part of our platform; depending on your product, you can add other features like
  • Text to speech
  • Sound Generator
  • Extraction
  • Remix, Extend, Inpaint
  • Audio Enhancement Features and many more