Skip to main content
All Sudo models support server-sent event (SSE) streaming.
Add "stream": true to your request body and consume the event-stream as it arrives.

Example – Python

Python

Example – TypeScript / browser fetch

TypeScript

About the SSE payload

  1. Each line that begins with data: contains a JSON chunk.
  2. Lines beginning with : are comments and can be safely ignored.
  3. A final line data: [DONE] signals the end of the stream.

Cancelling streams

Simply abort or close the underlying HTTP connection (e.g. via AbortController in the browser). The request will stop; however, you may be billed for the tokens of the full stream.