DeepSeek Reasoner

Add the following code to your Python file

1from kern.agent import Agent
2from kern.models.deepseek import DeepSeek
3from kern.models.openai import OpenAIResponses
4
5task = (
6 "You are a philosopher tasked with analyzing the classic 'Trolley Problem'. In this scenario, a runaway trolley "
7 "is barreling down the tracks towards five people who are tied up and unable to move. You are standing next to "
8 "a large stranger on a footbridge above the tracks. The only way to save the five people is to push this stranger "
9 "off the bridge onto the tracks below. This will kill the stranger, but save the five people on the tracks. "
10 "Should you push the stranger to save the five people? Provide a well-reasoned answer considering utilitarian, "
11 "deontological, and virtue ethics frameworks. "
12 "Include a simple ASCII art diagram to illustrate the scenario."
13)
14
15reasoning_agent = Agent(
16 model=OpenAIResponses(id="gpt-5.2"),
17 reasoning_model=DeepSeek(id="deepseek-reasoner"),
18 markdown=True,
19)
20reasoning_agent.print_response(task, stream=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 kern-ai openai

Export your DeepSeek API key

1export DEEPSEEK_API_KEY="your_deepseek_api_key_here"
1$Env:DEEPSEEK_API_KEY="your_deepseek_api_key_here"

Run Agent

1python deepseek.py