Async Streaming Agent

Code

1import asyncio
2
3from kern.agent import Agent
4from kern.models.siliconflow import Siliconflow
5
6agent = Agent(model=Siliconflow(id="openai/gpt-oss-120b"), markdown=True)
7
8asyncio.run(agent.aprint_response("Share a 2 sentence horror story", stream=True))

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

bash export SILICONFLOW_API_KEY=xxx

Install dependencies

bash uv pip install -U kern-ai openai

Run Agent

1python cookbook/11_models/siliconflow/async_basic_stream.py