> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modelslab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MusicGen

> This endpoint is used to generate music based on textual prompts.

<Warning>
  Make sure you add your [s3 details](/enterprise-api/general/update-s3-details) for `voice_cloning` server, so you can receive image generated in your bucket. Images generated without s3 details being added will be delete after **24 hours**
</Warning>

## Request

Make a `POST` request to below endpoint and pass the required parameters as a request body.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v1/enterprise/voice/music_gen' \
```

## Body

```json json theme={null}
{    
  "key":"enterprise_api_key",    
  "prompt":"rock music from the 90s",   
  "init_audio":"https://youtu.be/7Nm6uTHbB-Y?si=ORk1LOQ8J34Z0Lpm",    
  "sampling_rate":32000,    
  "base64":false,
  "temp": false,    
  "webhook":null,    
  "track_id":null
}
```

## Body Attributes

<ParamField query="key" type="string" required>
  Your API Key used for request authorization.
</ParamField>

<ParamField query="prompt" type="string" required>
  The input text for audio generation.
</ParamField>

<ParamField query="init_audio" type="string">
  The conditioning melody for audio generation.
</ParamField>

<ParamField query="sampling_rate" type="integer" min="10000" default="32000">
  The sampling rate of the generated audio. Lower bound: 10000, Default: 32000. No strict upper bound.
</ParamField>

<ParamField query="max_new_token" type="integer" min="256" max="1024" default="512">
  The maximum number of new tokens for audio generation. Range: 256–1024.
</ParamField>

<ParamField query="base64" type="boolean" default="false">
  Whether the input sound clip is in base64 format. Default: false.
</ParamField>

<ParamField query="temp" type="boolean" default="false">
  Whether you want temporary links (useful if your country blocks access to storage sites). Default: false.
</ParamField>

<ParamField query="output_format" type="string" enum="[&#x22;wav&#x22;, &#x22;mp3&#x22;, &#x22;flac&#x22;]" default="wav">
  Allows you to specify the output format of the generated audio. Options: wav, mp3, flac. Default: wav.
</ParamField>

<ParamField query="bitrate" type="string" enum="[&#x22;128k&#x22;, &#x22;192k&#x22;, &#x22;320k&#x22;]" default="128k">
  The bitrate of the generated audio file. Higher bitrates improve quality but increase file size. Default: 128k.
</ParamField>

<ParamField query="webhook" type="string" format="url">
  Provide a URL to receive a POST API call once the audio generation is complete.
</ParamField>

<ParamField query="track_id" type="string">
  This ID is returned in the response to the webhook API call and will be used to identify the webhook request.
</ParamField>
