1
Create a Python file
Copy
Ask AI
touch basic_streaming.py
2
Add the following code to your Python file
basic_streaming.py
Copy
Ask AI
"""
This example demonstrates asynchronous streaming responses from a team.
The team uses specialized agents with financial tools to provide real-time
stock information with async streaming output.
"""
import asyncio
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.team.team import Team
from agno.tools.exa import ExaTools
from agno.utils.pprint import apprint_run_response
# Stock price and analyst data agent
stock_searcher = Agent(
name="Stock Searcher",
model=OpenAIChat("gpt-5-mini"),
role="Searches the web for information on a stock.",
tools=[
ExaTools(
include_domains=["cnbc.com", "reuters.com", "bloomberg.com", "wsj.com"],
text=False,
show_results=True,
highlights=False,
)
],
)
# Company information agent
company_info_agent = Agent(
name="Company Info Searcher",
model=OpenAIChat("gpt-5-mini"),
role="Searches the web for information on a company.",
tools=[
ExaTools(
include_domains=["cnbc.com", "reuters.com", "bloomberg.com", "wsj.com"],
text=False,
show_results=True,
highlights=False,
)
],
)
# Create team with async streaming capabilities
team = Team(
name="Stock Research Team",
model=OpenAIChat("gpt-5-mini"),
members=[stock_searcher, company_info_agent],
markdown=True,
show_members_responses=True,
)
async def streaming_with_arun():
"""Demonstrate async streaming using arun() method."""
await apprint_run_response(
team.arun(input="What is the current stock price of NVDA?", stream=True)
)
async def streaming_with_aprint_response():
"""Demonstrate async streaming using aprint_response() method."""
await team.aprint_response("What is the current stock price of NVDA?", stream=True)
if __name__ == "__main__":
asyncio.run(streaming_with_arun())
# asyncio.run(streaming_with_aprint_response())
3
Create a virtual environment
Open the
Terminal and create a python virtual environment.Copy
Ask AI
python3 -m venv .venv
source .venv/bin/activate
4
Install libraries
Copy
Ask AI
pip install -U agno exa_py openai
5
Export your API keys
Copy
Ask AI
export OPENAI_API_KEY="your_openai_api_key_here"
export EXA_API_KEY="your_exa_api_key_here"
6
Run Team
Copy
Ask AI
python basic_streaming.py
7
Find All Cookbooks
Explore all the available cookbooks in the Agno repository. Click the link below to view the code on GitHub:Agno Cookbooks on GitHub