This project includes TWO versions of the Deep Research Agent. Here's how they compare:
Files:
deep_research_agent.pyconfig.pymain.pyexample_run.py
Architecture:
User Input
↓
Tavily Search API (4+ queries per section)
↓ (Returns 12+ web sources)
Format & Structure Context
↓
Gemini 2.5 LLM (Analyzes & Synthesizes)
↓
Research Report
How it works:
- Tavily searches the web with targeted queries
- Raw search results are formatted into context
- Gemini receives context and analyzes it
- Output includes citations from Tavily sources
Pros: ✅ Explicit control over search queries and sources ✅ Transparent - see exactly what sources were used ✅ Cost-effective - Gemini is cheaper, Tavily has free tier ✅ Modular - can swap search provider or LLM independently ✅ Better for compliance - control what sources are accessed
Cons: ❌ Two APIs required - More setup (Gemini + Tavily keys) ❌ More code - Manual orchestration of search + analysis ❌ Slower - Multiple sequential API calls per section
Best for:
- Production systems needing audit trails
- Cost-sensitive applications
- When you need control over data sources
- Compliance-heavy environments
Files:
deep_research_agent_openai.pyconfig_openai.pymain_openai.pyexample_run_openai.py
Architecture:
User Input
↓
OpenAI GPT-4o (handles search + analysis internally)
↓
Research Report
How it works:
- Single prompt to OpenAI GPT-4o
- OpenAI handles web search internally (built-in browsing)
- Analysis and synthesis done in same call
- Output includes citations from sources OpenAI found
Pros: ✅ Simpler setup - Only one API key needed ✅ Faster - Single API call per section ✅ Less code - OpenAI handles orchestration internally ✅ Potentially better quality - GPT-4o is very powerful ✅ More autonomous - Let OpenAI decide what to search
Cons: ❌ Less control - Can't see/control what OpenAI searches ❌ More expensive - GPT-4o costs more than Gemini 2.5 ❌ Black box - Don't know search strategy used ❌ Single vendor lock-in - Can't swap components
Best for:
- Quick prototypes and demos
- When you trust OpenAI's search capabilities
- Simpler deployment scenarios
- When development speed > cost
| Feature | Gemini + Tavily | OpenAI |
|---|---|---|
| API Keys Required | 2 (Gemini + Tavily) | 1 (OpenAI) |
| Cost (per report) | ~$0.10-0.30 | ~$0.50-1.00 |
| Speed | Slower (multiple calls) | Faster (single call) |
| Search Control | Full control | No control |
| Source Transparency | High (see all sources) | Medium (cites sources) |
| Code Complexity | Higher (manual RAG) | Lower (integrated) |
| Vendor Lock-in | Low (modular) | High (all OpenAI) |
| Quality | Excellent | Excellent |
| Free Tier | Yes (Tavily 1000/mo) | No |
- 🏢 Building for production/enterprise
- 💰 Budget-conscious or need free tier
- 🔍 Need audit trail of sources
- 🔒 Compliance requirements around data access
- 🔧 Want to customize search strategy
- 📊 Need to control what gets searched
- 🚀 Building quick POC/demo
- ⚡ Need fastest development time
- 🤝 Already using OpenAI ecosystem
- 🎯 Trust OpenAI's search judgment
- 💡 Want simplest architecture
- 📈 Quality > cost
# Setup
export GOOGLE_API_KEY="your_gemini_key"
export TAVILY_API_KEY="your_tavily_key"
# Run
python example_run.py
# or
python main.py --company "Bizzi" --sector "SaaS" --region "Vietnam" --website "https://bizzi.vn/en/"# Setup
export OPENAI_API_KEY="your_openai_key"
# Run
python example_run_openai.py
# or
python main_openai.py --company "Bizzi" --sector "SaaS" --region "Vietnam" --website "https://bizzi.vn/en/"Retrieval-Augmented Generation (RAG):
- Explicit separation of retrieval (Tavily) and generation (Gemini)
- You control the retrieval logic
- Context is assembled manually
- Classic RAG architecture
Code Structure:
# 1. Search with Tavily
results = tavily_client.search(query)
# 2. Format results
context = format_search_results(results)
# 3. Analyze with Gemini
response = gemini.invoke([
SystemMessage("You are an analyst..."),
HumanMessage(f"Context: {context}\n\nAnalyze...")
])Agent with Tools:
- OpenAI acts as agent with built-in search tool
- Internal orchestration of search
- Single unified call
- Agentic architecture
Code Structure:
# Single call - OpenAI handles search internally
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "user",
"content": "Research X and analyze Y..."
}]
)For this POC: Start with OpenAI version for fastest results, then migrate to Gemini + Tavily if:
- You need cost optimization
- Compliance requires audit trails
- You want more control
For production: Use Gemini + Tavily for enterprise-grade solution with transparency and control.
Try both and see which fits your needs better. All files are included in this repo.