Documentation Index
Fetch the complete documentation index at: https://polos.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Stream agent responses as they’re generated.
Stream text chunks
result = await storyteller.stream(polos, "Tell me a story about a robot")
# Iterate over text chunks as they arrive
async for chunk in result.text_chunks:
print(chunk, end="", flush=True)
Stream all events
result = await storyteller.stream(polos, "Write a haiku")
async for event in result.events:
if event.event_type == "text_delta":
print(event.data.get("content", ""), end="", flush=True)
elif event.event_type == "tool_call":
tool_name = event.data.get("tool_call", {}).get("function", {}).get("name")
print(f"\n[Tool: {tool_name}]")
elif event.event_type == "agent_finish":
print("\n[Done]")
Get final text
result = await storyteller.stream(polos, "What are benefits of reading?")
# Wait for completion and get accumulated text
final_text = await result.text()
print(final_text)
Run it
git clone https://github.com/polos-dev/polos.git
cd polos/python-examples/03-agent-streaming
cp .env.example .env # Add your POLOS_PROJECT_ID and API key
uv sync
python main.py
Open http://localhost:5173 to view your agents and workflows, run them from the UI, and see execution traces.
Python example on GitHub | TypeScript example on GitHub