curl --request POST \
--url https://api.minimax.io/v1/music_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "music-3.0",
"prompt": "Indie folk, melancholic, introspective, longing, solitary walk, coffee shop",
"lyrics": "[verse]\nStreetlights flicker, the night breeze sighs\nShadows stretch as I walk alone\nAn old coat wraps my silent sorrow\nWandering, longing, where should I go\n[chorus]\nPushing the wooden door, the aroma spreads\nIn a familiar corner, a stranger gazes",
"audio_setting": {
"sample_rate": 44100,
"bitrate": 256000,
"format": "mp3"
}
}
'import requests
url = "https://api.minimax.io/v1/music_generation"
payload = {
"model": "music-3.0",
"prompt": "Indie folk, melancholic, introspective, longing, solitary walk, coffee shop",
"lyrics": "[verse]
Streetlights flicker, the night breeze sighs
Shadows stretch as I walk alone
An old coat wraps my silent sorrow
Wandering, longing, where should I go
[chorus]
Pushing the wooden door, the aroma spreads
In a familiar corner, a stranger gazes",
"audio_setting": {
"sample_rate": 44100,
"bitrate": 256000,
"format": "mp3"
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
model: 'music-3.0',
prompt: 'Indie folk, melancholic, introspective, longing, solitary walk, coffee shop',
lyrics: '[verse]\nStreetlights flicker, the night breeze sighs\nShadows stretch as I walk alone\nAn old coat wraps my silent sorrow\nWandering, longing, where should I go\n[chorus]\nPushing the wooden door, the aroma spreads\nIn a familiar corner, a stranger gazes',
audio_setting: {sample_rate: 44100, bitrate: 256000, format: 'mp3'}
})
};
fetch('https://api.minimax.io/v1/music_generation', 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.minimax.io/v1/music_generation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'music-3.0',
'prompt' => 'Indie folk, melancholic, introspective, longing, solitary walk, coffee shop',
'lyrics' => '[verse]
Streetlights flicker, the night breeze sighs
Shadows stretch as I walk alone
An old coat wraps my silent sorrow
Wandering, longing, where should I go
[chorus]
Pushing the wooden door, the aroma spreads
In a familiar corner, a stranger gazes',
'audio_setting' => [
'sample_rate' => 44100,
'bitrate' => 256000,
'format' => 'mp3'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);
$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.minimax.io/v1/music_generation"
payload := strings.NewReader("{\n \"model\": \"music-3.0\",\n \"prompt\": \"Indie folk, melancholic, introspective, longing, solitary walk, coffee shop\",\n \"lyrics\": \"[verse]\\nStreetlights flicker, the night breeze sighs\\nShadows stretch as I walk alone\\nAn old coat wraps my silent sorrow\\nWandering, longing, where should I go\\n[chorus]\\nPushing the wooden door, the aroma spreads\\nIn a familiar corner, a stranger gazes\",\n \"audio_setting\": {\n \"sample_rate\": 44100,\n \"bitrate\": 256000,\n \"format\": \"mp3\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")
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.minimax.io/v1/music_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"model\": \"music-3.0\",\n \"prompt\": \"Indie folk, melancholic, introspective, longing, solitary walk, coffee shop\",\n \"lyrics\": \"[verse]\\nStreetlights flicker, the night breeze sighs\\nShadows stretch as I walk alone\\nAn old coat wraps my silent sorrow\\nWandering, longing, where should I go\\n[chorus]\\nPushing the wooden door, the aroma spreads\\nIn a familiar corner, a stranger gazes\",\n \"audio_setting\": {\n \"sample_rate\": 44100,\n \"bitrate\": 256000,\n \"format\": \"mp3\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.minimax.io/v1/music_generation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"model\": \"music-3.0\",\n \"prompt\": \"Indie folk, melancholic, introspective, longing, solitary walk, coffee shop\",\n \"lyrics\": \"[verse]\\nStreetlights flicker, the night breeze sighs\\nShadows stretch as I walk alone\\nAn old coat wraps my silent sorrow\\nWandering, longing, where should I go\\n[chorus]\\nPushing the wooden door, the aroma spreads\\nIn a familiar corner, a stranger gazes\",\n \"audio_setting\": {\n \"sample_rate\": 44100,\n \"bitrate\": 256000,\n \"format\": \"mp3\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"audio": "hex-encoded audio data",
"status": 2
},
"trace_id": "04ede0ab069fb1ba8be5156a24b1e081",
"extra_info": {
"music_duration": 25364,
"music_sample_rate": 44100,
"music_channel": 2,
"bitrate": 256000,
"music_size": 813651
},
"analysis_info": null,
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}Music Generation
Use this API to generate a song from lyrics and a prompt.
curl --request POST \
--url https://api.minimax.io/v1/music_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "music-3.0",
"prompt": "Indie folk, melancholic, introspective, longing, solitary walk, coffee shop",
"lyrics": "[verse]\nStreetlights flicker, the night breeze sighs\nShadows stretch as I walk alone\nAn old coat wraps my silent sorrow\nWandering, longing, where should I go\n[chorus]\nPushing the wooden door, the aroma spreads\nIn a familiar corner, a stranger gazes",
"audio_setting": {
"sample_rate": 44100,
"bitrate": 256000,
"format": "mp3"
}
}
'import requests
url = "https://api.minimax.io/v1/music_generation"
payload = {
"model": "music-3.0",
"prompt": "Indie folk, melancholic, introspective, longing, solitary walk, coffee shop",
"lyrics": "[verse]
Streetlights flicker, the night breeze sighs
Shadows stretch as I walk alone
An old coat wraps my silent sorrow
Wandering, longing, where should I go
[chorus]
Pushing the wooden door, the aroma spreads
In a familiar corner, a stranger gazes",
"audio_setting": {
"sample_rate": 44100,
"bitrate": 256000,
"format": "mp3"
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
model: 'music-3.0',
prompt: 'Indie folk, melancholic, introspective, longing, solitary walk, coffee shop',
lyrics: '[verse]\nStreetlights flicker, the night breeze sighs\nShadows stretch as I walk alone\nAn old coat wraps my silent sorrow\nWandering, longing, where should I go\n[chorus]\nPushing the wooden door, the aroma spreads\nIn a familiar corner, a stranger gazes',
audio_setting: {sample_rate: 44100, bitrate: 256000, format: 'mp3'}
})
};
fetch('https://api.minimax.io/v1/music_generation', 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.minimax.io/v1/music_generation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'music-3.0',
'prompt' => 'Indie folk, melancholic, introspective, longing, solitary walk, coffee shop',
'lyrics' => '[verse]
Streetlights flicker, the night breeze sighs
Shadows stretch as I walk alone
An old coat wraps my silent sorrow
Wandering, longing, where should I go
[chorus]
Pushing the wooden door, the aroma spreads
In a familiar corner, a stranger gazes',
'audio_setting' => [
'sample_rate' => 44100,
'bitrate' => 256000,
'format' => 'mp3'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);
$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.minimax.io/v1/music_generation"
payload := strings.NewReader("{\n \"model\": \"music-3.0\",\n \"prompt\": \"Indie folk, melancholic, introspective, longing, solitary walk, coffee shop\",\n \"lyrics\": \"[verse]\\nStreetlights flicker, the night breeze sighs\\nShadows stretch as I walk alone\\nAn old coat wraps my silent sorrow\\nWandering, longing, where should I go\\n[chorus]\\nPushing the wooden door, the aroma spreads\\nIn a familiar corner, a stranger gazes\",\n \"audio_setting\": {\n \"sample_rate\": 44100,\n \"bitrate\": 256000,\n \"format\": \"mp3\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")
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.minimax.io/v1/music_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"model\": \"music-3.0\",\n \"prompt\": \"Indie folk, melancholic, introspective, longing, solitary walk, coffee shop\",\n \"lyrics\": \"[verse]\\nStreetlights flicker, the night breeze sighs\\nShadows stretch as I walk alone\\nAn old coat wraps my silent sorrow\\nWandering, longing, where should I go\\n[chorus]\\nPushing the wooden door, the aroma spreads\\nIn a familiar corner, a stranger gazes\",\n \"audio_setting\": {\n \"sample_rate\": 44100,\n \"bitrate\": 256000,\n \"format\": \"mp3\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.minimax.io/v1/music_generation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"model\": \"music-3.0\",\n \"prompt\": \"Indie folk, melancholic, introspective, longing, solitary walk, coffee shop\",\n \"lyrics\": \"[verse]\\nStreetlights flicker, the night breeze sighs\\nShadows stretch as I walk alone\\nAn old coat wraps my silent sorrow\\nWandering, longing, where should I go\\n[chorus]\\nPushing the wooden door, the aroma spreads\\nIn a familiar corner, a stranger gazes\",\n \"audio_setting\": {\n \"sample_rate\": 44100,\n \"bitrate\": 256000,\n \"format\": \"mp3\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"audio": "hex-encoded audio data",
"status": 2
},
"trace_id": "04ede0ab069fb1ba8be5156a24b1e081",
"extra_info": {
"music_duration": 25364,
"music_sample_rate": 44100,
"music_channel": 2,
"bitrate": 256000,
"music_size": 813651
},
"analysis_info": null,
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}Authorizations
HTTP: Bearer Auth
- Security Scheme Type: http
- HTTP Authorization Scheme:
Bearer API_key, can be found in Account Management>API Keys.
Headers
Body
The model name. Options:
music-3.0(recommended): Text-to-music generation. Rate limit: 120 RPM.music-2.6: Previous-generation text-to-music model. Rate limit: 120 RPM.music-cover: Cover generation from a reference audio. Rate limit: 120 RPM.music-3.0-free: Free-tier version ofmusic-3.0. Rate limit: 3 RPM.music-2.6-free: Free-tier version ofmusic-2.6. Rate limit: 3 RPM.music-cover-free: Free-tier version ofmusic-cover. Rate limit: 3 RPM.
music-3.0, music-2.6, music-cover, music-3.0-free, music-2.6-free, music-cover-free A description of the music, specifying style, mood, and scenario.
For example: "Pop, melancholic, perfect for a rainy night".
Note:
- For
music-3.0/music-3.0-free/music-2.6/music-2.6-freewithis_instrumental: true: Required. Length: 1–2000 characters. - For
music-3.0/music-3.0-free/music-2.6/music-2.6-free(non-instrumental): Optional. Length: 0–2000 characters. - For
music-cover/music-cover-free: Required. Describes the target cover style. Length: 10–300 characters.
2000Song lyrics, using \n to separate lines. Supports structure tags: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo].
Note:
- For
music-3.0/music-3.0-free/music-2.6/music-2.6-freewithis_instrumental: true: Not required. - For
music-3.0/music-3.0-free/music-2.6/music-2.6-free(non-instrumental): Required. Length: 1–3500 characters. - For
music-cover/music-cover-free: Optional. If omitted, lyrics are automatically extracted from the reference audio via ASR. Length: 10–1000 characters. - When
lyrics_optimizer: trueandlyricsis empty, the system will auto-generate lyrics fromprompt.
1 - 3500Whether to automatically generate lyrics based on the prompt description. Only supported on music-3.0 / music-3.0-free / music-2.6 / music-2.6-free.
When set to true and lyrics is empty, the system will automatically generate lyrics from the prompt. Default: false.
URL of the reference audio. Only used with music-cover / music-cover-free model. Exactly one of audio_url or audio_base64 must be provided. Mutually exclusive with cover_feature_id.
Reference audio constraints:
- Duration: 6 seconds to 6 minutes
- Size: max 50 MB
- Format: common audio formats (mp3, wav, flac, etc.)
Base64-encoded reference audio. Only used with music-cover / music-cover-free model. Exactly one of audio_url or audio_base64 must be provided. Mutually exclusive with cover_feature_id.
Reference audio constraints:
- Duration: 6 seconds to 6 minutes
- Size: max 50 MB
- Format: common audio formats (mp3, wav, flac, etc.)
Feature ID returned by the Music Cover Preprocess API. Used in the two-step cover workflow to generate a cover with modified lyrics.
Only used with music-cover / music-cover-free model. Mutually exclusive with audio_url and audio_base64.
- When provided,
lyricsis required (length: 10–1000 characters) - The
cover_feature_idis valid for 24 hours - Same audio content returns the same
cover_feature_id