Skip to main content
POST
/
v1
/
sound_generator
Generate Sound Based on Given Prompt
curl --request POST \
  --url https://api.musicgpt.com/api/public/v1/sound_generator \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'prompt=Generate a soothing ambient soundscape.' \
  --data generate_album_cover=false \
  --data webhook_url=http://your-webhook-url.com/callback \
  --data audio_length=30
import requests

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

payload = {
"prompt": "Generate a soothing ambient soundscape.",
"generate_album_cover": "false",
"webhook_url": "http://your-webhook-url.com/callback",
"audio_length": "30"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/x-www-form-urlencoded"
}

response = requests.post(url, data=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
Authorization: '<api-key>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
prompt: 'Generate a soothing ambient soundscape.',
generate_album_cover: 'false',
webhook_url: 'http://your-webhook-url.com/callback',
audio_length: '30'
})
};

fetch('https://api.musicgpt.com/api/public/v1/sound_generator', 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/sound_generator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "prompt=Generate%20a%20soothing%20ambient%20soundscape.&generate_album_cover=false&webhook_url=http%3A%2F%2Fyour-webhook-url.com%2Fcallback&audio_length=30",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/x-www-form-urlencoded"
],
]);

$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/sound_generator"

payload := strings.NewReader("prompt=Generate%20a%20soothing%20ambient%20soundscape.&generate_album_cover=false&webhook_url=http%3A%2F%2Fyour-webhook-url.com%2Fcallback&audio_length=30")

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

req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

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/sound_generator")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("prompt=Generate%20a%20soothing%20ambient%20soundscape.&generate_album_cover=false&webhook_url=http%3A%2F%2Fyour-webhook-url.com%2Fcallback&audio_length=30")
.asString();
require 'uri'
require 'net/http'

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

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"] = 'application/x-www-form-urlencoded'
request.body = "prompt=Generate%20a%20soothing%20ambient%20soundscape.&generate_album_cover=false&webhook_url=http%3A%2F%2Fyour-webhook-url.com%2Fcallback&audio_length=30"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "task_id": "soundgen789",
  "conversion_id": "conv456",
  "eta": -1,
  "credit_estimate": 100.1,
  "message": "Successfully published to queue"
}
{
"success": false,
"error": "Prompt is required for sound generation."
}
{
"success": false,
"error": "Internal Server Error"
}

Authorizations

Authorization
string
header
required

Body

application/x-www-form-urlencoded
prompt
string
required

Text prompt guiding the sound generation.

Example:

"Generate a soothing ambient soundscape."

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:

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

audio_length
integer

Desired duration of generated audio in seconds (beta feature)

Example:

30

Response

Successfully initiated sound generation

success
boolean
task_id
string
conversion_id
string
eta
integer
credit_estimate
number<float>
message
string