---
title: "Stream text to speech over WebSocket"
method: GET
path: "/text-to-speech/speech"
tags: ["Text To Speech Commands"]
---

# Stream text to speech over WebSocket

`GET /text-to-speech/speech`

Open a WebSocket connection to stream text and receive synthesized audio in real time. Authentication is provided via the standard `Authorization: Bearer <API_KEY>` header. Send JSON frames with text to synthesize; receive JSON frames containing base64-encoded audio chunks.

Supported providers: `aws`, `telnyx`, `azure`, `murfai`, `minimax`, `rime`, `resemble`, `elevenlabs`, `xai`, `humain`.

**Connection flow:**
1. Open WebSocket with query parameters specifying provider, voice, and model.
2. Send an initial handshake message `{"text": " "}` (single space) with optional `voice_settings` to initialize the session.
3. Send text messages as `{"text": "Hello world"}`.
4. Receive audio chunks as JSON frames with base64-encoded audio.
5. A final frame with `isFinal: true` indicates the end of audio for the current text.

To interrupt and restart synthesis mid-stream, send `{"force": true}` — the current worker is stopped and a new one is started.

**Note:** The Telnyx `Ultra` model is not available over WebSocket. Use the HTTP POST `/text-to-speech/speech` endpoint instead.

## Query parameters

- `voice` string
- `provider` 'aws' | 'telnyx' | 'azure' | 'elevenlabs' | 'minimax' | 'murfai' | 'rime' | 'resemble' | 'xai' | 'humain'
- `model_id` string
- `voice_id` string
- `disable_cache` boolean
- `audio_format` 'pcm' | 'wav' | 'mp3'
- `socket_id` string

## Response `200`

WebSocket upgrade successful — this response is not returned directly. See 101 for frame documentation.

## Other responses

- `101` — WebSocket connection established. Communication proceeds via JSON frames. **Client → Server:** See `ClientTextFrame` schema. **Server → Client:** See `AudioChunkFrame`, `FinalFrame`, and `ErrorFrame` schemas.
- `400` — Invalid parameters — provider not supported or missing required fields.
- `401` — Authentication failed — missing or invalid `x-telnyx-auth-rev2` header.

---

[API](https://skmtc.net/team-telnyx/apis/telnyx-api-2.md) · [All operations](https://skmtc.net/team-telnyx/apis/telnyx-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/team-telnyx/telnyx-api-2/versions/8f5f4e537994/schema)
