Getting Started

This page takes you from install to a first generated file. Capabilities explains how to choose a model, API documents the Python surface, and Troubleshooting lists the errors you can meet and their fixes.

Install

pip install abstractmusic

The base package has no local ML runtime. It includes standard-library clients for ElevenLabs Music and for self-hosted ACE-Step API servers. This page describes AbstractMusic 0.3.0; if PyPI has an older version, install from the repository:

pip install "abstractmusic @ git+https://github.com/lpalbou/AbstractMusic"

Install the extra of each local engine you want to run:

pip install "abstractmusic[acestep]"             # ACE-Step XL checkpoints
pip install "abstractmusic[minimax-music3-mlx]"  # MiniMax-Music3, Apple silicon (MLX)
pip install "abstractmusic[minimax-music3]"      # MiniMax-Music3, CUDA / Apple MPS / CPU (PyTorch)
pip install "abstractmusic[stable-audio-3]"      # Stable Audio 3 (gated weights)
pip install "abstractmusic[stable-audio]"        # Stable Audio Open Small (gated weights)
pip install "abstractmusic[musicgen]"            # MusicGen small (non-commercial weights)
pip install "abstractmusic[all-apple]"           # every Apple silicon runtime
pip install "abstractmusic[all-gpu]"             # every CUDA runtime
  • stable-audio and stable-audio-3 run on inference code bundled in AbstractMusic (modified copies of Stability AI's MIT-licensed code); you do not install stable-audio-tools or stable_audio_3. Their extras install only the libraries that code needs (Torch, Transformers, Safetensors, Hugging Face Hub, NumPy, Einops, and a few model-specific helpers).
  • The minimax-music3 extras install AbstractMusic's own runtimes (no diffusers or transformers): minimax-music3 adds NumPy (1.26 or later), Torch (2.3 or later), Safetensors, Tokenizers and Hugging Face Hub; minimax-music3-mlx adds MLX (0.24.2 or later, macOS arm64 only), NumPy, Tokenizers and Hugging Face Hub.

Credentials

Environment variables carry credentials only:

export ELEVENLABS_API_KEY=...     # ElevenLabs Music
export ACEMUSIC_API_KEY=...       # the key of your ACE-Step API server (the acemusic engine sends one)
export HF_TOKEN=...               # gated Hugging Face models (Stable Audio)

Every other setting is a flag. A configuration variable from an earlier version (for example ABSTRACTMUSIC_DURATION_S or ACEMUSIC_BASE_URL) changes nothing; the CLI names it once on stderr with the flag to use instead (see Troubleshooting).

Choose an engine and a model

There is no default engine. Every command names one with --backend (alias --engine), or names a registry model with --model-id, in which case its engine is used and named on stderr. To see what each model can do:

abstractmusic models                                 # the models this package can run
abstractmusic models --needs lyrics --language fr    # those that sing French lyrics
abstractmusic models --usable                        # those you can run here now

The engines: elevenlabs (remote, ElevenLabs Music), acemusic (remote, a self-hosted ACE-Step API server), acestep, minimax-music3, stable-audio-3, stable-audio (Stable Audio Open Small), musicgen, and diffusers (any Diffusers audio checkpoint you name with --model-id). Aliases: eleven and 11labs for elevenlabs; ace and xl for acestep; sa3 for stable-audio-3; minimax and music3 for minimax-music3; remote and ace-music for acemusic; hf for diffusers. Some aliases also select a checkpoint (stable-audio-3-medium, stable-audio-3-small, stable-audio-open-small, musicgen-small); combined with a different --model-id they are an error.

Generate from the command line

abstractmusic --backend acestep t2m "ambient lo-fi study music" --duration 10 --out lofi.wav
abstractmusic --backend elevenlabs t2m "cinematic instrumental synth cue" --duration 30 --out cue.mp3
abstractmusic --backend elevenlabs t2m "upbeat pop song" --lyrics auto --composition-mode plan --duration 30 --out pop.mp3
abstractmusic --backend acemusic --acemusic-base-url http://127.0.0.1:8001 t2m "heroic fantasy epic music" --duration 30 --out epic.wav
abstractmusic --backend musicgen t2m "ambient lo-fi study music" --duration 10 --out lofi.wav
abstractmusic --backend stable-audio t2m "short ambient synth loop" --duration 10 --out loop.wav
abstractmusic --backend stable-audio-3 t2m "rhythmic space shooter game music" --duration 30 --out game.wav
abstractmusic t2m --model-id stabilityai/stable-audio-3-small-sfx --duration 3 --out sfx.wav "A short sci-fi laser zap, crisp transient, no reverb tail"
abstractmusic --backend stable-audio t2m "A heavy wooden door slam, close-mic, natural room tail" --duration 11 --out slam.wav
abstractmusic --backend minimax-music3 t2m "Instrumental cinematic piece, solo piano and soft strings, no vocals" --duration 30 --out piano.wav
abstractmusic --backend acestep t2m "heroic fantasy epic music" --enhance-prompt --auto-lyrics --print-plan --duration 30 --out epic.wav
abstractmusic --backend acestep t2m "heroic fantasy epic instrumental music" --instrumental --print-plan --duration 120 --out epic.wav
abstractmusic --backend acestep t2m "raw prompt only" --text-planner off --duration 30 --out raw.wav

What the CLI does with a command:

  • Format and output path. The format defaults to the model's own (WAV for the local models, MP3 for ElevenLabs); --out defaults to out.<format>. A format the model does not write is an error.
  • Duration. --duration defaults to the model's own default length: 10 s for ACE-Step and MusicGen, 30 s for MiniMax-Music3 and the Stable Audio 3 music checkpoints, 5 s for stabilityai/stable-audio-3-small-sfx, 11 s for Stable Audio Open Small, and 10 s where the registry states none (ElevenLabs, an ACE-Step API server, an unlisted Diffusers checkpoint). Local models return exactly the requested length. A duration outside a model's limits is an error.
  • Task. A model that does only sound effects (Stable Audio 3 Small SFX, Stable Audio Open Small) gets text_to_audio when you do not pass --task, and the CLI says so on stderr. A task the model does not do is an error.
  • Options and request fields. An option the selected engine does not read is an error that names the engines that do. A request field the model cannot honour (lyrics to a model that does not sing, --bpm to a model without a tempo control, a guidance value to a turbo ACE-Step checkpoint) is an error that names the model and suggests abstractmusic models --needs ....
  • Planner. --text-planner deterministic (the default) uses the dependency-free built-in planner; auto chooses it too on the CLI; off passes your text through unchanged. Values the planner chooses (a tempo, a key) are sent only to a model that takes them, and recorded otherwise. For generations of 45 s or more, --structure-prompt (default on) adds a compact section map to the caption; --no-structure-prompt turns it off.
  • Lyrics. --lyrics reads the two characters \n as a line break; --lyrics-file PATH reads a UTF-8 file, one sung line per line. --lyrics auto (or --auto-lyrics) writes simple template lyrics in English for a model that sings.
  • Downloads. Local engines download missing Hugging Face weights. acestep does not when you pass --no-download; minimax-music3 downloads only with an explicit --download. The other engines do not read these two options and refuse them.

t2m prints the output path on stdout and a one-line run summary on stderr (backend, model, runtime, device, dtype, audio length, sample rate and channels, wall time, seed, and stage timings when the backend reports them):

run: backend=<backend id> model=<model id> device=<device> dtype=<dtype> audio=<seconds>s@<rate>Hz/<channels>ch wall=<seconds>s seed=<seed> timings[<stage>=<seconds>s, ...]

--metadata-out auto writes the run's metadata as JSON next to the audio (the --out path with .json). --verbose shows backend logs and progress bars. Errors are one ERROR: line on stderr: exit status 2 for a value the request cannot carry, 1 for other failures (--verbose shows the traceback of an unexpected one), and 130 for Ctrl-C.

Generate from Python

from abstractmusic import MusicManager
from abstractmusic.backends import ElevenLabsMusicBackend, ElevenLabsMusicBackendConfig

backend = ElevenLabsMusicBackend(config=ElevenLabsMusicBackendConfig(api_key="..."))
music = MusicManager(backend=backend)
mp3_bytes = music.t2m("cinematic instrumental synth cue", duration_s=30.0)
open("cue.mp3", "wb").write(mp3_bytes)
from abstractmusic import MusicManager
from abstractmusic.backends import AceMusicBackend, AceMusicBackendConfig

# A self-hosted ACE-Step API server.
backend = AceMusicBackend(config=AceMusicBackendConfig(base_url="http://127.0.0.1:8001", api_key="..."))
music = MusicManager(backend=backend)
wav_bytes = music.t2m("uplifting synthwave with punchy drums", duration_s=30.0)
open("synthwave.wav", "wb").write(wav_bytes)

A request the model cannot honour raises MusicRequestError (from abstractmusic.prompt_planner) before anything loads or is sent. Generated audio files are artifacts, not source files.

Generate a song with vocals

minimax-music3 sings lyrics you write, up to 6 minutes, and runs locally. Its default model is the 8-bit package AbstractFramework/minimax-music3-8bit (12.6 GB) on Apple silicon and the published weights (28.6 GB) with the PyTorch runtime; either downloads only on request (--download once; Python: MiniMaxMusic3BackendConfig(local_files_only=False)). Put each section tag on its own line and write roughly 1.5 to 2.5 words per second of audio (the file is as long as --duration; shorter lyrics are sung as written and wrapped in instrumental sections):

abstractmusic --backend minimax-music3 t2m \
  "Warm acoustic folk ballad, fingerpicked guitar, soft piano, intimate female vocal, 96 bpm" \
  --lyrics "[verse]\nMorning light across the harbor\nGulls are calling out the day\n[chorus]\nCarry me home on the evening tide\nCarry me home where the lanterns glide" \
  --duration 15 --seed 7 --download --out ballad.wav

Before generating, the CLI states the length (Generating 15 s with minimax-music3 (--duration).) and prints a NOTE: line for anything about the request you should know first. A song takes minutes (151 to 188 s for 30 s of audio with MLX on an Apple M5 Max). See MiniMax-Music3.

Interactive REPL

abstractmusic --backend acestep repl --duration 10 --out-dir renders
abstractmusic --engine xl repl
abstractmusic --engine musicgen repl

Inside the REPL:

/status
/engines
/engine acestep
/duration 12
/bpm 128
/steps 8
/shift 3
/seed 123
/verbose off
/lyrics [Instrumental]
/enhance-prompt on
/structure-prompt on
/text-planner deterministic
/auto-lyrics on
/prompt bright melodic synth pop loop with steady drums
/run
bright melodic synth pop loop with steady drums
/params
/exit

For ACE-Step turbo checkpoints, keep /shift 3 with /steps 8: the turbo schedule is tuned around shift=3.0, and turbo checkpoints take no guidance value. See the REPL guide.