Skip to main content

Documentation 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.

Every resource method exposed by the aisdk/elevenlabs package returns a strongly-typed PHP 8.3 value object from the AiSdk\ElevenLabs\Data namespace. These classes carry the exact response surface documented by ElevenLabs while hiding raw HTTP details behind well-named properties. Because each class is declared final readonly, instances are immutable and safe to pass around without defensive copying.
All data classes in AiSdk\ElevenLabs\Data are final readonly PHP 8.3 value objects. Properties are set once at construction and can never be mutated. The rawResponse property present on most types gives you access to the full decoded API response for fields not promoted to first-class properties.

Shared / Audio

BinaryData is the low-level container for raw binary payloads returned by stem-separation and other endpoints that produce a single file with a known MIME type. For the primary audio output of most resource methods, the SDK returns the AudioData type from aisdk/core instead (see the note below).
use AiSdk\ElevenLabs\Data\BinaryData;

$stems = ElevenLabs::music()->separateStems(
    Content::audio(__DIR__ . '/song.mp3'),
    ['stem_variation_id' => 'six_stems_v1'],
);

// $stems is a BinaryData instance
$stems->save(__DIR__ . '/stems.zip');
data
string
required
The raw binary payload as a PHP string. Feed this directly to file_put_contents or use save().
mimeType
string
The MIME type reported by the response, e.g. audio/mpeg or application/zip. Defaults to application/octet-stream when the API does not specify one.
filename
string|null
An optional filename hint, populated when the API returns a Content-Disposition header.
Methods
save(string $path): string
Writes data to the given file-system path. Returns the path on success, or throws AiSdkException if the write fails.
AudioData and AudioResult come from aisdk/core, not this package. Core speech and transcription methods (Generate::speech(), Generate::transcription()) return AudioResult, whose output property is an AudioData instance. ElevenLabs resource methods that return audio (music composition, voice changer, dialogue, etc.) also surface their primary output as an AudioData under the output property of the relevant result type.

Music

Returned by ElevenLabs::music()->plan(). Wraps the raw composition-plan payload from ElevenLabs as a typed value object so it can be passed to composeFromPlan() without manual array juggling.
$plan = ElevenLabs::music()->plan('A tense cinematic cue with a quiet ending.', [
    'model_id' => 'music_v2',
    'music_length_ms' => 30_000,
]);

// Pass the plan directly to composeFromPlan
$track = ElevenLabs::music()->composeFromPlan($plan, [
    'model_id' => 'music_v2',
    'output_format' => 'mp3_48000_192',
]);
value
array
The raw composition plan as an associative array, as returned by the ElevenLabs /music/plan endpoint. Pass this instance directly to composeFromPlan().
Returned by ElevenLabs::music()->upload(). Uploading source audio registers it with ElevenLabs for composition-plan and inpainting workflows and returns its typed song ID alongside optional plan and timestamp metadata.
$upload = ElevenLabs::music()->upload(
    Content::audio(__DIR__ . '/source.mp3'),
    ['return_composition_plan' => true],
);

echo $upload->songId;
songId
string
required
The ElevenLabs song ID assigned to the uploaded audio. Use this in subsequent composition-plan or inpainting requests.
compositionPlan
array|null
The composition plan generated for the uploaded source, if requested. null when the plan was not requested or not returned by the API.
wordTimestamps
list<array>
Word-level timestamp data associated with the uploaded audio. Empty list when no timestamp data was returned.
rawResponse
array
The full decoded API response for access to any fields not promoted to dedicated properties.
Returned by ElevenLabs::music()->composeDetailed(). Extends the basic audio output with composition metadata, song-level metadata, and an optional song ID for use in follow-up operations.
$detailed = ElevenLabs::music()->composeDetailed('A bright synth-pop theme.', [
    'model_id' => 'music_v2',
    'with_timestamps' => true,
]);

echo $detailed->songId;
$detailed->output->save(__DIR__ . '/theme.mp3');
output
AudioData
required
The generated audio. AudioData is the core SDK audio container — call save(string $path) on it to write the file to disk.
compositionPlan
array
required
The structured composition plan used to produce this track, as an associative array.
songMetadata
array
required
Song-level metadata returned by ElevenLabs (tempo, key, genre tags, and similar attributes) as an associative array.
songId
string|null
The ElevenLabs song ID for the generated track, when returned by the API. Use this for inpainting or remix workflows.
rawMetadata
array
The raw decoded metadata response for access to any fields not surfaced by the above properties.

