ElevenLabs SDK-compatible streaming-input TTS (WebSocket)
Streams text into TTS with the ElevenLabs WebSocket protocol. Use it to start generating audio before all of the text is available. The request must include `Upgrade: websocket`. **Client → server** frames (JSON): - `{ "text": " ", "voice_settings": { "speed": 1.0 }, "generation_config": {...} }` — optional init frame (single space). See the `VoiceSettings` schema for the supported keys; `speed` is honored across providers. - `{ "text": "Hello ", "try_trigger_generation": true }` — append text. - `{ "text": "world.", "flush": true }` — append and force generation. - `{ "text": "", "flush": true }` — flush without closing. - `{ "text": "" }` — close the stream. **Server → client** frames (JSON): - `{ "audio": "<base64 bytes>" }` — one frame per audio chunk. - `{ "audio": null, "error": "<code>", "code": "<status>" }` — error. Text is buffered by default to improve prosody across message boundaries. Two ElevenLabs-only options control buffering: - `auto_mode` (query param) — disables buffering; audio is generated per message rather than across the buffer. - `generation_config.chunk_length_schedule` (init-frame field) — tunes the buffer size, e.g. the init frame `{ "text": " ", "generation_config": { "chunk_length_schedule": [50] } }`. The `try_trigger_generation` and `flush` fields are supported by ElevenLabs, Deepgram, Grok, and Fish. MiniMax does not support mid-stream flushing. Deepgram WebSocket TTS supports only `pcm_*` and `ulaw_*`. Requesting `mp3_*` returns `400 invalid_output_format`. Use `provider_options` for provider-specific settings. You can also pass supported options directly as query parameters. If both forms set the same option, `provider_options[<name>]=<value>` takes precedence. Recognized enum and boolean option values are case-insensitive and are normalized to each provider's wire spelling; free-form values such as prompts, keyterms, and voice IDs retain their original case. The message-level protocol is documented at [the realtime WebSocket reference](/realtime-reference) (AsyncAPI spec: [/asyncapi.yaml](/asyncapi.yaml)).
/el/v1/text-to-speech/{voice_id}/stream-inputStreams text into TTS with the ElevenLabs WebSocket protocol. Use it to start
generating audio before all of the text is available. The request must include
Upgrade: websocket.
Client → server frames (JSON):
{ "text": " ", "voice_settings": { "speed": 1.0 }, "generation_config": {...} }— optional init frame (single space). See theVoiceSettingsschema for the supported keys;speedis honored across providers.{ "text": "Hello ", "try_trigger_generation": true }— append text.{ "text": "world.", "flush": true }— append and force generation.{ "text": "", "flush": true }— flush without closing.{ "text": "" }— close the stream.
Server → client frames (JSON):
{ "audio": "<base64 bytes>" }— one frame per audio chunk.{ "audio": null, "error": "<code>", "code": "<status>" }— error.
Text is buffered by default to improve prosody across message boundaries. Two ElevenLabs-only options control buffering:
auto_mode(query param) — disables buffering; audio is generated per message rather than across the buffer.generation_config.chunk_length_schedule(init-frame field) — tunes the buffer size, e.g. the init frame{ "text": " ", "generation_config": { "chunk_length_schedule": [50] } }.
The try_trigger_generation and flush fields are supported by ElevenLabs,
Deepgram, Grok, and Fish. MiniMax does not support mid-stream flushing.
Deepgram WebSocket TTS supports only pcm_* and ulaw_*. Requesting
mp3_* returns 400 invalid_output_format.
Use provider_options for provider-specific settings. You can also pass
supported options directly as query parameters. If both forms set the same
option, provider_options[<name>]=<value> takes precedence. Recognized enum
and boolean option values are case-insensitive and are normalized to each
provider's wire spelling; free-form values such as prompts, keyterms, and voice
IDs retain their original case.
The message-level protocol is documented at the realtime WebSocket reference (AsyncAPI spec: /asyncapi.yaml).
Tenant key (ElevenLabs SDK convention).
In: header
Path Parameters
Provider voice id (path segment). For Grok TTS, eve is the default voice.
Query Parameters
Model id: bare name or {author}/{modelName} slug (elevenlabs/eleven_flash_v2_5).
Comma-separated or repeated provider IDs in preferred order. Providers not listed remain eligible.
Comma-separated or repeated provider IDs. Only these providers may serve the request.
Comma-separated or repeated provider IDs that must not serve the request.
Set to false to prevent fallback to another provider. Automatic provider retries are not currently supported.
Provider output format (case-insensitive), e.g. mp3_44100_128, pcm_16000, or ulaw_8000. Deepgram WS TTS only supports pcm_/ulaw_.
Seconds of client inactivity before the ElevenLabs connection is closed.
ElevenLabs only. Generate audio for each message instead of buffering text across messages.
ElevenLabs only. Set to false to disable provider request logging.
ISO language code for speech generation.
ElevenLabs text-normalization mode: auto, on, or off.
ElevenLabs only. Parse SSML tags in the input text.
Provider-specific options in bracket notation, such as provider_options[encoding]=linear16. You can also pass supported options directly as query parameters. If both forms set the same option, the bracketed value takes precedence.
Header Parameters
Must be websocket to perform the protocol upgrade.
Response Body
application/json
application/json
application/json
application/json
application/json
import WebSocket from "ws";const ws = new WebSocket("wss://api.allmodels.io/el/v1/text-to-speech/eve/stream-input?model_id=grok/grok-tts&output_format=mp3_44100_128", { headers: { Authorization: `Bearer ${process.env.ALLMODELS_API_KEY}` }});ws.on("open", () => { ws.send(JSON.stringify({ text: "Hello from AllModels", flush: true }));});ws.on("message", (data, isBinary) => { if (isBinary) process.stdout.write(data); else console.log(JSON.parse(data.toString()));});ws.on("error", console.error);import asyncioimport jsonimport osimport websocketsasync def main(): async with websockets.connect( "wss://api.allmodels.io/el/v1/text-to-speech/eve/stream-input?model_id=grok/grok-tts&output_format=mp3_44100_128", additional_headers={"Authorization": f"Bearer {os.environ['ALLMODELS_API_KEY']}"}, ) as socket: await socket.send(json.dumps({"text": "Hello from AllModels", "flush": True})) async for message in socket: print(message if isinstance(message, str) else f"{len(message)} audio bytes")asyncio.run(main())curl --http1.1 -i "https://api.allmodels.io/el/v1/text-to-speech/eve/stream-input?model_id=grok/grok-tts&output_format=mp3_44100_128" \ -H "Authorization: Bearer $ALLMODELS_API_KEY" \ -H "Connection: Upgrade" \ -H "Upgrade: websocket" \ -H "Sec-WebSocket-Version: 13" \ -H "Sec-WebSocket-Key: SGVsbG9BbGxNb2RlbHMhIQ=="import osfrom elevenlabs.client import ElevenLabsclient = ElevenLabs( api_key=os.environ["ALLMODELS_API_KEY"], base_url="https://api.allmodels.io/el",)chunks = client.text_to_speech.convert_realtime( "pNInz6obpgDQGcFmaJgB", text=iter(["Hello from AllModels"]), model_id="elevenlabs/eleven-turbo-v2-5", output_format="mp3_44100_128",)with open("speech.mp3", "wb") as output: for chunk in chunks: output.write(chunk){ "detail": { "message": "Deepgram TTS WS only supports pcm_*/ulaw_* output formats.", "status": "invalid_output_format", "provider": "deepgram", "output_format": "mp3_44100_128" }}{ "error": "missing_api_key"}{ "detail": { "loc": [ "body", "text" ], "msg": "field required", "type": "value_error.missing" }}{ "detail": { "message": "websocket upgrade required", "status": "websocket_upgrade_required" }}{ "detail": { "message": "authentication was not initialized", "status": "auth_not_initialized" }}ElevenLabs SDK-compatible TTS (convert) POST
Generates speech with `client.textToSpeech.convert(...)`. It accepts the same request and returns the same streaming audio response as the `/stream` endpoint. Use `provider_options` for provider-specific settings. You can also pass supported options directly as query parameters. If both forms set the same option, `provider_options[<name>]=<value>` takes precedence. Recognized enum and boolean option values are case-insensitive and are normalized to each provider's wire spelling; free-form values such as prompts, keyterms, and voice IDs retain their original case.
ElevenLabs SDK-compatible STT (file upload) POST
Transcribes an uploaded audio file with `client.speechToText.convert(...)`. Supported formats are WAV, MP3, FLAC, MP4/M4A, OGG, and WebM. Unsupported or unreadable files return `422 indeterminate_audio_duration`. Use `provider_options` for provider-specific settings. You can also pass supported options directly as query parameters. If both forms set the same option, `provider_options[<name>]=<value>` takes precedence. Recognized enum and boolean option values are case-insensitive and are normalized to each provider's wire spelling; free-form values such as prompts, keyterms, and voice IDs retain their original case.
