本页还没有译文
本页 26 段还没译成简体中文,下面显示的是英文原文。Tavily research integration
还没翻译译自英文(docs.langchain.com)本页 26 段都还没译
Tavily is a search engine built specifically for AI agents (LLMs), delivering real-time, accurate, and factual results at speed. Tavily offers a Research endpoint that generates comprehensive research reports tailored for LLMs and RAG.
Overview
Integration details
| Class | Package | PY support | Downloads | Version |
|---|---|---|---|---|
TavilyResearch | @langchain/tavily | ✅ |
Tool features
| Returns artifact | Native async | Return data | Pricing |
|---|---|---|---|
| ❌ | ✅ | Research report content, sources, citations | 1,000 free credits / month |
Setup
The integration lives in the @langchain/tavily package:
npm install @langchain/tavily @langchain/coreyarn add @langchain/tavily @langchain/corepnpm add @langchain/tavily @langchain/coreCredentials
Set up an API key on the Tavily dashboard and set it as an environment variable named TAVILY_API_KEY.
process.env.TAVILY_API_KEY = "YOUR_API_KEY";It is also helpful (but not needed) to set up LangSmith for observability:
process.env.LANGSMITH_TRACING = "true";
process.env.LANGSMITH_API_KEY = "your-api-key";Instantiation
You can import and instantiate TavilyResearch like this:
import { TavilyResearch } from "@langchain/tavily";
const tool = new TavilyResearch({
// model: "mini",
// citationFormat: "apa",
// stream: false,
});model(optional): Research agent model."mini","pro", or"auto"(default).citationFormat(optional): Citation format for sources."numbered","mla","apa", or"chicago"(default"numbered").outputSchema(optional): JSON Schema that shapes the research output.stream(optional): Whether to stream research results. Default isfalse.
Invocation
Invoke directly with args
The Tavily research tool accepts the following arguments during invocation:
input(required): The research task or question to investigate- Optional overrides:
model,outputSchema,stream,citationFormat
await tool.invoke({
input: "What are the latest developments in AI?",
});Invoke with ToolCall
You can also invoke the tool with a model-generated ToolCall, in which case a ToolMessage is returned:
// This is usually generated by a model, but we'll create a tool call directly for demo purposes.
const modelGeneratedToolCall = {
args: {
input: "What are the latest developments in AI?",
},
id: "1",
name: tool.name,
type: "tool_call",
};
await tool.invoke(modelGeneratedToolCall);Use within an agent
Pass the research tool to createAgent so the agent can call it with a research task:
import { ChatOpenAI } from "@langchain/openai";
import { TavilyResearch } from "@langchain/tavily";
import { createAgent } from "langchain";
const llm = new ChatOpenAI({
model: "gpt-5.5",
});
const tavilyResearchTool = new TavilyResearch({
model: "mini",
});
const agent = createAgent({
model: llm,
tools: [tavilyResearchTool],
});
const userInput =
"Research the latest developments in AI agents and summarize key trends.";
const stream = await agent.streamEvents(
{ messages: [{ role: "user", content: userInput }] },
{ version: "v3" },
);
await Promise.all([
(async () => {
for await (const message of stream.messages) {
for await (const token of message.text) {
process.stdout.write(token);
}
}
})(),
(async () => {
for await (const call of stream.toolCalls) {
console.dir({ name: call.name, input: call.input }, { depth: null });
await call.output;
}
})(),
]);
await stream.output;API reference
For detailed documentation of all Tavily Research API features and configurations, see the API reference: docs.tavily.com/documentation/api-reference/endpoint/research