Voice Design

A single voice-design or voice-remix preview, contained within the previews list of a VoiceDesignResult. Each preview includes the generated audio and a generatedVoiceId that is the required input to voiceDesign()->create().
$design = ElevenLabs::voiceDesign()->design(
    'A warm documentary narrator with measured pacing.',
    ['model_id' => 'eleven_ttv_v3', 'auto_generate_text' => true],
);

$preview = $design->previews[0];
$preview->audio->save(__DIR__ . '/preview.mp3');
echo $preview->generatedVoiceId;
generatedVoiceId
string
required
The ephemeral voice ID for this preview. Pass this to voiceDesign()->create() to permanently save it as a usable voice.
audio
AudioData
required
The preview audio clip. Call save(string $path) to persist it locally.
language
string|null
The language the preview was generated in, when reported by the API.
Returned by ElevenLabs::voiceDesign()->design() and ElevenLabs::voiceDesign()->remix(). Contains a list of generated voice previews plus the sample text that was spoken.
$result = ElevenLabs::voiceDesign()->design(
    'A warm documentary narrator with measured pacing.',
    ['model_id' => 'eleven_ttv_v3', 'auto_generate_text' => true],
);

foreach ($result->previews as $preview) {
    echo $preview->generatedVoiceId . PHP_EOL;
    $preview->audio->save(__DIR__ . "/{$preview->generatedVoiceId}.mp3");
}
previews
list<VoicePreview>
required
The generated voice preview objects. Each entry has generatedVoiceId, audio, and optionally language.
text
string
required
The sample text spoken in the previews — either auto-generated or the text you supplied.
rawResponse
array
The full decoded API response.
Returned by ElevenLabs::voiceDesign()->create(). Confirms that the selected preview has been permanently saved to your ElevenLabs account as a usable voice.
$voice = ElevenLabs::voiceDesign()->create(
    generatedVoiceId: $preview->generatedVoiceId,
    name: 'Documentary narrator',
    description: 'A warm, expressive documentary narrator with measured pacing.',
);

// Use $voice->id as the voice_id in speech generation
echo $voice->id;
id
string
required
The permanent ElevenLabs voice ID. Use this as the voice_id in TTS and voice-changer requests.
name
string
required
The name you assigned to the saved voice.
category
string|null
The voice category assigned by ElevenLabs (e.g. generated), when present in the response.
description
string|null
The description you supplied when creating the voice.
rawResponse
array
The full decoded API response.

Dialogue

Character-level timing metadata for a segment of synthesised dialogue. Used as the alignment and normalizedAlignment properties of TimedDialogueResult.
characters
list<string>
required
Ordered list of individual characters in the aligned segment.
startTimes
list<float>
required
Start time in seconds for each character in characters, at the same index.
endTimes
list<float>
required
End time in seconds for each character in characters, at the same index.
Describes a contiguous span of the output audio spoken by a single voice in a timed-dialogue result.
voiceId
string
required
The ElevenLabs voice ID that spoke this segment.
start
float
required
Start time of this voice segment in seconds within the combined output audio.
end
float
required
End time of this voice segment in seconds within the combined output audio.
characterStart
int
required
Zero-based character offset within the dialogue transcript where this segment begins.
characterEnd
int
required
Zero-based character offset within the dialogue transcript where this segment ends (exclusive).
dialogueInputIndex
int
required
Zero-based index into the original dialogue inputs array that produced this segment.
Returned by ElevenLabs::dialogue()->withTimestamps(). Bundles the combined audio with per-character alignment data and per-voice segment boundaries.
$dialogue = ElevenLabs::dialogue()->withTimestamps([
    ['text' => 'Ready?', 'voice_id' => 'JBFqnCBsd6RMkjVDRZzb'],
    ['text' => 'Ready.', 'voice_id' => 'Aw4FAjKCGjjNkVhN1Xmq'],
]);

$dialogue->output->save(__DIR__ . '/dialogue.mp3');

foreach ($dialogue->voiceSegments as $segment) {
    echo "{$segment->voiceId}: {$segment->start} - {$segment->end}\n";
}
output
AudioData
required
The combined dialogue audio. Call save(string $path) to write it to disk.
alignment
CharacterAlignment|null
Raw character-level alignment from ElevenLabs. null when the API did not return alignment data.
normalizedAlignment
CharacterAlignment|null
Whitespace-normalised character-level alignment. null when not returned by the API.
voiceSegments
list<VoiceSegment>
required
One entry per contiguous voice span in the combined audio, describing which voice spoke when and which input dialogue entry it corresponds to.
rawResponse
array
The full decoded API response.

Dubbing

Returned by ElevenLabs::dubbing()->create(). Represents the newly-submitted asynchronous dubbing job. Poll dubbing()->status($job->id) to track progress.
$job = ElevenLabs::dubbing()->create(
    Content::video(__DIR__ . '/interview.mp4'),
    targetLanguage: 'es',
    options: ['source_lang' => 'en'],
);

echo $job->id;
echo $job->expectedDuration; // seconds
id
string
required
The ElevenLabs dubbing job ID. Use this in all subsequent status(), output(), and transcript() calls.
expectedDuration
float
required
The estimated processing time in seconds as reported by ElevenLabs at submission time.
rawResponse
array
The full decoded API response from the job-creation endpoint.
Returned by ElevenLabs::dubbing()->status(). Reflects the current state of a dubbing job, including its source language, target languages, and any error message if the job failed.
$status = ElevenLabs::dubbing()->status($job->id);

if ($status->status === 'dubbed') {
    ElevenLabs::dubbing()
        ->output($job->id, 'es')
        ->save(__DIR__ . '/interview-es.mp4');
}
id
string
required
The dubbing job ID.
name
string
required
The display name of the dubbing job as recorded by ElevenLabs.
status
string
required
The current job state. Common values are dubbing, dubbed, and failed.
sourceLanguage
string|null
The detected or specified source language of the original media.
targetLanguages
list<string>
required
The language codes the content is being or has been dubbed into.
createdAt
string
required
ISO 8601 creation timestamp for the job.
editable
bool
Whether the dubbing output can be edited in Dubbing Studio. Defaults to false.
mediaType
string|null
The detected media type of the original content (e.g. video/mp4).
mediaDuration
float|null
Duration of the original media in seconds, when known.
error
string|null
Human-readable error message when status is failed.
rawResponse
array
The full decoded API response.
Returned by ElevenLabs::dubbing()->transcript(). Provides the dubbed transcript in the format you requested — either as a raw string (SRT, WebVTT) or as a structured array.
$subtitles = ElevenLabs::dubbing()->transcript($job->id, 'es', 'srt');
file_put_contents(__DIR__ . '/interview-es.srt', $subtitles->content ?? '');
format
string
required
The transcript format that was requested, e.g. srt, webvtt, or json.
content
string|null
The transcript as a raw string, populated for text-based formats such as srt and webvtt. null when a structured format was returned instead.
structured
array|null
The transcript as a decoded associative array, populated for JSON-based formats. null for text-based formats.
rawResponse
array
The full decoded API response.

Forced Alignment

A single aligned unit — either a character or a word — as returned within a ForcedAlignmentResult. Both the characters and words lists on that result are composed of AlignmentItem instances.
text
string
required
The character or word that this item represents.
start
float
required
Start time of this unit in seconds within the aligned audio.
end
float
required
End time of this unit in seconds within the aligned audio.
loss
float|null
The alignment loss score for this item, when returned by the API. Lower values indicate higher confidence alignment.
Returned by ElevenLabs::forcedAlignment()->create(). Provides character- and word-level timing for every token in the supplied transcript, aligned against the audio you provided.
$alignment = ElevenLabs::forcedAlignment()->create(
    Content::audio(__DIR__ . '/narration.wav'),
    'The exact transcript spoken in the recording.',
);

foreach ($alignment->words as $word) {
    echo "{$word->text}: {$word->start} - {$word->end}\n";
}
characters
list<AlignmentItem>
required
Character-level alignment items, one per character in the transcript.
words
list<AlignmentItem>
required
Word-level alignment items, one per word in the transcript.
loss
float
required
The overall alignment loss for the full audio/transcript pair. Lower is better.
rawResponse
array
The full decoded API response.

Build docs developers (and LLMs) love