Browse documentation

WebSocket

Open a WebSocket to the returned url. The token travels as a subprotocol, because browsers cannot set headers on a WebSocket handshake.

http
wss://<url from connect>Sec-WebSocket-Protocol: lecsync.realtime.v1, <token>
js
const ws = new WebSocket(  url,  ['lecsync.realtime.v1', token],);
// session.ready is the go signal — send audio after it arrives.ws.onmessage = (e) => {  const msg = JSON.parse(e.data);  if (msg.type === 'session.ready') startSendingAudio();};

expiresAt is a deadline for opening the connection, not a limit on how long it may stay open. A stream ends after 4 hours, or after 60 seconds with no audio. session.ping does not reset that idle timer.

js
ws.send(JSON.stringify({ type: 'session.ping' }));// → { "type": "session.pong" }

The API is a pure realtime pipe. Unless you pass store: true nothing is persisted — when the connection closes, the audio and the transcript are gone from our side.