Create music
Generates a music track from a text prompt (ElevenLabs Eleven Music). Returns a binary audio stream in the requested response_format. Billed per minute of generated audio (the requested duration_ms).
POST
https://api.deutschlandgpt.de/v2/audio/musicExample request
curl https://api.deutschlandgpt.de/v2/audio/music \
-X POST \
-H "Authorization: Bearer $DGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Upbeat lo-fi hip hop with mellow piano and a soft beat",
"model": "music_v1",
"duration_ms": 30000,
"response_format": "mp3"
}'curl https://api.deutschlandgpt.de/v2/audio/music \
-X POST \
-H "Authorization: Bearer $DGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Upbeat lo-fi hip hop with mellow piano and a soft beat",
"model": "music_v1",
"duration_ms": 30000,
"response_format": "mp3"
}'import os, requests
response = requests.post(
"https://api.deutschlandgpt.de/v2/audio/music",
headers={"Authorization": f"Bearer {os.environ['DGPT_API_KEY']}"},
json={
"prompt": "Upbeat lo-fi hip hop with mellow piano and a soft beat",
"model": "music_v1",
"duration_ms": 30000,
"response_format": "mp3"
},
)
print(response.json())import os, requests
response = requests.post(
"https://api.deutschlandgpt.de/v2/audio/music",
headers={"Authorization": f"Bearer {os.environ['DGPT_API_KEY']}"},
json={
"prompt": "Upbeat lo-fi hip hop with mellow piano and a soft beat",
"model": "music_v1",
"duration_ms": 30000,
"response_format": "mp3"
},
)
print(response.json())const response = await fetch('https://api.deutschlandgpt.de/v2/audio/music', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DGPT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"prompt": "Upbeat lo-fi hip hop with mellow piano and a soft beat",
"model": "music_v1",
"duration_ms": 30000,
"response_format": "mp3"
}),
});
console.log(await response.json());const response = await fetch('https://api.deutschlandgpt.de/v2/audio/music', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DGPT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"prompt": "Upbeat lo-fi hip hop with mellow piano and a soft beat",
"model": "music_v1",
"duration_ms": 30000,
"response_format": "mp3"
}),
});
console.log(await response.json());Request body
promptstringrequiredDescription of the music to generate (genre, mood, instruments, tempo, …).
modelstringoptionalMusic model to use. Defaults to music_v1.
duration_msintegeroptionalLength of the generated track in milliseconds. Capped at the model's max (300000 = 5 min). Defaults to 30000.
response_formatstringoptionalAudio format. Defaults to mp3.
Response
200audio/mpeg, audio/opus, audio/pcm
Binary audio stream of the generated music.
Response codes
200
Binary audio stream of the generated music.
400
Unsupported format or provider error.
401
Unauthorized.
402
Insufficient credits.
403
API key lacks permission for this model.
404
Model not found.
Was this page helpful?