POST
POST /v1/music/plan — ElevenLabs API
ElevenLabs APIGenerate Composition Plan
- Base URL
- https://api.elevenlabs.io
- Auth
- xi-api-key: <ELEVENLABS_API_KEY>
- Last verified
- 2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 221 tokens · Vary: Accept
→ 221 tokens · Vary: Accept
Critical gotchas
Authentication uses the non-standard xi-api-key header, not Authorization: Bearer. Sending a Bearer token returns HTTP 401.
Text-to-speech responses are raw binary audio, not JSON. Write the body to a file (--output speech.mp3) rather than parsing it.
cURL
curl -X POST 'https://api.elevenlabs.io/v1/music/plan?enable_logging=true' \ -H "xi-api-key: $ELEVENLABS_API_KEY" \ -H 'Content-Type: application/json' \ -d '{ "prompt": "example-prompt", "music_length_ms": 0, "source_composition_plan": { "negative_global_styles": [ "metal", "hip-hop", "country" ], "positive_global_styles": [ "pop", "rock", "jazz" ], "sections": [ { "duration_ms": 10000, "lines": [ "Verse 1 lyrics" ], "negative_local_styles": [ "metal", "hip-hop", "country" ], "positive_local_styles": [ "pop", "rock", "jazz" ], "section_name": "Verse 1" } ] }, "model_id": "music_v1"}'
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| enable_logging | query | boolean | No | When enable_logging is set to false zero retention mode will be used for the request. Zero retention mode may only be used by enterprise customers. |
| prompt | body | string | Yes | A simple text prompt to compose a plan from. |
| music_length_ms | body | integer | No | The length of the composition plan to generate in milliseconds. Must be between 3000ms and 600000ms. Optional - if not provided, the model will choose a length based on the prompt. |
| source_composition_plan | body | object | No | An optional composition plan to use as a source for the new composition plan. |
| model_id | body | string | No | Request body field model_id. |
Response 200 OK
{
"negative_global_styles": [
"metal",
"hip-hop",
"country"
],
"positive_global_styles": [
"pop",
"rock",
"jazz"
],
"sections": [
{
"duration_ms": 10000,
"lines": [
"Verse 1 lyrics"
],
"negative_local_styles": [
"metal",
"hip-hop",
"country"
],
"positive_local_styles": [
"pop",
"rock",
"jazz"
],
"section_name": "Verse 1"
}
]
} Get a free ElevenLabs API key → sponsored Affiliate link - we may earn a commission, at no extra cost to you.