Introduction
This guide shows you how to integrate Tavily with CrewAI to create sophisticated AI agents that can search the web and extract content. By combining CrewAI’s multi-agent framework with Tavily’s real-time web search capabilities, you can build AI systems that research, analyze, and process web information autonomously.Prerequisites
Before you begin, make sure you have:- An OpenAI API key from OpenAI Platform
- A Tavily API key from Tavily Dashboard
Installation
Install the required packages:
Note: The stable python versions to use with CrewAI are Python >=3.10 and Python <3.13 .
Setup
Set up your API keys:Using Tavily Search with CrewAI
CrewAI provides built-in Tavily tools that make it easy to integrate web search capabilities into your AI agents. TheTavilySearchTool allows your agents to search the web for real-time information.
Customizing search tool parameters
Example:query(str): Required. The search query string.search_depth(Literal[“basic”, “advanced”], optional): The depth of the search. Defaults to “basic”.topic(Literal[“general”, “news”, “finance”], optional): The topic to focus the search on. Defaults to “general”.time_range(Literal[“day”, “week”, “month”, “year”], optional): The time range for the search. Defaults to None.max_results(int, optional): The maximum number of search results to return. Defaults to 5.include_domains(Sequence[str], optional): A list of domains to prioritize in the search. Defaults to None.exclude_domains(Sequence[str], optional): A list of domains to exclude from the search. Defaults to None.include_answer(Union[bool, Literal[“basic”, “advanced”]], optional): Whether to include a direct answer synthesized from the search results. Defaults to False.include_raw_content(bool, optional): Whether to include the raw HTML content of the searched pages. Defaults to False.include_images(bool, optional): Whether to include image results. Defaults to False.timeout(int, optional): The request timeout in seconds. Defaults to 60.
Explore More Parameters: For a complete list of available parameters and their descriptions, visit our API documentation to discover all the customization options available for search operations.
Full Code Example - Search
Full Code Example - Search
Using Tavily Extract with CrewAI
TheTavilyExtractorTool allows your CrewAI agents to extract and process content from specific web pages. This is particularly useful for content analysis, data collection, and research tasks.
Customizing extract tool parameters
Example:urls(Union[List[str], str]): Required. A single URL string or a list of URL strings to extract data from.include_images(Optional[bool]): Whether to include images in the extraction results. Defaults to False.extract_depth(Literal[“basic”, “advanced”]): The depth of extraction. Use “basic” for faster, surface-level extraction or “advanced” for more comprehensive extraction. Defaults to “basic”.timeout(int): The maximum time in seconds to wait for the extraction request to complete. Defaults to 60.
Explore More Parameters: For a complete list of available parameters and their descriptions, visit our API documentation to discover all the customization options available for extract operations.
Full Code Example - Extract
Full Code Example - Extract
Using Tavily Research with CrewAI
TheTavilyResearchTool lets your CrewAI agents kick off Tavily research tasks, returning a synthesized, cited report (or a stream of progress events) instead of raw search results. Use it when an agent needs an investigative answer rather than a single web search.
Note: Using theTavilyResearchToolrequires thetavily-pythonlibrary in addition tocrewai-tools. Install it alongside CrewAI tools:
Customizing research tool parameters
Example:input(str): Required. The research task or question to investigate.model(Literal[“mini”, “pro”, “auto”], optional): The Tavily research model."auto"lets Tavily pick;"mini"is faster and cheaper;"pro"is the most capable. Defaults to"auto".output_schema(dict, optional): Optional JSON Schema that structures the research output. Useful when you want strictly typed results. Defaults to None.stream(bool, optional): WhenTrue, the tool returns an iterator of SSE chunks emitting research progress and the final result instead of a single string. Defaults to False.citation_format(Literal[“numbered”, “mla”, “apa”, “chicago”], optional): Citation format for the report. Defaults to"numbered".
Stream research progress
Whenstream=True, the tool returns a generator (or async generator from _arun) of SSE chunks so your application can surface incremental progress:
Structured output via JSON Schema
Pass anoutput_schema when you need a typed result instead of a free-form report:
Explore More Parameters: For a complete list of available parameters and their descriptions, visit our API documentation to discover all the customization options available for research operations.
Full Code Example - Research
Full Code Example - Research