Back

gpt-researcher

Use this skill when the user asks to "research background on", "find background information about", "search web for context on", "look up policy history of", "find grey literature on", "research institutional context", "find government reports on", "background research for introduction section", "research country context", "web research on", "autonomous web search", "deep research on", "find sources about", or needs web-sourced background context for academic writing (political economy, comparative politics, economic history, public policy). Complements Zotero/arXiv for web-accessible grey literature and policy documents.

Skyll
77.75 installshaipingxu/social-science-claude-scholar

Add to your agent

curl "https://api.skyll.app/skill/gpt-researcher"
SKILL.md
# GPT Researcher — Academic Research Background Tool

Autonomous deep web research agent for gathering background context, policy documents, grey literature, and institutional history. **Complements** (does not replace) academic literature search via Zotero/arXiv.

## When to Use vs. Other Tools

| Task | Best Tool |
|------|-----------|
| Find recent academic papers | `daily-paper-generator` + Zotero |
| Read and annotate specific papers | `literature-reviewer` agent |
| Institutional/country background | **GPT Researcher** ← this skill |
| Policy documents & reports | **GPT Researcher** ← this skill |
| Local PDF corpus research | **GPT Researcher** ← this skill |
| Historical event context | **GPT Researcher** ← this skill |
| Quantitative data retrieval | Manual (FRED, World Bank API) |

---

## Setup Status (2026-03-14)

| Component | Status | Notes |
|-----------|--------|-------|
| venv | ✅ `/tmp/gptr-env/` (Python 3.11) | Recreate if /tmp cleared: `cd /tmp && ~/.local/bin/uv venv gptr-env --python 3.11 && ~/.local/bin/uv pip install gpt-researcher langchain-anthropic langchain-huggingface sentence-transformers tavily-python --python /tmp/gptr-env/bin/python` |
| TAVILY_API_KEY | ✅ Set in `~/.zshenv` | 1000 searches/month free |
| ANTHROPIC_API_KEY | ⚠️ Not set | Needed for full gpt-researcher autonomous mode; get from console.anthropic.com |

## Two Usage Modes

### Mode A: Tavily Search + Claude Synthesis (Recommended — works now)

```bash
# Run Tavily search
export TAVILY_API_KEY="$(grep TAVILY ~/.zshenv | cut -d'"' -f2)"
/tmp/gptr-env/bin/python ~/.claude/scripts/tavily_search.py "your research query"

# Results are printed + saved to /tmp/tavily_results_TIMESTAMP.md
# Then tell Claude: "Read /tmp/tavily_results_*.md and synthesize a background section"
```

**This is the practical daily workflow** — Tavily finds sources, Claude synthesizes.

### Mode B: Full GPT Researcher (requires ANTHROPIC_API_KEY)

```bash
# First: get API key from console.anthropic.com → API Keys → Create
echo 'export ANTHROPIC_API_KEY="sk-ant-YOUR_KEY"' >> ~/.zshenv
source ~/.zshenv

# Then run with all config:
export SMART_LLM="anthropic:claude-haiku-4-5"
export FAST_LLM="anthropic:claude-haiku-4-5"
export STRATEGIC_LLM="anthropic:claude-haiku-4-5"
export EMBEDDING="huggingface:sentence-transformers/all-MiniLM-L6-v2"
/tmp/gptr-env/bin/python -c "
import asyncio, os
from gpt_researcher import GPTResearcher
async def run():
    r = GPTResearcher(query='YOUR QUERY', report_type='research_report', verbose=False)
    await r.conduct_research()
    print(await r.write_report())
asyncio.run(run())
"
```

Get Tavily key: https://app.tavily.com | Get Anthropic key: https://console.anthropic.com

---

## Core Usage Patterns for Academic Research

### 1. Institutional / Country Background Research

Use for writing Introduction or Case Selection sections:

```python
import asyncio
from gpt_researcher import GPTResearcher

async def research_background(topic: str, output_file: str = "background.md"):
    researcher = GPTResearcher(
        query=topic,
        report_type="research_report",   # 2000+ word detailed report
        report_source="web",
    )
    await researcher.conduct_research()
    report = await researcher.write_report()

    with open(output_file, "w") as f:
        f.write(report)
    print(f"Report saved to {output_file}")
    return report

# Example: Comparative politics case background
asyncio.run(research_background(
    "Political economy of state-business relations in Taiwan 1949-1980: "
    "KMT party structure, land reform, export-led industrialization policy",
    output_file="background/taiwan_political_economy.md"
))
```

### 2. Policy History Research

For policy analysis papers — trace legislative/regulatory history:

```python
asyncio.run(research_background(
    "History of minimum wage legislation in US states 1990-2020: "
    "key policy changes, timing, state-level variation, political context",
    output_file="background/min_wage_policy_history.md"
))
```

### 3. Deep Research (Multi-Level, ~5 min)

For comprehensive literature sweeps — recursively explores subtopics:

