A simple research agent built with GPT Researcher that provides comprehensive research reports through an easy-to-use web interface.
- 🔍 Automated Research: Conducts thorough research on any topic using multiple web sources
- 📝 Multiple Report Types: Generate research reports, resource lists, or outlines
- 🌐 Web Interface: Simple, clean HTML interface with no dependencies
- ⚡ Fast Results: Get comprehensive reports in minutes
- 📊 Source Tracking: See all sources used and research costs
- 🚀 Easy Setup: Minimal configuration required
- Python 3.11 or later
- OpenAI API key
- Tavily API key (for web search)
# Clone the repository
git clone <your-repo-url>
cd research-agent-example
# Install dependencies
pip install -r requirements.txt
You need two API keys:
- OpenAI API Key: Get from https://platform.openai.com/api-keys
- Tavily API Key: Get from https://tavily.com/ (free tier available)
Set them as environment variables:
# Option 1: Export in terminal
export OPENAI_API_KEY="your_openai_api_key_here"
export TAVILY_API_KEY="your_tavily_api_key_here"
# Option 2: Create a .env file
echo "OPENAI_API_KEY=your_openai_api_key_here" >> .env
echo "TAVILY_API_KEY=your_tavily_api_key_here" >> .env
python server.py
The server will start at http://localhost:8000
- Open your browser and go to
http://localhost:8000
- Enter your research query (e.g., "Latest developments in quantum computing")
- Select the report type:
- Research Report: Comprehensive analysis with citations
- Resource Report: List of relevant resources and links
- Outline Report: Structured outline for the topic
- Click "Start Research" and wait for results
research-agent-example/
├── server.py # FastAPI backend server
├── static/
│ └── index.html # Web interface
├── requirements.txt # Python dependencies
├── env_setup.txt # Environment setup guide
└── README.md # This file
GET /
- Serves the web interfacePOST /research
- Conducts research and returns reportGET /health
- Health check and API key status
curl -X POST "http://localhost:8000/research" \
-H "Content-Type: application/json" \
-d '{
"query": "What are the latest AI trends?",
"report_type": "research_report"
}'
Response:
{
"report": "# Research Report\n\n...",
"sources": ["https://...", "https://..."],
"costs": {
"total_cost": 0.1234,
"total_tokens": 5678
},
"num_sources": 15
}
The research agent uses GPT-4 models by default. Average research:
- Takes ~3 minutes to complete
- Costs ~$0.10 per research task
- Analyzes 20+ web sources
- Ensure both
OPENAI_API_KEY
andTAVILY_API_KEY
are set - Check the
/health
endpoint to verify configuration
- Complex topics may take 3-5 minutes
- The agent is gathering information from multiple sources
- Ensure your query is specific enough
- Try using "Research Report" type for comprehensive results
- Never commit API keys to version control
- Add
.env
to your.gitignore
file - Use environment variables or secure key management in production
- GPT Researcher Documentation
- GPT Researcher GitHub
- OpenAI API Documentation
- Tavily API Documentation
This example is provided as-is for educational purposes.