# Speech and transcription for many live calls on one WebSocket

WS /v1/tts/multi and WS /v1/stt/multi carry many live speech and transcription sessions on one WebSocket, and each session keeps its own id, billing, and close code.

Published 2026-11-18. Paxa Labs.

An application that speaks and listens on many calls at once used to open two WebSockets for every call. Two hundred agents on the phone held four hundred sockets. Each new call waited for its own connection before the first word went out, and every socket needed its own keepalive, reconnect, and teardown.

Since November 18, `WS /v1/tts/multi` and `WS /v1/stt/multi` carry many calls on one long-lived socket. Each call is a context, named by an id you choose. A context behaves exactly like a `WS /v1/tts/live` or `WS /v1/stt/live` connection, with the same frames, events, billing, and limits.

## What shipped

- `WS /v1/tts/multi` speaks streamed text for many calls at once, in any Paxa TTS Flash v2 or Paxa TTS Flash voice. Each context picks its own voice and audio format, telephony mu-law and A-law included.
- `WS /v1/stt/multi` transcribes many calls at once with Paxa STT Lite Realtime. Every context gets streaming transcription with automatic turn detection.
- Every JSON frame and every event carries a `context_id`. Audio travels in binary frames that open with a short header naming the context.
- A context ends with one `closed` event carrying the close code a socket of its own would have used. The other calls on the socket keep running.
- Before a restart, the server sends `draining` with a grace period for moving calls to a new socket.

## Where it fits

Any service that holds many conversations at the same moment can put them on a few sockets per server.

### Contact centers

