Music Generation

Music Generation with Suno v3.5

Last Modifiy Date: 2024-09-05

Key Features

  • High-Quality Music Generation: Create music tracks based on descriptive prompts.
  • Flexible Integration: Compatible with various programming languages and frameworks.

Generate Music

Endpoint: POST /api/generate
Description: Generate music based on a given text prompt using the Suno v3.5 model. Available models include chirp-v3-5 and chirp-v3-0. This endpoint will automatically fill in the lyrics.

curl
curl -X POST "https://udioapi.pro/api/generate" \
   -H "Content-Type: application/json" \
   -d '{
        "title": "",
        "prompt": "",
        "gpt_description_prompt":"",
        "custom_mode":false,
        "make_instrumental": false,
        "model": "chirp-v3.0",
        "callback_url":"",
        "disable_callback": false,
        "token":"{{ your token }}"
    }'
nodejs
const fetch = require('node-fetch');

const postData = {
  title: '',
  prompt: '',
  gpt_description_prompt: '',
  custom_mode: false,
  make_instrumental: false,
  model: 'chirp-v3.0',
  callback_url: '',
  disable_callback: false,
  token: '{{ your token }}'
};

fetch('https://udioapi.pro/api/generate', {
  method: 'POST',
  headers: {
      'Content-Type': 'application/json',
  },
  body: JSON.stringify(postData)
})
  .then(response => response.json())
  .then(data => {
      console.log('Success:', data);
  })
  .catch((error) => {
      console.error('Error:', error);
  });
python
import requests
import json

# Define the URL and the payload
url = "https://udioapi.pro/api/generate"
payload = {
  "title": "",
  "prompt": "",
  "gpt_description_prompt": "",
  "custom_mode": False,
  "make_instrumental": False,
  "model": "chirp-v3.0",
  "callback_url": "",
  "disable_callback": False,
  "token": "{{ your api_key }}"
}

# Define the headers
headers = {
  "Content-Type": "application/json"
}

# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))

# Check if the request was successful
if response.status_code == 200:
  print("Success!")
  # Print the response body
  print(response.text)
else:
  print("Failed to send request. Status code:", response.status_code)

# You can also handle exceptions and errors as needed

  • title: Music title
  • prompt: generate music prompt, If the content is too long, the generation will fail with "Topic too long."
  • gpt_description_prompt: Can input music style, If the content is too long, the generation will fail with "Topic too long."
  • custom_mode: This parameter exists only in the suno-v3 model.
  • make_instrumental: false,
  • model: Options include chirp-v3.0, chirp-v3.5, udio-130, udio-32,
    1. udio-130: Generate 2:10 clips. Takes longer
    2. udio-32: Generate 32s clips
  • callback_url : Optional field, but it is recommended to use your own address due to potential delays with our forwarding
  • disable_callback : The default value of disable_callback is false. If you do not provide the callback_url parameter and set disable_callback to true, we will store your generated results on our server, but this data will be retained for a maximum of 30 days.
  • token: your api_key Required field

Custom Mode: If you want to use customMode, make sure the following parameters exist.

customModeinstrumentalRequired Parameters
truefalsestyle, prompt, title
truetruestyle, title
falsetrueprompt
falsefalseprompt

Submit Generation Task Response

{
  message: 'success',
  workId: 'workId'
}

  • workId: Fields used to query generate results

Generate Callback Sample


{
  "code": 200,
  "data": {
    "callbackType": "complete",
    "data": [
      {
        "audio_url": "https://xxx.mp3",
        "createTime": 1717587606036,
        "duration": 146.08,
        "id": "59001af3-845d-47af-9e23-625adb0c6505",
        "image_url": "https://xxx.png",
        "model_name": "chirp-v3.5",
        "prompt": "[Verse]xxx[Verse 2]xxx[Chorus]xxx[Verse 3]xxx[Bridge]xxx[Chorus]xxx",
        "tags": "melodic pop piano",
        "title": "xxx"
      },
      {
        "audio_url": "https://xxx.mp3",
        "createTime": 1717587606036,
        "duration": 240,
        "id": "b0fa4b03-89d2-4c6d-82ea-28aa2604fee6",
        "image_url": "https://xxx.png",
        "model_name": "chirp-v3.5",
        "prompt": "[Verse]xxx[Verse 2]xxx[Chorus]xxx[Verse 3]xxx[Bridge]xxx[Chorus]xxx",
        "tags": "melodic pop piano",
        "title": "xxx"
      }
    ]
  },
  "msg": "All generated successfully."
}
Dashboard

About CallBack Url

Once the cover, title, and lyrics are successfully generated, we will make a callback to the "callback URL" you provided in the generation interface. Please note that the generated files will only be retained for 30 days.

Note: In some cases, the official website may skip the 'text' and 'first' stages and directly mark the task as 'complete'. Be aware of this possibility.

The callback method will be "POST", and the "Content-Type" should be set to "application/json".