Skip to main content
streamChat() is an async generator that sends the chat request with stream: true and yields one ChatDeltaEvent per SSE frame.

Signature

opts accepts conversationId, userId, tools, and results.

ChatDeltaEvent

Collect the full text

Callback style

consumeStream(stream, onEvent, onDone?, onError?) wraps a stream with callbacks and returns a function that cancels delivery.

Errors

  • HTTP errors before the stream starts throw the usual typed errors (for example ReyGridAuthError).
  • Failures during the stream, including malformed frames, are thrown as ReyGridStreamError.
  • Connection failures before the response throw ReyGridNetworkError.
  • timeoutMs covers the whole stream.
See Error handling.