$npx -y skills add calesthio/OpenMontage --skill musicGenerate music using ElevenLabs Music API. Use when creating instrumental tracks, songs with lyrics, background music, jingles, or any AI-generated music composition. Supports prompt-based generation, composition plans for granular control, and detailed output with metadata.
| 1 | # ElevenLabs Music Generation |
| 2 | |
| 3 | Generate music from text prompts - supports instrumental tracks, songs with lyrics, and fine-grained control via composition plans. |
| 4 | |
| 5 | > **Setup:** See [Installation Guide](references/installation.md). For JavaScript, use `@elevenlabs/*` packages only. |
| 6 | |
| 7 | ## Quick Start |
| 8 | |
| 9 | ### Python |
| 10 | |
| 11 | ```python |
| 12 | from elevenlabs import ElevenLabs |
| 13 | |
| 14 | client = ElevenLabs() |
| 15 | |
| 16 | audio = client.music.compose( |
| 17 | prompt="A chill lo-fi hip hop beat with jazzy piano chords", |
| 18 | music_length_ms=30000 |
| 19 | ) |
| 20 | |
| 21 | with open("output.mp3", "wb") as f: |
| 22 | for chunk in audio: |
| 23 | f.write(chunk) |
| 24 | ``` |
| 25 | |
| 26 | ### JavaScript |
| 27 | |
| 28 | ```javascript |
| 29 | import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js"; |
| 30 | import { createWriteStream } from "fs"; |
| 31 | |
| 32 | const client = new ElevenLabsClient(); |
| 33 | const audio = await client.music.compose({ |
| 34 | prompt: "A chill lo-fi hip hop beat with jazzy piano chords", |
| 35 | musicLengthMs: 30000, |
| 36 | }); |
| 37 | audio.pipe(createWriteStream("output.mp3")); |
| 38 | ``` |
| 39 | |
| 40 | ### cURL |
| 41 | |
| 42 | ```bash |
| 43 | curl -X POST "https://api.elevenlabs.io/v1/music" \ |
| 44 | -H "xi-api-key: $ELEVENLABS_API_KEY" -H "Content-Type: application/json" \ |
| 45 | -d '{"prompt": "A chill lo-fi beat", "music_length_ms": 30000}' --output output.mp3 |
| 46 | ``` |
| 47 | |
| 48 | ## Methods |
| 49 | |
| 50 | | Method | Description | |
| 51 | |--------|-------------| |
| 52 | | `music.compose` | Generate audio from a prompt or composition plan | |
| 53 | | `music.composition_plan.create` | Generate a structured plan for fine-grained control | |
| 54 | | `music.compose_detailed` | Generate audio + composition plan + metadata | |
| 55 | | `music.upload` | Upload an audio file for later inpainting workflows and optionally extract its composition plan | |
| 56 | |
| 57 | See [API Reference](references/api_reference.md) for full parameter details. |
| 58 | |
| 59 | `music.upload` is available to enterprise clients with access to the inpainting feature. |
| 60 | |
| 61 | ## Composition Plans |
| 62 | |
| 63 | For granular control, generate a composition plan first, modify it, then compose: |
| 64 | |
| 65 | ```python |
| 66 | plan = client.music.composition_plan.create( |
| 67 | prompt="An epic orchestral piece building to a climax", |
| 68 | music_length_ms=60000 |
| 69 | ) |
| 70 | |
| 71 | # Inspect/modify styles and sections |
| 72 | print(plan.positiveGlobalStyles) # e.g. ["orchestral", "epic", "cinematic"] |
| 73 | |
| 74 | audio = client.music.compose( |
| 75 | composition_plan=plan, |
| 76 | music_length_ms=60000 |
| 77 | ) |
| 78 | ``` |
| 79 | |
| 80 | ## Content Restrictions |
| 81 | |
| 82 | - Cannot reference specific artists, bands, or copyrighted lyrics |
| 83 | - `bad_prompt` errors include a `prompt_suggestion` with alternative phrasing |
| 84 | - `bad_composition_plan` errors include a `composition_plan_suggestion` |
| 85 | |
| 86 | ## Error Handling |
| 87 | |
| 88 | ```python |
| 89 | try: |
| 90 | audio = client.music.compose(prompt="...", music_length_ms=30000) |
| 91 | except Exception as e: |
| 92 | print(f"API error: {e}") |
| 93 | ``` |
| 94 | |
| 95 | Common errors: 401 (invalid key), 422 (invalid params), 429 (rate limit). |
| 96 | |
| 97 | ## References |
| 98 | |
| 99 | - [Installation Guide](references/installation.md) |
| 100 | - [API Reference](references/api_reference.md) |