Skip to content

zidane/tools/web-search

The opt-in web_search tool, with Tavily, Brave or DuckDuckGo as the backend.

import { … } from 'zidane/tools/web-search'src/tools/web-search.ts

Use webSearch when the agent needs current information from the web. It is not in zidane/tools, so a code-only agent has no network search by default. Each call picks the backend: Tavily when TAVILY_API_KEY is set, then Brave when BRAVE_SEARCH_API_KEY is set, then a keyless DuckDuckGo fallback. DuckDuckGo limits the request rate, and its HTML page can change. Pair it with fetchUrl to read the pages it finds.

TypeScript
import { createAgent } from 'zidane'
import { anthropic } from 'zidane/providers/anthropic'
import { webSearch } from 'zidane/tools/web-search'

const agent = createAgent({ provider: anthropic(), tools: { web_search: webSearch } })
const stats = await agent.run({ prompt: 'Find the latest stable Bun release and its date.' })
console.log(stats.turns)

Constants#

webSearchConstant#

The web_search tool. Searches the web through the configured backend and returns titles, URLs and snippets.

TypeScript
const webSearch: ToolDef

src/tools/web-search.ts:207