Streaming Input
The ElevenLabs stream-input WebSocket. Send text chunks as they are produced, receive audio chunks as they are synthesized. The protocol voice-agent frameworks speak.
Last reviewed 2026-08-25
Connect
wss://api.mserve.ai/elevenlabs/v1/text-to-speech/{voice_id}/stream-input?output_format=mp3_44100_128Auth is the xi-api-key header, the Authorization header, or xi_api_key in the first frame. output_format accepts the ElevenLabs enum. An unknown format closes the socket with code 1008 and an invalid_output_format error frame.
Frames
Start
Send a first frame with a single space. It can carry voice_settings, generation_config, and xi_api_key.
{ "text": " ", "voice_settings": { "stability": 0.5, "similarity_boost": 0.8 }, "xi_api_key": "ms_live_your_key" }Send text
Send text as it arrives from your model. Words are buffered until a sentence boundary or a flush.
{ "text": "Every model. " }Flush and close
flush forces synthesis of the buffer. An empty string closes the stream.
{ "text": " ", "flush": true }{ "text": "" }Server frames carry base64 audio, optional alignment, and isFinal on the last one:
{ "audio": "SUQzBAAAAAAA…", "isFinal": false, "alignment": { "chars": ["E", "v"], "charStartTimesMs": [0, 50], "charDurationsMs": [50, 60] } }Frameworks
Pipecat, LiveKit Agents, and Vapi speak this protocol through their ElevenLabs plugins. Set the plugin's base URL to https://api.mserve.ai/elevenlabs and its key to an ms_live_ key.
from pipecat.services.elevenlabs.tts import ElevenLabsTTSService
tts = ElevenLabsTTSService(api_key="ms_live_your_key", voice_id="21m00Tcm4TlvDq8ikWAM", base_url="https://api.mserve.ai/elevenlabs")Billing
The stream is billed once at close, on the characters sent. A dropped connection bills the characters that were synthesized.