allmodels.ioDocs
API ReferenceNative TTS/STT

Native streaming TTS (WebSocket)

GET/v1/tts

Opens 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
AuthorizationBearer <token>

Tenant key supplied as the Authorization Bearer token.

In: header

Query Parameters

provider?string

Use a specific TTS provider.

Value in

  • "deepgram"
  • "elevenlabs"
  • "soniox"
  • "fish"
  • "groq"
  • "grok"
  • "minimax"
  • "cartesia"
  • "together"
  • "openai"
  • "gemini"
  • "fal"
  • "inworld"
  • "amazon"
  • "sprag"
voice?string

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*string

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.

provider_order?array<string>

Comma-separated or repeated provider IDs in preferred order. Providers not listed remain eligible.

provider_only?array<string>

Comma-separated or repeated provider IDs. Only these providers may serve the request.

provider_ignore?array<string>

Comma-separated or repeated provider IDs that must not serve the request.

allow_fallbacks?boolean

Set to false to prevent fallback to another provider. Automatic provider retries are not currently supported.

format?string

Output audio container.

Value in

  • "mp3"
  • "pcm"
auto_flush?string

Auto-flush buffered text. Any value except the literal false enables it.

Default"true"
provider_options?||||||||||||||

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

Upgrade*string

Must be websocket to perform the protocol upgrade.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

Client
Language
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);
Empty

{  "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"}