Skip to main content
Streaming allows you to receive agent responses incrementally as they’re generated, rather than waiting for the complete response. This provides real-time feedback to users and creates a more responsive experience. Since language models can take time to generate complete responses, streaming lets users see output as it’s produced, making applications feel faster and more interactive.

Basic Usage

Use the stream() method for synchronous calls or astream() for asynchronous calls:
Output:

Accessing Event Attributes

Access individual attributes of streaming events:
Output:

Event Types

When streaming, events have different types that you can handle: