# zidane/tools/web-search

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

Import: `import { … } from 'zidane/tools/web-search'`. Source: [src/tools/web-search.ts](https://github.com/Tahul/zidane/blob/main/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`](https://zidane.si/docs/reference/tools-fetch-url.md) to read the pages it finds.

```ts
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

### `webSearch`

Constant.

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

```ts
const webSearch: ToolDef
```

Source: [src/tools/web-search.ts:207](https://github.com/Tahul/zidane/blob/main/src/tools/web-search.ts#L207)
