Performance with Teams

Example showing how to analyze the runtime and memory usage of an Kern Team.

Create a Python file

1"""Run `uv pip install kern-ai openai` to install dependencies."""
2
3from kern.agent import Agent
4from kern.eval.performance import PerformanceEval
5from kern.models.openai import OpenAIResponses
6from kern.team.team import Team
7
8team_member = Agent(model=OpenAIResponses(id="gpt-5.2"))
9
10
11def instantiate_team():
12 return Team(members=[team_member])
13
14
15instantiation_perf = PerformanceEval(
16 name="Instantiation Performance Team", func=instantiate_team, num_iterations=1000
17)
18
19if __name__ == "__main__":
20 instantiation_perf.run(print_results=True, print_summary=True)

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Install dependencies

1uv pip install -U openai kern-ai

Export your OpenAI API key

1export OPENAI_API_KEY="your_openai_api_key_here"
1$Env:OPENAI_API_KEY="your_openai_api_key_here"

Run Team

1python performance_team_instantiation.py