ElevenLabs realtime transcription
Stream PCM audio and receive ElevenLabs-compatible transcription events with the ElevenLabs SDK.
Connect to the ElevenLabs-compatible realtime endpoint, send PCM audio, and listen for partial and committed transcripts.
Connect with the SDK
wss://api.allmodels.io/el/v1/speech-to-text/realtimeElevenLabsimport { readFile } from "node:fs/promises";
import {
AudioFormat,
CommitStrategy,
ElevenLabsClient,
RealtimeEvents
} from "@elevenlabs/elevenlabs-js";
const client = new ElevenLabsClient({
apiKey: process.env.ALLMODELS_API_KEY,
baseUrl: "https://api.allmodels.io/el"
});
const connection = await client.speechToText.realtime.connect({
modelId: "deepgram/nova-3",
audioFormat: AudioFormat.PCM_16000,
sampleRate: 16000,
languageCode: "en",
includeTimestamps: true,
commitStrategy: CommitStrategy.MANUAL
});
connection.on(RealtimeEvents.PARTIAL_TRANSCRIPT, ({ text }) => {
process.stdout.write(text);
});
connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, ({ text }) => {
console.log("\nfinal:", text);
});
connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS, (event) => {
console.log("\nfinal with timestamps:", event.text, event.words);
});
connection.on(RealtimeEvents.ERROR, console.error);
connection.send({
audioBase64: (await readFile("chunk.pcm")).toString("base64")
});
connection.commit();Events
| Event | Purpose |
|---|---|
session_started | Confirms the effective session configuration. |
partial_transcript | Provides interim transcript text. |
committed_transcript | Provides finalized transcript text. |
committed_transcript_with_timestamps | Provides finalized text with timestamp details. |
error | Reports connection, request, or provider failures. |
Choose the model, audio format, sample rate, language, and commit strategy before sending audio. Use CommitStrategy.MANUAL with connection.commit() when your application determines utterance boundaries. Use CommitStrategy.VAD to let supported providers detect boundaries automatically.
Canonical model names select the provider for realtime connections. For example, deepgram/nova-3 routes the connection to Deepgram without a custom provider header.
See the realtime STT API reference and message-level realtime reference for all connection parameters and events.
