For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Connect
BlogHelp CenterAPI PricingSign up
OverviewElevenCreativeElevenAgentsElevenAPIReception AIAPI referenceChangelog
OverviewElevenCreativeElevenAgentsElevenAPIReception AIAPI referenceChangelog
  • Get started
    • Quickstart
    • Agents Quickstart
    • Choosing the right model
  • Tutorials
    • Text to Speech
    • Speech to Text
    • Speech Engine
    • Music
    • Text to Dialogue
    • Voice Changer
    • Voice Isolator
    • Dubbing
    • Sound effects
    • Forced Alignment
  • Concepts
    • Understanding audio streaming
    • Understanding latency
    • Voice cloning
  • How-to guides
      • Streaming
      • Composition plans
      • Inpainting (Enterprise)
  • Reference
    • Libraries & SDKs
    • Errors
    • Agent tooling
    • Webhooks
    • Zero Retention Mode
    • Breaking changes policy
    • UI components
    • Example projects
    • Next.js template
    • Showcase
  • Private deployment
    • Overview
LogoLogo
Login
Login
Connect
BlogHelp CenterAPI PricingSign up
On this page
  • Using the Eleven Music API
  • Next steps
How-to guidesMusic

Music streaming

This guide shows you how to stream music with Eleven Music.
Was this page helpful?
Previous

Composition plans

Precise control over music generation with structured JSON
Next
Built with

How-to guide · Assumes you have completed the Music quickstart.

This guide will show you how to stream music with Eleven Music.

The Eleven Music API is only available to paid users.

Using the Eleven Music API

This guide assumes you have set up your API key and SDK. Complete the quickstart first if you haven’t.

1

Make the API request

Create a new file named example.py or example.mts, depending on your language of choice and add the following code:

1# example.py
2from elevenlabs.client import ElevenLabs
3from elevenlabs.play import play
4import os
5from io import BytesIO
6from dotenv import load_dotenv
7load_dotenv()
8
9elevenlabs = ElevenLabs(
10 api_key=os.getenv("ELEVENLABS_API_KEY"),
11)
12
13stream = elevenlabs.music.stream(
14 prompt="Create an intense, fast-paced electronic track for a high-adrenaline video game scene. Use driving synth arpeggios, punchy drums, distorted bass, glitch effects, and aggressive rhythmic textures. The tempo should be fast, 130–150 bpm, with rising tension, quick transitions, and dynamic energy bursts.",
15 music_length_ms=10000,
16)
17
18# Create a BytesIO object to hold the audio data in memory
19audio_stream = BytesIO()
20
21# Write each chunk of audio data to the stream
22for chunk in stream:
23 if chunk:
24 audio_stream.write(chunk)
25
26# Reset stream position to the beginning
27audio_stream.seek(0)
28
29play(audio_stream)
2

Execute the code

1python example.py

You should hear the generated music playing.

Next steps

Composition plans

Use composition plans to structure and control how music is generated.

Music inpainting

Edit and blend sections of existing tracks with new generations.