Async Tool Use

Code

1import asyncio
2
3from kern.agent import Agent
4from kern.models.litellm import LiteLLM
5from kern.tools.hackernews import HackerNewsTools
6
7agent = Agent(
8 model=LiteLLM(
9 id="gpt-5-mini",
10 name="LiteLLM",
11 ),
12 markdown=True,
13 tools=[HackerNewsTools()],
14)
15
16# Ask a question that would likely trigger tool use
17asyncio.run(agent.aprint_response("What is happening in France?"))

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 LITELLM_API_KEY=xxx

Install dependencies

1uv pip install -U litellm kern-ai

Run Agent

1python cookbook/11_models/litellm/async_tool_use.py