Each live call in a [contact center](https://paxalabs.com/use-cases/call-centers) holds a speech context for the agent's voice and a transcription context for the caller. The contexts open when the call connects and close when it hangs up. A server handling hundreds of calls keeps two sockets open all day.

Use your own call id as the `context_id` on both sockets. The transcript, the audio, and every billing receipt then name the call directly.

### Voice agent platforms

A platform hosting [voice agents](https://paxalabs.com/use-cases/voice-agents) for many businesses runs each conversation as a context on a worker's socket. One agent failing closes its own context with a code. The conversations beside it continue, and each context reports its own charges for the platform to pass on to the business behind the call.

### Phone lines and SIP gateways

A media server bridging phone lines to an agent receives 8 kHz mu-law audio from each line. It can forward that audio to `WS /v1/stt/multi` as it arrives, behind the line's id. The reply comes back from `WS /v1/tts/multi` in mu-law or A-law, with no transcoding on either side.

### Live captions for many rooms

A university putting [live captions](https://paxalabs.com/use-cases/captions) in every [lecture](https://paxalabs.com/use-cases/lectures) hall, or a conference running parallel tracks, opens one transcription context per room. Each context finds the end of every turn on its own and delivers a finished transcript for it.

### One context per speaker

A meeting tool that receives each participant's audio track separately can transcribe every track in its own context. Each line of the [meeting transcript](https://paxalabs.com/use-cases/meetings) then belongs to one participant, with no speaker separation on a mixed recording. Contexts open and close as people join and leave.

### Characters in games and stories

A [game](https://paxalabs.com/use-cases/games-apps) or an [interactive story](https://paxalabs.com/use-cases/interactive-fiction) can give every character in a scene its own speech context, each with its own voice. Lines stream as the dialogue system writes them. A `cancel` stops one character mid-sentence while the others carry on.

### Language learning and tutoring

A [language app](https://paxalabs.com/use-cases/e-learning) listens to each learner through a transcription context and answers through a speech context, with many learners per server. Each context sets its own voice and language. Learners of English, Thai, and Mandarin share the same two sockets.

### Outbound calls and announcements

Appointment reminders and delivery updates go out as calls, each a speech context opened when the line picks up. A campaign of thousands of calls runs on the sockets the dialer already holds. Station and store [announcements](https://paxalabs.com/use-cases/announcements) work the same way, one context per speaker zone.

## How a context works

Open the socket with your API key in the `Authorization` or `x-api-key` header. A `start` frame with a new `context_id` opens a context and takes the fields the single socket's `start` takes. The id is 1 to 64 characters of letters, digits, and `.`, `_`, `:`, or `-`.

Every frame you send for that call and every event it sends back carries the id. A binary audio frame opens with one byte counting the id's length, then the id in ASCII, then the audio, up to 64 KiB a frame. Here is one speech context speaking one line:

Server events:

```json
{"type":"started","context_id":"call-1042","connection":"7d9c2b7e-4a41-4c8e-9a35-1f26d8c04b7a","model":"paxa-tts-flash-v2","voice":"khanomkrok","format":"mp3","sample_rate":44100}
{"type":"charged","context_id":"call-1042","seq":1,"chars":36,"credits":0.36,"total_credits":0.36}
{"type":"flushed","context_id":"call-1042","seq":1}
{"type":"done","context_id":"call-1042","total_chars":36,"total_credits":0.36}
{"type":"closed","context_id":"call-1042","code":1000,"reason":"session complete"}
```

After `closed`, the id is free for a new call. A context with no frame in and nothing out for 300 seconds closes with 4408.

## When one call fails

A failure closes only its own context. Running out of credits closes that context with 4402, a malformed frame with 4400, and a backend failure with its own code. Every other context on the socket keeps running.

Two conditions close the whole socket, because nothing on that key could charge again. The key stopped being valid (4401), or it reached its spending cap (4403). Every open context reports `closed` with that code first.

Before a restart, the server sends `draining` with a grace period in seconds. Open a new socket, start new calls there, and move each open call over at its next turn boundary.

## Billing and limits

A context is billed as a connection of its own, at the rates of [live speech](https://paxalabs.com/docs/live-streaming#billing) and [realtime transcription](https://paxalabs.com/docs/speech-to-text#realtime). The request floor applies once per context, and its `charged` receipts and `done` total count that call alone.

Each open context holds one of the plan's [concurrent slots](https://paxalabs.com/docs/rate-limits#concurrency) for its product, counted together with single connections. A socket sets no limit of its own on contexts. Each speech leg spends one request of the per-minute rate limit, and a transcription context spends one at its `start`.

The account's plan and the key's spending cap are read again while the socket stays open. A plan upgrade applies to the next context without reconnecting.

## When a socket of its own is simpler

The multiplexed sockets take the API key in a request header, which puts them on your server. A browser app, or a product with one conversation at a time, stays simpler on `WS /v1/tts/live` and `WS /v1/stt/live`. Both kinds of socket can run side by side on one account.

## Common questions

### Does a call cost more on a multiplexed socket?

A context bills exactly as a connection of its own, at the same rates and with the same request floor once per call.

### How many calls can one socket carry?

As many as the plan's concurrency allows for that product. The socket sets no cap of its own, and a context holds its slot from `start` until `closed`.

### Can one socket carry both speech and transcription?

A socket carries one product. A call that speaks and listens holds a context on `WS /v1/tts/multi` and one on `WS /v1/stt/multi`, and both can use the same `context_id`.

### What happens to open calls during a deploy?

The server sends `draining` with a grace period first, and calls already open keep running through it. A call still open at the end closes with 1001. A speech leg in flight finishes or is refunded, and transcription charges the audio it received.

### Can I reuse a context id?

Yes, once its `closed` event arrives. A late frame for an id that is not open answers an error and closes nothing. It cannot end a new call that reused the id.

## Next steps

- Read [Many sessions on one WebSocket](https://paxalabs.com/docs/multiplexing) for the binary header, the close codes, and restarts, with TypeScript and Python clients.
- Read [the realtime transcription launch](https://paxalabs.com/blog/realtime-transcription-for-thai-voice-agents) for how a context finds the end of each turn.

The contract itself lives in the docs.

- [Multiplexed live speech](https://paxalabs.com/docs/api/tts-multi): Every speech frame, event, and code
- [Multiplexed realtime transcription](https://paxalabs.com/docs/api/stt-multi): Every transcription frame, event, and code
- [Rate limits and concurrency](https://paxalabs.com/docs/rate-limits): Contexts a plan may hold at once
