Skip to main content

Installation

Install the required packages:

Setup

Set up your API keys:

Using Tavily with Anthropic tool calling

Implementation

System prompt

Define a system prompt to guide Claude’s behavior:

Tool schema

Define the Tavily search tool for Claude with enhanced parameters:
Scroll to the bottom to find the full json schema for search, extract, map and crawl

Tool execution

Create optimized functions to handle Tavily searches:

Main chat function

The main function that handles the two-step conversation with Claude:

Usage example

Tavily endpoints schema for Anthropic tool definition

Note: When using these schemas, you can customize which parameters are exposed to the model based on your specific use case. For example, if you are building a finance application, you might set topic: "finance" for all queries without exposing the topic parameter. This way, the LLM can focus on deciding other parameters, such as time_range, country, and so on, based on the user’s request. Feel free to modify these schemas as needed and only pass the parameters that are relevant to your application.
API Format: The schemas below are for Anthropic’s tool format. Each tool uses the input_schema structure with type, properties, and required fields.
For more information about Tavily’s capabilities, check out our API documentation and best practices.