Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Production-ready Tavily API integration patterns for search, extract, crawl, map, and research in Python and JavaScript.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/research.md
1# Research API Reference23## Table of Contents45- [Overview](#overview)6- [Prompting Best Practices](#prompting-best-practices)7- [Model Selection](#model-selection)8- [Key Parameters](#key-parameters)9- [Basic Usage](#basic-usage)10- [Streaming vs Polling](#streaming-vs-polling)11- [Structured Output vs Report](#structured-output-vs-report)12- [Response Fields](#response-fields)13- [Summary](#summary)1415---1617## Overview1819The Research API conducts comprehensive research on any topic with automatic source gathering, analysis, and response generation with citations. It's an end-to-end solution when you need AI-powered research without building your own pipeline.2021---2223## Prompting Best Practices2425Define a **clear goal** with all **details** and **direction**.2627**Guidelines:**28- **Be specific when you can.** Include known details: target market, competitors, geography, constraints29- **Stay open-ended only for discovery.** Make it explicit: "tell me about the most impactful AI innovations in healthcare in 2025"30- **Avoid contradictions.** Don't include conflicting constraints or goals31- **Share what's already known.** Include prior assumptions so research doesn't repeat existing knowledge32- **Keep prompts clean and directed.** Clear task + essential context + desired output format3334### Example Queries3536**Company research:**37```38Research the company ____ and its 2026 outlook. Provide a brief overview39of the company, its products, services, and market position.40```4142**Competitive analysis:**43```44Conduct a competitive analysis of ____ in 2026. Identify their main45competitors, compare market positioning, and analyze key differentiators.46```4748**With prior context:**49```50We're evaluating Notion as a potential partner. We already know they51primarily serve SMB and mid-market teams, expanded their AI features52significantly in 2025, and most often compete with Confluence and ClickUp.53Research Notion's 2026 outlook, including market position, growth risks,54and where a partnership could be most valuable. Include citations.55```5657---5859## Model Selection6061| Model | Best For |62|-------|----------|63| `pro` | Comprehensive, multi-agent research for complex, multi-domain topics |64| `mini` | Targeted, efficient research for narrow or well-scoped questions |65| `auto` | When unsure how complex research will be (default) |6667### Pro Model6869Multi-agent research suited for complex topics spanning multiple subtopics or domains. Use for deeper analysis, thorough reports, or maximum accuracy.7071```python72result = client.research(73input="Analyze the competitive landscape for ____ in the SMB market, "74"including key competitors, positioning, pricing models, customer "75"segments, recent product moves, and defensible advantages or risks "76"over the next 2-3 years.",77model="pro"78)79```8081### Mini Model8283Optimized for targeted, efficient research. Best for narrow or well-scoped questions where you still benefit from agentic searching and synthesis.8485```python86result = client.research(87input="What are the top 5 competitors to ____ in the SMB market, and how do they differentiate?",88model="mini"89)90```9192---9394## Key Parameters9596### research()9798| Parameter | Type | Default | Description |99|-----------|------|---------|-------------|100| `input` | string | Required | The research topic or question |101| `model` | enum | `"auto"` | `"mini"`, `"pro"`, or `"auto"` |102| `stream` | boolean | false | Enable streaming responses |103| `output_schema` | object | null | JSON Schema for structured output |104| `citation_format` | enum | `"numbered"` | `"numbered"`, `"mla"`, `"apa"`, `"chicago"` |105106### get_research()107108| Parameter | Type | Description |109|-----------|------|-------------|110| `request_id` | string | Task ID from `research()` response |111112---113114## Basic Usage115116Research tasks are two-step: initiate with `research()`, retrieve with `get_research()`.117118```python119import time120from tavily import TavilyClient121122client = TavilyClient()123124# Step 1: Start research task125result = client.research(126input="Latest developments in quantum computing and their practical applications",127model="pro"128)129request_id = result["request_id"]130131# Step 2: Poll until completed132response = client.get_research(request_id)133while response["status"] not in ["completed", "failed"]:134print(f"Status: {response['status']}... polling again in 10 seconds")135time.sleep(10)136response = client.get_research(request_id)137138# Step 3: Handle result139if response["status"] == "failed":140raise RuntimeError(f"Research failed: {response.get('error', 'Unknown error')}")141142report = response["content"]143sources = response["sources"]144```145146---147148## Streaming vs Polling149150**Streaming** — Best for user interfaces where you want real-time updates.151**Polling** — Best for background processes where you check status periodically.152153### Streaming154155Enable real-time progress monitoring with `stream=True`.156157```python158stream = client.research(159input="Latest developments in quantum computing",160model="pro",161stream=True162)163164for chunk in stream:165print(chunk.decode('utf-8'))166```167168### Event Types169170| Event Type | Description |171|------------|-------------|172| **Tool Call** | Agent initiates action (Planning, WebSearch, etc.) |173| **Tool Response** | Results after tool execution with sources |174| **Content** | Research report streamed as markdown (or JSON with `output_schema`) |175| **Sources** | Complete list of sources, emitted after content |176| **Done** | Signals completion |177178### Tool Types179180| Tool | Description | Models |181|------|-------------|--------|182| `Planning` | Initializes research strategy | mini, pro |183| `WebSearch` | Executes web searches | mini, pro |184| `Generating` | Creates final report | mini, pro |185| `ResearchSubtopic` | Deep research on subtopics | pro only |186187### Typical Flow1881891. `Planning` tool_call → tool_response1902. `WebSearch` tool_call → tool_response (with sources)1913. `ResearchSubtopic` cycles (Pro mode only)1924. `Generating` tool_call → tool_response1935. `Content` chunks (markdown or structured JSON)1946. `Sources` event1957. `Done` event196197See [streaming cookbook](https://github.com/tavily-ai/tavily-cookbook/blob/main/cookbooks/research/streaming.ipynb) and [polling cookbook](https://github.com/tavily-ai/tavily-cookbook/blob/main/cookbooks/research/polling.ipynb) for complete examples.198199---200201## Structured Output vs. Report202203| Format | Best For |204|--------|----------|205| **Report** (default) | Reading, sharing, or displaying verbatim (chat interfaces, briefs, newsletters) |206| **Structured Output** | Data enrichment, pipelines, or powering UIs with specific fields |207208## Structured Output209210Use `output_schema` to receive research in a predefined JSON structure.211212```python213schema = {214"properties": {215"summary": {216"type": "string",217"description": "Executive summary of findings"218},219"key_points": {220"type": "array",221"items": {"type": "string"},222"description": "Main takeaways from the research"223},224"metrics": {225"type": "object",226"properties": {227"market_size": {"type": "string", "description": "Total market size"},228"growth_rate": {"type": "number", "description": "Annual growth percentage"}229}230}231},232"required": ["summary", "key_points"]233}234235result = client.research(236input="Electric vehicle market analysis 2024",237output_schema=schema238)239```240241### Schema Best Practices242243- **Write clear field descriptions.** 1-3 sentences explaining what the field should contain244- **Match the structure you need.** Use arrays, objects, enums appropriately (e.g., `competitors: string[]`, not `"A, B, C"`)245- **Avoid duplicate fields.** Keep each field unique and specific246- **Use `required` arrays** to enforce mandatory fields at any nesting level247248**Supported types:** `object`, `string`, `integer`, `number`, `array`249250### Streaming with Structured Output251252When `output_schema` is provided, content arrives as structured JSON:253254```python255stream = client.research(256input="AI agent frameworks comparison",257model="mini",258stream=True,259output_schema={260"properties": {261"summary": {"type": "string", "description": "Executive summary"},262"key_points": {"type": "array", "items": {"type": "string"}}263},264"required": ["summary", "key_points"]265}266)267268for chunk in stream:269data = chunk.decode('utf-8')270print(data) # Content chunks will be structured JSON271```272273---274275## Response Fields276277### research() Response278279| Field | Description |280|-------|-------------|281| `request_id` | Unique identifier for tracking |282| `created_at` | Timestamp when task was created |283| `status` | Initial status |284| `input` | The research topic submitted |285| `model` | Model used by research agent |286287### get_research() Response288289| Field | Description |290|-------|-------------|291| `status` | `"pending"`, `"processing"`, `"completed"`, `"failed"` |292| `content` | Generated research report (when completed) |293| `sources` | Array of source citations |294| `response_time` | Time in seconds |295296### Source Object297298| Field | Description |299|-------|-------------|300| `url` | Source URL |301| `title` | Source title |302| `citation` | Formatted citation string |303304---305306## Summary3073081. **Be specific in prompts** — Include known details: target market, competitors, geography, constraints3092. **Share prior context** — Include what you already know to avoid repetition3103. **Choose the right model** — `mini` for focused queries, `pro` for comprehensive multi-domain analysis3114. **Use streaming for UX** — Display real-time progress during long research tasks3125. **Use structured output for pipelines** — Define schemas for consistent, parseable responses3136. **Use reports for reading** — Default format is best for chat interfaces and sharing314315For more examples, see the [Tavily Cookbook](https://github.com/tavily-ai/tavily-cookbook/tree/main/research) and [live demo](https://chat-research.tavily.com/).316