Gemini with Reasoning Tools

Add the following code to your Python file

1from kern.agent import Agent
2from kern.models.google import Gemini
3from kern.tools.reasoning import ReasoningTools
4from kern.tools.hackernews import HackerNewsTools
5
6reasoning_agent = Agent(
7 model=Gemini(id="gemini-2.5-pro-preview-03-25"),
8 tools=[
9 ReasoningTools(
10 think=True,
11 analyze=True,
12 add_instructions=True,
13 ),
14 HackerNewsTools(),
15 ],
16 instructions="Use tables where possible",
17 stream_events=True,
18 markdown=True,
19 debug_mode=True,
20)
21reasoning_agent.print_response(
22 "Write a report comparing NVDA to TSLA.", show_full_reasoning=True
23)

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 google-genai ddgs

Export your Google API key

1export GOOGLE_API_KEY="your_google_api_key_here"
1$Env:GOOGLE_API_KEY="your_google_api_key_here"

Run Agent

1python gemini_reasoning_tools.py