Async Tool Use

Code

1"""Run `uv pip install` to install dependencies."""
2
3import asyncio
4
5from kern.agent import Agent
6from kern.models.openai import OpenAIResponses
7from kern.tools.hackernews import HackerNewsTools
8
9agent = Agent(
10 model=OpenAIResponses(id="gpt-5-mini"),
11 tools=[HackerNewsTools()],
12 markdown=True,
13)
14asyncio.run(agent.aprint_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/async_tool_use.py