Async Tool Use
Code
1"""Run `uv pip install` to install dependencies."""23import asyncio45from kern.agent import Agent6from kern.models.xai import xAI7from kern.tools.hackernews import HackerNewsTools89agent = Agent(10 model=xAI(id="grok-2"),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.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export XAI_API_KEY=xxxInstall dependencies
1uv pip install -U xai kern-aiRun Agent
1python cookbook/11_models/xai/async_tool_use.py