basic_stream.py
stream=True emits content as it arrives. When iterating over agent.run() directly, set stream_events=True to include lifecycle and tool events in addition to content events.
agent.run(..., stream=True) returns an iterator. API or network errors that
occur after the stream starts are raised while that iterator is consumed.Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Set your API key
4
Save and run
Save the example as
basic_stream.py, then run: