Python SDK for deep research using Gemini with search grounding
Project description
deep-researcher-sdk
A Python SDK for conducting deep research using Google's Gemini models with built-in search grounding. No external search APIs required.
Installation
pip install deep-researcher-sdk
Or with uv:
uv add deep-researcher-sdk
Quick Start
from deep_research import research
result = research("What are the top trends in B2B SaaS marketing in 2025?")
print(result.report)
Configuration
Set your Gemini API key as an environment variable:
export GEMINI_API_KEY="your-api-key"
Get a free API key from Google AI Studio.
Usage
Simple Usage
from deep_research import research
result = research("Your research query here")
# Access the results
print(result.plan) # Research plan
print(result.learnings) # List of learnings from searches
print(result.report) # Final synthesized report
Save Output to Files
from deep_research import research
result = research(
"Your research query here",
output_dir="./research_output"
)
# Saves: plan.md, learning_1.md, ..., learnings.md, report.md
Custom Models
from deep_research import research
result = research(
"Your research query here",
thinking_model="gemini-2.5-pro", # For planning and synthesis
task_model="gemini-2.5-flash", # For search tasks
)
Class-Based Usage
from deep_research import DeepResearcher
researcher = DeepResearcher(
thinking_model="gemini-2.5-pro",
task_model="gemini-2.5-flash",
api_key="your-api-key", # Optional, defaults to GEMINI_API_KEY env var
)
# Run full research
result = researcher.research("Your query", output_dir="./output")
# Or run individual steps
plan = researcher.write_plan("Your query")
queries = researcher.generate_search_queries(plan)
learnings = [researcher.search_and_learn(q.query, q.research_goal) for q in queries]
report = researcher.write_report(plan, learnings)
How It Works
The SDK orchestrates a multi-step research flow:
- Plan Generation - Uses the thinking model to create a structured research plan
- Query Generation - Generates 3-5 targeted search queries based on the plan
- Search & Learn - Executes each query using Gemini's built-in search grounding, extracting key learnings
- Report Synthesis - Combines all learnings into a comprehensive final report
Dual Model Architecture
The SDK uses two models optimized for different tasks:
- Thinking Model (
gemini-2.5-pro): Used for planning, query generation, and final report synthesis. Optimized for reasoning and complex synthesis. - Task Model (
gemini-2.5-flash): Used for search tasks with grounding enabled. Optimized for speed and web search integration.
Output Structure
When using output_dir, the SDK saves:
output_dir/
├── plan.md # Research plan
├── learning_1.md # First search result
├── learning_2.md # Second search result
├── ...
├── learnings.md # All learnings combined
└── report.md # Final synthesized report
Adding to Letta Agents
1. Add dependency to your Letta Dockerfile
FROM letta/letta:latest
RUN /app/.venv/bin/python3 -m pip install deep-researcher-sdk
Make sure GEMINI_API_KEY is set in your Letta environment.
2. Create a tool file (e.g., deep_research_tool.py)
def deep_research(query: str) -> str:
"""
Conduct deep research on a topic and return a comprehensive report.
Use this tool when you need to research a topic thoroughly before
making recommendations or answering complex questions. The query
should be specific and well-defined.
Args:
query (str): The research topic or question to investigate
Returns:
str: A comprehensive markdown report with findings and sources
"""
from deep_research import research
result = research(query)
return result.report
3. Register and attach to your agent
from letta_client import Letta
client = Letta(base_url="http://localhost:8283")
# Create tool from file
tool = client.tools.create_from_file(filepath="deep_research_tool.py")
# Attach to agent
client.tools.attach_to_agent(agent_id="your-agent-id", tool_id=tool.id)
Requirements
- Python 3.12+
- Google Gemini API key
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deep_researcher_sdk-0.1.1.tar.gz.
File metadata
- Download URL: deep_researcher_sdk-0.1.1.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6d260bb939b04818c72e8a3a3d9998e627233dfd5ad2ada2dbf60796e4e7cb2
|
|
| MD5 |
ee1b2c327743c7ea2a56f52d8b6a758d
|
|
| BLAKE2b-256 |
aa0a9480808d3ceae0fced788506f9826a8d5cdb76eaeddd9d6ba94884682655
|
File details
Details for the file deep_researcher_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deep_researcher_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b9cd8332dfccfb8cf5cfe9da341506e2461b873c17f2ec06137f5171b019580
|
|
| MD5 |
3bb2f4aae1238385228b9480ace7dfa7
|
|
| BLAKE2b-256 |
d4321e3935779d6188cb1afbe2400f84430e70dc6abc99e015dbb7f5c9b47b7b
|