```python
async def deep_research(query: str):
    researcher = GPTResearcher(
        query=query,
        report_type="deep",   # recursive tree exploration
    )
    await researcher.conduct_research()
    return await researcher.write_report()

# Good for: economic history, qualitative comparative, mechanism tracing
asyncio.run(deep_research(
    "Causes and consequences of property rights reforms in post-communist Eastern Europe"
))
```

### 4. Local Document Research (PDF Corpus RAG)

Research across your existing PDFs — works with papers, reports, archives:

```python
import os
os.environ["DOC_PATH"] = "./my-papers"  # directory with your PDFs

researcher = GPTResearcher(
    query="How do these papers explain variation in democratic backsliding?",
    report_type="research_report",
    report_source="local",   # searches local docs only
)
await researcher.conduct_research()
report = await researcher.write_report()
```

### 5. Hybrid Search (Web + Local Documents)

```python
researcher = GPTResearcher(
    query="Electoral system reform and party fragmentation: key arguments",
    report_type="research_report",
    report_source="hybrid",   # web + local PDFs combined
)
```

---

## Output Quality & Limitations

**Strengths for academic use:**
- Grey literature (government reports, think tank papers, NGO documents)
- Policy timelines and event chronologies
- Institutional descriptions and organizational histories
- News archives for event documentation
- Finding publicly available datasets and data sources

**Important limitations — always verify:**
- ❌ Cannot access paywalled journals (JSTOR, Elsevier, etc.)
- ❌ Citations may not be in correct academic format → paste into Zotero for cleaning
- ❌ May hallucinate specific statistics or dates → fact-check key claims
- ❌ Not a substitute for systematic literature review
- ✅ Use output as **first draft context**, not final citations

**Recommended workflow:**
1. Run GPT Researcher for background sweep
2. Copy promising sources into Zotero for proper citation
3. Verify key factual claims before including in paper

---

## Integration with Research Workflow

### In Research Ideation Stage
```
research-ideation skill
    └── GPT Researcher: "What is the policy/institutional context of [topic]?"
    └── Output → background.md → feeds Introduction writing
```

### In Paper Writing Stage
```
ml-paper-writing skill (Introduction section)
    └── GPT Researcher: search for grey literature and policy context
    └── Zotero: formal academic citations
    └── Combined → complete Introduction with proper sourcing
```

### Quick One-liner (for simple queries)
```bash
python -c "
import asyncio
from gpt_researcher import GPTResearcher
async def r(q):
    res = GPTResearcher(q, 'research_report')
    await res.conduct_research()
    print(await res.write_report())
asyncio.run(r('$QUERY'))
"
```

---

## Academic Research Query Templates

Copy and adapt these for common research scenarios:

```python
QUERY_TEMPLATES = {
    "case_background": "{country/region} political economy {period}: "
                       "key institutions, major actors, policy trajectory",

    "policy_history":  "History of {policy_area} in {country} {years}: "
                       "legislation timeline, implementation, political context",

    "dataset_discovery": "Available datasets and data sources for {topic}: "
                         "government statistics, panel data, survey data",

    "mechanism_context": "Evidence for {mechanism} in {context}: "
                         "case studies, qualitative evidence, historical examples",

    "lit_gap_scan":    "Recent scholarly debate on {topic}: "
                       "competing arguments, unresolved questions, empirical gaps",
}
```

---

## Reference Resources

- **`references/config-reference.md`** — All configuration options (LLM provider, search depth, output format)
- **`references/deep-research.md`** — Deep research mode settings and cost estimates
- Official docs: https://docs.gptr.dev

References (2)

📎 config-reference.md
# Configuration Reference

