Native streaming TTS (WebSocket)
/v1/ttsOpens a WebSocket using the selected provider's text-to-speech protocol.
The request must include Upgrade: websocket.
After connecting, send provider-specific JSON messages and receive binary
audio. For example, Grok accepts {"type":"text","text":"..."} plus optional
{"type":"flush"} / {"type":"close"} frames.
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.
Authentication failures close the connection with code 4401 or 4403.
The close reason contains { "error": "<code>" }.
The message-level protocol is documented at the realtime WebSocket reference (AsyncAPI spec: /asyncapi.yaml).
Authorization
BearerAuth Tenant key supplied as the Authorization Bearer token.
In: header
Query Parameters
Use a specific TTS provider.
Value in
- "deepgram"
- "elevenlabs"
- "soniox"
- "fish"
- "groq"
- "grok"
- "minimax"
- "cartesia"
- "together"
- "openai"
- "gemini"
- "fal"
- "inworld"
- "amazon"
- "sprag"
Provider voice id (e.g. eve for Grok, EXAVITQu4vr4xnSDxMaL for ElevenLabs), or the voice ID of a voice you cloned (e.g. AM:@narrator). Required when the routed model's provider requires a voice — a missing value is then refused 400 voice_required (see defaults.tts.voice on GET /v1/providers for a recommended value); otherwise an omitted voice is forwarded as absent, never substituted, and the provider's own default applies.
Model id: bare name (eleven_flash_v2_5) or {author}/{modelName} slug (elevenlabs/eleven_flash_v2_5). Required — a missing value is refused 400 model_required; the router applies no default model.
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.
Output audio container.
Value in
- "mp3"
- "pcm"
Auto-flush buffered text. Any value except the literal false enables it.
"true"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
application/json
import WebSocket from "ws";const ws = new WebSocket("wss://api.allmodels.io/v1/tts?provider=grok&model=grok/grok-tts&voice=eve&format=pcm", { headers: { Authorization: `Bearer ${process.env.ALLMODELS_API_KEY}` }});ws.on("open", () => { ws.send(JSON.stringify({ type: "text", text: "Hello from AllModels" }));});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/v1/tts?provider=grok&model=grok/grok-tts&voice=eve&format=pcm", additional_headers={"Authorization": f"Bearer {os.environ['ALLMODELS_API_KEY']}"}, ) as socket: await socket.send(json.dumps({"type": "text", "text": "Hello from AllModels"})) 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/v1/tts?provider=grok&model=grok/grok-tts&voice=eve&format=pcm" \ -H "Authorization: Bearer $ALLMODELS_API_KEY" \ -H "Connection: Upgrade" \ -H "Upgrade: websocket" \ -H "Sec-WebSocket-Version: 13" \ -H "Sec-WebSocket-Key: SGVsbG9BbGxNb2RlbHMhIQ=="{ "error": "invalid_tts_request"}{ "error": "missing_api_key"}{ "error": "provider_not_allowed", "tried": [ "deepgram", "soniox", "assemblyai" ]}{ "error": "instructions_not_supported", "model": "grok-tts", "tried": [ "grok" ]}{ "error": "websocket_upgrade_required"}{ "error": "auth_not_initialized"}Create a Realtime client secret POST
Creates credentials for an untrusted client, such as a browser or mobile app, to connect directly to AllModels without receiving your API key.
Native streaming STT (WebSocket) GET
Opens a WebSocket and emits normalized streaming speech-to-text events. The request must include `Upgrade: websocket`.
