Skip to main content
Streaming allows you to process data incrementally as it is generated by the model. This is useful for large outputs or when you want to display data to users in real-time.

JavaScript

You can leverage pipeThrough and TextDecoderStream to process streamed data efficiently:

Explanation

  • model.run: Sends the input text to the model with streaming enabled.
  • pipeThrough(new TextDecoderStream()): Converts the byte stream into text.
  • for await (const chunk of textStream): Processes each chunk of text as it arrives.

Python

In Python, streaming can be achieved using the Bytez client:

Explanation

  • model.run: Sends the input text and parameters to the model with streaming enabled.
  • for chunk in stream: Iterates through each chunk of streamed data as it is generated.

Julia

You can use the Bytez library to implement streaming with channels:

Explanation

  • model.run: Sends the input text and options to the model with streaming enabled.
  • while isopen(stream): Continuously checks for new data in the stream.
  • take!(stream): Retrieves the next item from the stream.