## Table of Contents
- [Required Variables](#required-variables)
- [LLM Configuration](#llm-configuration)
- [Provider API Keys](#provider-api-keys)
- [Retriever Configuration](#retriever-configuration)
- [Report Configuration](#report-configuration)
- [Feature Toggles](#feature-toggles)
- [Configuration Priority](#configuration-priority)
- [Example .env](#example-env)

---

## Required Variables

```bash
OPENAI_API_KEY=sk-...          # Or another LLM provider key
TAVILY_API_KEY=tvly-...        # Or another retriever key
```

---

## LLM Configuration

```bash
LLM_PROVIDER=openai            # openai, anthropic, google, groq, together, etc.
FAST_LLM=gpt-4o-mini           # Quick tasks (summarization)
SMART_LLM=gpt-4o               # Complex reasoning (report writing)
STRATEGIC_LLM=o3-mini          # Planning (agent selection)
TEMPERATURE=0.4                # 0.0-1.0
MAX_TOKENS=4000
REASONING_EFFORT=medium        # For o-series: low, medium, high
```

---

## Provider API Keys

```bash
# OpenAI
OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://api.openai.com/v1

# Anthropic
ANTHROPIC_API_KEY=sk-ant-...

# Google
GOOGLE_API_KEY=AIza...

# Groq
GROQ_API_KEY=gsk_...

# Azure OpenAI
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
```

---

## Retriever Configuration

```bash
RETRIEVER=tavily               # Single or comma-separated: tavily,google,mcp
MAX_SEARCH_RESULTS_PER_QUERY=5
MAX_URLS_TO_SCRAPE=10
SIMILARITY_THRESHOLD=0.42
```

### Retriever API Keys

```bash
TAVILY_API_KEY=tvly-...
GOOGLE_API_KEY=AIza...
GOOGLE_CX_KEY=...
BING_API_KEY=...
SERPER_API_KEY=...
SERPAPI_API_KEY=...
EXA_API_KEY=...
```

---

## Report Configuration

```bash
REPORT_FORMAT=apa              # apa, mla, chicago, harvard, ieee
TOTAL_WORDS=1000
LANGUAGE=english
CURATE_SOURCES=true
```

---

## Feature Toggles

### Image Generation

```bash
IMAGE_GENERATION_ENABLED=true
GOOGLE_API_KEY=AIza...
IMAGE_GENERATION_MODEL=models/gemini-2.5-flash-image
IMAGE_GENERATION_MAX_IMAGES=3
IMAGE_GENERATION_STYLE=dark    # dark, light, auto
```

### Deep Research

```bash
DEEP_RESEARCH_BREADTH=4        # Subtopics per level
DEEP_RESEARCH_DEPTH=2          # Recursion levels
DEEP_RESEARCH_CONCURRENCY=2    # Parallel tasks
```

### MCP

```bash
MCP_STRATEGY=fast              # fast, deep, disabled
```

### Local Documents

```bash
DOC_PATH=./my-docs
# Supports: PDF, DOCX, TXT, CSV, XLSX, PPTX, MD
```

### Server

```bash
HOST=0.0.0.0
PORT=8000
VERBOSE=true
```

---

## Configuration Priority

```
Environment Variables (highest)
        ↓
JSON Config File (if provided)
        ↓
Default Values (lowest)
```

**Important:** Config keys are lowercased when accessed:

```python
# In default.py: "SMART_LLM": "gpt-4o"
# Access as: self.cfg.smart_llm  # lowercase!
```

---

## Example .env

```bash
# Required
OPENAI_API_KEY=sk-your-key
TAVILY_API_KEY=tvly-your-key

# LLM
FAST_LLM=gpt-4o-mini
SMART_LLM=gpt-4o

# Report
TOTAL_WORDS=1000
LANGUAGE=english

# Optional: Images
IMAGE_GENERATION_ENABLED=true
GOOGLE_API_KEY=AIza-your-key
IMAGE_GENERATION_STYLE=dark
```
📎 deep-research.md
# Deep Research Mode Reference

## Table of Contents
- [Overview](#overview)
- [Configuration](#configuration)
- [DeepResearchSkill](#deepresearchskill)
- [Usage](#usage)

---

## Overview

Deep Research uses recursive tree-like exploration with configurable depth and breadth.

---

## Configuration

```bash
DEEP_RESEARCH_BREADTH=4    # Subtopics per level
DEEP_RESEARCH_DEPTH=2      # Recursion levels
DEEP_RESEARCH_CONCURRENCY=2  # Parallel tasks
```

---

## DeepResearchSkill

**File:** `gpt_researcher/skills/deep_research.py`

```python
class DeepResearchSkill:
    def __init__(self, researcher):
        self.researcher = researcher
        self.breadth = getattr(researcher.cfg, 'deep_research_breadth', 4)
        self.depth = getattr(researcher.cfg, 'deep_research_depth', 2)
        self.concurrency_limit = getattr(researcher.cfg, 'deep_research_concurrency', 2)
        self.learnings = []
        self.research_sources = []
        self.context = []

    async def deep_research(self, query: str, on_progress=None) -> str:
        """
        Recursive research with depth and breadth.
        
        1. Research main topic
        2. Generate subtopics (breadth)
        3. For each subtopic, recursively research (depth)
        4. Aggregate all findings
        5. Generate comprehensive report
        """
```

---

## Usage

```python
researcher = GPTResearcher(
    query="Comprehensive analysis of quantum computing",
    report_type="deep",  # Triggers deep research
)
await researcher.conduct_research()
report = await researcher.write_report()
```

### Research Tree Structure

```
Query: "Quantum Computing"
├── Subtopic 1: Hardware (depth 1)
│   ├── Subtopic 1.1: Superconducting qubits (depth 2)
│   └── Subtopic 1.2: Ion traps (depth 2)
├── Subtopic 2: Algorithms (depth 1)
│   ├── Subtopic 2.1: Shor's algorithm (depth 2)
│   └── Subtopic 2.2: Grover's algorithm (depth 2)
├── Subtopic 3: Applications (depth 1)
│   └── ...
└── Subtopic 4: Challenges (depth 1)
    └── ...
```

With `DEEP_RESEARCH_BREADTH=4` and `DEEP_RESEARCH_DEPTH=2`, this explores 4 subtopics at each level, going 2 levels deep.
gpt-researcher - Skyll