Async Basic Streaming Agent

Stream a Perplexity-powered Agno agent's response asynchronously.

Code

async_basic_stream.py
import asyncio

from agno.agent import Agent
from agno.models.perplexity import Perplexity

agent = Agent(model=Perplexity(id="sonar-pro"), markdown=True)

asyncio.run(agent.aprint_response("Share a 2 sentence horror story", stream=True))

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Set your API key

export PERPLEXITY_API_KEY=xxx

Install dependencies

uv pip install -U agno openai

Run Agent

python async_basic_stream.py