Tool Use Stream

Code

1"""Run `uv pip install` to install dependencies."""
2
3from kern.agent import Agent
4from kern.models.openai import OpenAIResponses
5from kern.tools.hackernews import HackerNewsTools
6
7agent = Agent(
8 model=OpenAIResponses(id="gpt-5-mini"),
9 tools=[HackerNewsTools()],
10 markdown=True,
11)
12agent.print_response("Whats happening in France?", 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

1export OPENAI_API_KEY=xxx

Install dependencies

1uv pip install -U openai kern-ai

Run Agent

1python cookbook/11_models/openai/responses/tool_use_stream.py