langchain.js
    Preparing search index...

    Tavily search API tool integration. (Deprecated)

    Please use the TavilySearch tool from the @langchain/tavily package, instead.

    Setup: Install @langchain/community. You'll also need an API key set as TAVILY_API_KEY.

    npm install @langchain/community
    
    Instantiate
    import { TavilySearchResults } from "@langchain/community/tools/tavily_search";

    const tool = new TavilySearchResults({
    maxResults: 2,
    // ...
    });

    Invocation
    await tool.invoke("what is the current weather in sf?");
    

    Invocation with tool call
    // This is usually generated by a model, but we'll create a tool call directly for demo purposes.
    const modelGeneratedToolCall = {
    args: {
    input: "what is the current weather in sf?",
    },
    id: "tool_call_id",
    name: tool.name,
    type: "tool_call",
    };
    await tool.invoke(modelGeneratedToolCall);
    ToolMessage {
      "content": "...",
      "name": "tavily_search_results_json",
      "additional_kwargs": {},
      "response_metadata": {},
      "tool_call_id": "tool_call_id"
    }
    

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • Optionalfields: any

      Returns TavilySearchResults

    Properties

    apiKey?: string
    apiUrl?: string
    days?: number
    description: string = "A search engine optimized for comprehensive, accurate, and trusted results. Useful for when you need to answer questions about current events. Input should be a search query."
    excludeDomains?: string[]
    includeAnswer?: boolean
    includeDomains?: string[]
    includeImageDescriptions?: boolean
    includeImages?: boolean
    includeRawContent?: boolean
    kwargs: Record<string, unknown> = {}
    maxResults: number = 5
    name: string = "tavily_search_results_json"
    searchDepth?: "basic" | "deep"
    topic?: string

    Methods

    • Parameters

      • input: string
      • Optional_runManager: any

      Returns Promise<string>

    • Returns string