Async Performance Evaluation
Example showing how to run performance evaluations on async functions.
Create a Python file
1"""This example shows how to run a Performance evaluation on an async function."""23import asyncio45from kern.agent import Agent6from kern.eval.performance import PerformanceEval7from kern.models.openai import OpenAIResponses8910# Simple async function to run an Agent.11async def arun_agent():12 agent = Agent(13 model=OpenAIResponses(id="gpt-5.2"),14 system_message="Be concise, reply with one sentence.",15 )16 response = await agent.arun("What is the capital of France?")17 return response181920performance_eval = PerformanceEval(func=arun_agent, num_iterations=10)2122# Because we are evaluating an async function, we use the arun method.23asyncio.run(performance_eval.arun(print_summary=True, print_results=True))Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall dependencies
1uv pip install -U openai kern-aiExport your OpenAI API key
1export OPENAI_API_KEY="your_openai_api_key_here"1$Env:OPENAI_API_KEY="your_openai_api_key_here"Run Agent
1python performance_async.py