> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meetjamie.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming endpoint

> Open the /v1/platform/diarize WebSocket, send audio in real time and finalize the session.

```http theme={null}
GET wss://api.meetjamie.ai/v1/platform/diarize?encoding=pcm_s16le&sample_rate=16000&channels=1
```

| Query parameter | Accepted value | Default |
| - | - | - |
| `encoding` | `pcm_s16le` | `pcm_s16le` |
| `sample_rate` | `16000` | `16000` |
| `channels` | `1` | `1` |
| `token` | your token, if you cannot send the header | – |
| `session_id` | an existing session id, to [reconnect](https://docs.meetjamie.ai/platform/reconnecting.md) | – |

Any other value of `encoding`, `sample_rate` or `channels` is refused before the upgrade with HTTP `400 {"error":"invalid_audio_format","message":"…"}`. On success the server answers `101 Switching Protocols` with the response header `jamie-session-id: ps_<32 hex>`; the same id also arrives in the first message.

## Sending audio

* Send audio as **binary** messages of raw `pcm_s16le`, 16 kHz, mono. Frames are concatenated into one continuous stream, so they do not have to align with samples.
* Use frames of **100 ms (3,200 bytes)**. A frame may hold at most **500 ms (16,000 bytes)**; a larger one gets the error `frame_too_large` and the socket closes with `1009`. The session itself stays open and you can [reconnect](https://docs.meetjamie.ai/platform/reconnecting.md). A message over 1 MiB drops the connection without an error message.
* **Stream in real time.** In total you may be at most 500 ms ahead of the wall-clock time since the session started (plus 0.1 % of the elapsed time, for clock drift). Sending faster ends the session with `ahead_of_realtime` and close `4003`; you still receive the final result. For a pre-recorded file, pace the frames at 100 ms per 3,200 bytes.
* **For a new session, send only audio captured after the `session` message.** Audio you buffered while connecting would put you ahead of real time immediately; drop it. After a [reconnect](https://docs.meetjamie.ai/platform/reconnecting.md) it is the other way round: send the audio you buffered while disconnected.
* **Keep the socket alive.** If nothing arrives from you for 60 s, the server sends `client_inactive` and closes with `4004`. If you pause audio, send `{"type":"keepalive"}` at least every 30 s; do not rely on WebSocket pings. The session stays open and you can reconnect.
* **Give pings at least 60 s.** If your WebSocket library sends pings, allow at least 60 s for the reply. A network path can hold back a connection for 20–30 s and then deliver everything at once; a shorter ping timeout closes a session that would have recovered. If the connection drops anyway (`1005`, `1006`), [reconnect](https://docs.meetjamie.ai/platform/reconnecting.md) with the session id.

## Client messages

| Message | Effect |
| - | - |
| binary frame with audio | appends audio to the session |
| `{"type":"finalize"}` or an empty binary frame | ends the session; the server sends the remaining segments, `final` and `finished`, then closes with `1000` |
| `{"type":"keepalive"}` | keeps the socket open while you send no audio; no reply |
| anything else | error `invalid_message`; the socket and session are unaffected |

Audio sent after `finalize` is ignored, except that a frame over 16,000 bytes still closes the connection with `1009`; reconnect with the session id to receive the result.

## Ending a session

Send `{"type":"finalize"}` (or an empty binary frame), keep reading, and wait for the server to close. You receive, in order: a last `speakers` message with the remaining segments and `"open":null`, then `final`, then `finished`, then close `1000`. This usually takes under a second; allow up to 60 s before giving up. If the server cannot finish in time you receive `result_incomplete`, followed by `final` with everything decided so far.

> [!NOTE]
>
> Closing the socket yourself does **not** end the session: it stays open for reconnection for 300 s and then ends as `idle_timeout`. Once you send a close frame, nothing more is delivered on that connection. If you close before `finished`: when you had already sent `finalize`, reconnect with the session id to receive `final` and `finished`; when you had not, reconnecting rejoins the running session, and you end it by sending `finalize` there.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.