Basic Agent with Streaming
Code
1from kern.agent import Agent2from kern.models.portkey import Portkey34agent = Agent(5 model=Portkey(6 id="@first-integrati-707071/gpt-5-nano",7 ),8 markdown=True,9)1011# Print the response in the terminal12agent.print_response(13 "What is Portkey and why would I use it as an AI gateway?", stream=True14)Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API keys
1export PORTKEY_API_KEY=***2export PORTKEY_VIRTUAL_KEY=***Install dependencies
1uv pip install -U kern-aiRun Agent
1python cookbook/11_models/portkey/basic_stream.py