TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/elevenlabs/llms.txt
Use this file to discover all available pages before exploring further.
Music resource exposes the full surface of ElevenLabs’ music generation APIs from a single, coherent PHP interface. You can compose tracks directly from a text prompt, break the process into two steps by generating a composition plan first, receive rich metadata alongside the audio, derive a synchronized score from one or more video files, isolate individual stems from a mixed track, and upload source audio for use in composition-plan and inpainting workflows. Every method is available on both the configured provider instance and the static facade.
Methods
compose()
The simplest path to a finished track. Supply a text prompt and any additional options; the method returns anAudioResult whose output property you can save or read directly.
output_format is extracted from the options array and forwarded as a query
parameter before the remaining options are serialised into the JSON request
body. This matches the ElevenLabs API contract. The default value when the
key is omitted is 'auto'.Descriptive text that guides the composition — instrumentation, mood, tempo,
and structure all influence the result.
Additional generation options sent in the request body (except
output_format, which is sent as a query parameter).ElevenLabs music model to use. Available values:
music_v1, music_v2.Target duration of the generated track in milliseconds.
Audio encoding for the returned file (e.g.
mp3_44100_128,
mp3_48000_192). Defaults to 'auto'.Contains the raw audio bytes and MIME type. Call
->save($path) to write
the file, or access ->data for the raw string.plan()
Generate a structured composition plan without producing audio. The plan encodes the structural decisions ElevenLabs has made — sections, styles, instruments — and can be inspected or modified before you commit to rendering a track.Descriptive text used to build the composition plan.
Additional options forwarded in the JSON request body, including
model_id
and music_length_ms.The raw composition plan returned by ElevenLabs. Pass this directly to
composeFromPlan() or composeDetailedFromPlan().composeFromPlan()
Render audio from an existingMusicPlan or a raw plan array. This lets you inspect or adjust the plan between steps before committing to a full render.
A
MusicPlan instance returned by plan(), or a raw associative array with
the same structure.Generation options, including
model_id and output_format.composeDetailed()
Compose a track and receive aDetailedMusicResult that bundles the audio together with the composition plan and song metadata returned in the same response. Useful when you need to log, display, or post-process plan and metadata alongside the audio.
composeDetailed() sends an Accept: multipart/mixed header and receives
audio and JSON metadata as separate parts in a single response. The
output_format option is extracted and sent as a query parameter as with
compose(). The default format is 'auto'.Text description used to compose the track.
Options sent in the JSON body. Common keys include
model_id,
music_length_ms, with_timestamps, and output_format.The rendered audio data. Call
->save($path) to write the file.The structured plan that was used to generate the track.
Metadata about the produced song (title, style tags, and similar fields).
ElevenLabs song identifier returned in the
song-id response header, if
present.composeDetailedFromPlan()
Identical tocomposeDetailed() but drives the render from an existing plan rather than a fresh prompt. Accepts either a MusicPlan object or a raw array.
A
MusicPlan instance or a raw plan array.Generation options including
model_id and output_format.Same structure as
composeDetailed() — see above for field descriptions.videoToMusic()
Derive a synchronized music soundtrack from one or more video files. Each video is uploaded as a multipart part; the text options (description, tags, model) are sent alongside them.A single
Content value or a list of Content values created with
Content::video(). Each item is sent as a separate videos multipart field.Additional fields appended to the multipart request. Useful keys include
description, tags, model_id, and output_format. The default
output_format when omitted is mp3_44100_128.separateStems()
Separate a mixed audio track into individual stems (e.g. vocals, bass, drums). The result is a ZIP archive containing each stem as a separate audio file.The source audio file, created with
Content::audio().Options sent alongside the file in the multipart request. The
output_format key (default mp3_44100_128) is extracted and sent as a
query parameter.Determines how many stems are produced (e.g.
six_stems_v1).Embed a C2PA provenance manifest in each output stem when
true.Call
$stems->save($path) to write the ZIP file directly to disk. Throws an
AiSdkException if the write fails.upload()
Upload a source audio file for use in composition-plan extraction and inpainting workflows. Returns aMusicUpload with the assigned song ID and any plan or timestamp data the API analysed from the file.
The source audio to upload, created with
Content::audio().The ElevenLabs identifier assigned to the uploaded track.
Extracted composition plan, or
null if the API did not return one.Array of word-timing objects. Each entry is an associative array with at
least
word, start, and end keys. Empty when timestamps were not
requested.Data Classes
MusicPlan
Returned byplan(). Wraps the raw plan array so it can be passed directly to composeFromPlan() or composeDetailedFromPlan() without unwrapping it yourself.
| Property | Type | Description |
|---|---|---|
value | array | The raw composition plan from ElevenLabs, including section chunks, styles, and structural metadata. |
DetailedMusicResult
Returned bycomposeDetailed() and composeDetailedFromPlan(). Bundles audio and structured metadata from the multipart/mixed response.
| Property | Type | Description |
|---|---|---|
output | AudioData | Rendered audio bytes and MIME type. |
compositionPlan | array | The plan that governed this composition. |
songMetadata | array | Title, style, and other song-level metadata. |
songId | string|null | Song identifier from the song-id response header. |
rawMetadata | array | The complete, unparsed JSON metadata object from the response. |
MusicUpload
Returned byupload(). Carries the song ID and any analytical data derived from the uploaded file.
| Property | Type | Description |
|---|---|---|
songId | string | ElevenLabs identifier for the uploaded track. |
compositionPlan | array|null | Extracted plan, if requested and returned. |
wordTimestamps | list | Word-timing entries, empty when not requested. |
rawResponse | array | The complete, unparsed JSON response from the upload endpoint. |
Available Models
| Model ID | Description |
|---|---|
music_v1 | First-generation ElevenLabs music model. |
music_v2 | Second-generation model with improved structure and plan support. |
model_id option on any music method.