PromptShop

Music

ElevenLabs Music Generation allows users to generate music from text prompts, offering control over instrumental tracks and songs with lyrics. It supports fi...

Install

npx promptshop add music

Details

What This Skill Does

Eleven Labs Music Generation allows users to generate music from text prompts, offering control over instrumental tracks and songs with lyrics. It supports fine-grained control through composition plans, making it suitable for musicians, content creators, and developers seeking AI-generated music.

When to Use

  • Generate background music for videos.
  • Create custom soundtracks for games.
  • Produce royalty-free music for commercial use.
  • Experiment with AI-assisted music composition.
  • Develop personalized music playlists.
  • Compose music for podcasts or audiobooks.

Key Features

  • Generates music from text prompts.
  • Supports instrumental and lyrical compositions.
  • Offers fine-grained control via composition plans.
  • Provides Python, Java Script, and cURL interfaces.
  • Allows uploading audio for inpainting workflows.
  • Generates structured plans for detailed control.

Manual Installation

Quick Start

Python

from elevenlabs import Eleven Labs

client = Eleven Labs()

audio = client.music.compose( prompt="A chill lo-fi hip hop beat with jazzy piano chords", music_length_ms=30000 )

with open("output.mp3", "wb") as f: for chunk in audio: f.write(chunk)

Java Script

import { Eleven LabsClient } from "@elevenlabs/elevenlabs-js"; import { create WriteStream } from "fs";

const client = new Eleven LabsClient(); const audio = await client.music.compose({ prompt: "A chill lo-fi hip hop beat with jazzy piano chords", music LengthMs: 30000, }); audio.pipe(create WriteStream("output.mp3"));

cURL

curl -X POST "https://api.elevenlabs.io/v1/music"
-H "xi-api-key: $ELEVENLABS_API_KEY" -H "Content-Type: application/json"
-d '{"prompt": "A chill lo-fi beat", "music_length_ms": 30000}' --output output.mp3

Methods

MethodDescription
music.composeGenerate audio from a prompt or composition plan
music.composition_plan.createGenerate a structured plan for fine-grained control
music.compose_detailedGenerate audio + composition plan + metadata
music.uploadUpload an audio file for later inpainting workflows and optionally extract its composition plan

See API Reference for full parameter details.

music.upload is available to enterprise clients with access to the inpainting feature.

Composition Plans

For granular control, generate a composition plan first, modify it, then compose:

plan = client.music.composition_plan.create( prompt="An epic orchestral piece building to a climax", music_length_ms=60000 )

Inspect/modify styles and sections print(plan.positive GlobalStyles) # e.g. ["orchestral", "epic", "cinematic"]

audio = client.music.compose( composition_plan=plan, music_length_ms=60000 )

Content Restrictions

Cannot reference specific artists, bands, or copyrighted lyrics bad_prompt errors include a prompt_suggestion with alternative phrasing bad_composition_plan errors include a composition_plan_suggestion

Error Handling

try: audio = client.music.compose(prompt="...", music_length_ms=30000) except Exception as e: print(f"API error: {e}")

Common errors: 401 (invalid key), 422 (invalid params), 429 (rate limit).

References

Installation Guide API Reference ElevenLabs Music Generation

Generate music from text prompts - supports instrumental tracks, songs with lyrics, and fine-grained control via composition plans.

Setup: See Installation Guide. For Java Script, use @elevenlabs/* packages only.

Quick Start

Python

from elevenlabs import Eleven Labs

client = Eleven Labs()

audio = client.music.compose( prompt="A chill lo-fi hip hop beat with jazzy piano chords", music_length_ms=30000 )

with open("output.mp3", "wb") as f: for chunk in audio: f.write(chunk)

Java Script

import { Eleven LabsClient } from "@elevenlabs/elevenlabs-js"; import { create WriteStream } from "fs";

const client = new Eleven LabsClient(); const audio = await client.music.compose({ prompt: "A chill lo-fi hip hop beat with jazzy piano chords", music LengthMs: 30000, }); audio.pipe(create WriteStream("output.mp3"));

cURL

curl -X POST "https://api.elevenlabs.io/v1/music"
-H "xi-api-key: $ELEVENLABS_API_KEY" -H "Content-Type: application/json"
-d '{"prompt": "A chill lo-fi beat", "music_length_ms": 30000}' --output output.mp3

Methods

MethodDescription
music.composeGenerate audio from a prompt or composition plan
music.composition_plan.createGenerate a structured plan for fine-grained control
music.compose_detailedGenerate audio + composition plan + metadata
music.uploadUpload an audio file for later inpainting workflows and optionally extract its composition plan

See API Reference for full parameter details.

music.upload is available to enterprise clients with access to the inpainting feature.

Composition Plans

For granular control, generate a composition plan first, modify it, then compose:

plan = client.music.composition_plan.create( prompt="An epic orchestral piece building to a climax", music_length_ms=60000 )

Inspect/modify styles and sections print(plan.positive GlobalStyles) # e.g. ["orchestral", "epic", "cinematic"]

audio = client.music.compose( composition_plan=plan, music_length_ms=60000 )

Content Restrictions

Cannot reference specific artists, bands, or copyrighted lyrics bad_prompt errors include a prompt_suggestion with alternative phrasing bad_composition_plan errors include a composition_plan_suggestion

Error Handling

try: audio = client.music.compose(prompt="...", music_length_ms=30000) except Exception as e: print(f"API error: {e}")

Common errors: 401 (invalid key), 422 (invalid params), 429 (rate limit).

References

Installation Guide API Reference