ElevenLabs Music - Quickstart Python Example

March 30, 2026 ยท View on GitHub

Generate an MP3 music track from a text prompt using the ElevenLabs Python SDK.

Setup

  1. Copy the environment file and add your API key:

    cp .env.example .env
    

    Then edit .env and paste your ElevenLabs API key.

  2. Create a virtual environment and install dependencies:

    python3 -m venv .venv
    .venv/bin/pip install -r requirements.txt
    

The Music API is currently available to paid ElevenLabs users.

Run

.venv/bin/python main.py "A chill lo-fi beat with jazzy piano chords"

The generated track is saved to output.mp3.