Providers
Tavily
The Tavily search API, with an optional generated answer in response metadata and raw page content on request.
- env var
- TAVILY_API_KEY
- auth
- request body
- operations
- search
- results
- 10, up to 20
Address it
import { create, searchProviderDetailed } from "@agntn/web";
const tavily = create("tavily"); // TAVILY_API_KEY
const results = await tavily.search("query", { includeDomains: ["docs.python.org"] });
const answer = await searchProviderDetailed("tavily", "query", { summary: true, fullText: true });
answer.metadata?.answer; // the generated answer for the query
The key goes in the body of a POST to api.tavily.com.
What it reads
| Call | Endpoint |
|---|---|
search | POST /search with max_results, search_depth: "basic", include_answer, include_raw_content |
What comes back
score, publishedDate and, with fullText, text from raw_content. summary asks for the query answer, which lands in response metadata.answer, not on a result. Include and exclude domains work.
Gotchas
- The answer is one string for the whole query, so it lives on the response, not on a result.
search()alone cannot show it,searchDetailed()can. search_depthis alwaysbasic. Advanced depth costs more credits and is not exposed, on purpose.
Where it lives
src/providers/tavily.ts.