0
Fork 0
mirror of https://github.com/TanStack/ai.git synced 2026-11-18 19:34:58 +00:00
ai/docs/reference/functions/toWebSocketStream.md
github-actions[bot] f4f32bdcc2
docs: regenerate API documentation (#1195)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-08-22 08:16:20 +00:00

980 B

id title
toWebSocketStream toWebSocketStream

Function: toWebSocketStream()

function toWebSocketStream<TOffset>(
   socket, 
   request, 
   init): void;

Defined in: packages/ai/src/stream-to-websocket.ts:115

Run a full-duplex, conversation-scoped chat over an already-accepted server socket. Each inbound RunAgentInput frame starts one chat() turn (via onRun) whose chunks are pumped back as frames; the socket stays open across turns (pending client-tool resubmit, next user message) until the client closes it or the idle timeout fires. An abort control frame aborts only its turn.

Type Parameters

TOffset

TOffset extends string = string

Parameters

socket

WebSocketLike

request

Request

init

WebSocketStreamInit<TOffset>

Returns

void