OpenAI o4-mini with reasoning summary

Add the following code to your Python file

1from kern.agent import Agent
2from kern.models.openai import OpenAIResponses
3from kern.tools.hackernews import HackerNewsTools
4
5# Setup the reasoning Agent
6agent = Agent(
7 model=OpenAIResponses(
8 id="o4-mini",
9 reasoning_summary="auto", # Requesting a reasoning summary
10 ),
11 tools=[HackerNewsTools()],
12 instructions="Use tables to display the analysis",
13 markdown=True,
14)
15
16agent.print_response(
17 "Write a brief report comparing NVDA to TSLA",
18 stream=True,
19)

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 kern-ai openai ddgs

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 Agent

1python openai.py