WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion content/cookbook/05-node/56-web-search-agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Unlike the native web search examples where searching is built into the model, u

### Use ready-made tools

If you prefer a ready-to-use web search tool without building one from scratch, [Exa](https://exa.ai/)(a web search API designed for AI applications) provides a tool that integrates directly with the AI SDK.
If you prefer a ready-to-use web search tool without building one from scratch, there are several options that integrate directly with the AI SDK.

#### Exa

Expand Down Expand Up @@ -161,6 +161,73 @@ const { text } = await generateText({
console.log(text);
```

#### Perplexity Search

<Note>
Get your API key from the [Perplexity API Keys
page](https://www.perplexity.ai/account/api/keys).
</Note>

First, install the Perplexity Search tool:

```bash
pnpm install @perplexity-ai/ai-sdk
```

Then, you can import and pass it into `generateText`, `streamText`, or your agent. Perplexity Search provides real-time web search with advanced filtering options including domain, language, date range, and recency filters:

```ts
import { generateText, stepCountIs } from 'ai';
import { perplexitySearch } from '@perplexity-ai/ai-sdk';

const { text } = await generateText({
model: 'anthropic/claude-sonnet-4-5',
prompt:
'What are the latest AI developments? Use search to find current information.',
tools: {
search: perplexitySearch(),
},
stopWhen: stepCountIs(3),
});

console.log(text);
```

For more configuration options and customization, see the [Perplexity Search API documentation](https://docs.perplexity.ai/guides/search-quickstart).

#### Tavily

<Note>
Get your API key from the [Tavily Dashboard](https://app.tavily.com).
</Note>

First, install the `tavilySearch` tool:

```bash
pnpm install @tavily/ai-sdk
```

Then, you can import and pass it into `generateText`, `streamText`, or your agent:

```ts
import { generateText, stepCountIs } from 'ai';
import { tavilySearch, tavilyExtract } from '@tavily/ai-sdk';

const { text } = await generateText({
model: 'anthropic/claude-sonnet-4.5',
prompt: 'When was the latest update to the AI SDK?',
tools: {
webSearch: tavilySearch(),
webExtract: tavilyExtract(),
},
stopWhen: stepCountIs(3),
});

console.log(text);
```

For more customization options over your agent's web-access functionality, visit the [Tavily AI SDK Documentation](https://docs.tavily.com/documentation/integrations/vercel).

### Build and use custom tools

For more control over your web search functionality, you can build custom tools using web scraping and crawling APIs. This approach allows you to customize search parameters, handle specific data formats, and integrate with specialized search services.
Expand Down
2 changes: 2 additions & 0 deletions content/docs/02-foundations/04-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ These packages provide pre-built tools you can install and use immediately:

- **[@exalabs/ai-sdk](https://www.npmjs.com/package/@exalabs/ai-sdk)** - Web search tool that lets AI search the web and get real-time information.
- **[@parallel-web/ai-sdk-tools](https://www.npmjs.com/package/@parallel-web/ai-sdk-tools)** - Web search and extract tools powered by Parallel Web API for real-time information and content extraction.
- **[@perplexity-ai/ai-sdk](https://www.npmjs.com/package/@perplexity-ai/ai-sdk)** - Search the web with real-time results and advanced filtering powered by Perplexity's Search API.
- **[@tavily/ai-sdk](https://www.npmjs.com/package/@tavily/ai-sdk)** - Search, extract, crawl, and map tools for enterprise-grade agents to explore the web in real-time.
- **[Stripe agent tools](https://docs.stripe.com/agents?framework=vercel)** - Tools for interacting with Stripe.
- **[StackOne ToolSet](https://docs.stackone.com/agents/typescript/frameworks/vercel-ai-sdk)** - Agentic integrations for hundreds of [enterprise SaaS](https://www.stackone.com/integrations) platforms.
- **[agentic](https://docs.agentic.so/marketplace/ts-sdks/ai-sdk)** - A collection of 20+ tools that connect to external APIs such as [Exa](https://exa.ai/) or [E2B](https://e2b.dev/).
Expand Down
64 changes: 64 additions & 0 deletions content/tools-registry/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,70 @@ console.log(text);`,
websiteUrl: 'https://parallel.ai',
npmUrl: 'https://www.npmjs.com/package/@parallel-web/ai-sdk-tools',
},
{
slug: 'perplexity-search',
name: 'Perplexity Search',
description:
"Search the web with real-time results and advanced filtering powered by Perplexity's Search API. Provides ranked search results with domain, language, date range, and recency filters. Supports multi-query searches and regional search results.",
packageName: '@perplexity-ai/ai-sdk',
tags: ['search', 'web'],
apiKeyEnvName: 'PERPLEXITY_API_KEY',
installCommand: {
pnpm: 'pnpm install @perplexity-ai/ai-sdk',
npm: 'npm install @perplexity-ai/ai-sdk',
yarn: 'yarn add @perplexity-ai/ai-sdk',
bun: 'bun add @perplexity-ai/ai-sdk',
},
codeExample: `import { generateText, gateway, stepCountIs } from 'ai';
import { perplexitySearch } from '@perplexity-ai/ai-sdk';

const { text } = await generateText({
model: gateway('openai/gpt-4o-mini'),
prompt: 'What are the latest AI developments? Use search to find current information.',
tools: {
search: perplexitySearch(),
},
stopWhen: stepCountIs(3),
});

console.log(text);`,
docsUrl: 'https://docs.perplexity.ai/guides/search-quickstart',
apiKeyUrl: 'https://www.perplexity.ai/account/api/keys',
websiteUrl: 'https://www.perplexity.ai',
npmUrl: 'https://www.npmjs.com/package/@perplexity-ai/ai-sdk',
},
{
slug: 'tavily',
name: 'Tavily',
description:
'Tavily is a web intelligence platform offering real-time web search optimized for AI applications. Tavily provides comprehensive web research capabilities including search, content extraction, website crawling, and site mapping to power AI agents with current information.',
packageName: '@tavily/ai-sdk',
tags: ['search', 'extract', 'crawl'],
apiKeyEnvName: 'TAVILY_API_KEY',
installCommand: {
pnpm: 'pnpm install @tavily/ai-sdk',
npm: 'npm install @tavily/ai-sdk',
yarn: 'yarn add @tavily/ai-sdk',
bun: 'bun add @tavily/ai-sdk',
},
codeExample: `import { generateText, gateway, stepCountIs } from 'ai';
import { tavilySearch } from '@tavily/ai-sdk';

const { text } = await generateText({
model: gateway('google/gemini-3-pro-preview'),
prompt: 'What are the latest developments in agentic search?',
tools: {
webSearch: tavilySearch,
Comment on lines +168 to +174
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { tavilySearch } from '@tavily/ai-sdk';
const { text } = await generateText({
model: gateway('google/gemini-3-pro-preview'),
prompt: 'What are the latest developments in agentic search?',
tools: {
webSearch: tavilySearch,
import { tavilySearch, tavilyExtract } from '@tavily/ai-sdk';
const { text } = await generateText({
model: gateway('google/gemini-3-pro-preview'),
prompt: 'What are the latest developments in agentic search?',
tools: {
webSearch: tavilySearch(),
webExtract: tavilyExtract(),

The Tavily code example in the registry is incomplete - it only demonstrates using tavilySearch without parentheses, while the corresponding cookbook example shows using both tavilySearch() and tavilyExtract() with parentheses.

View Details

Analysis

Tavily code example in registry is incomplete and uses incorrect function syntax

What fails: The registry example for Tavily (lines ~167-179 in content/tools-registry/registry.ts) shows webSearch: tavilySearch without parentheses and only demonstrates the search tool, missing the extract tool entirely. The cookbook shows both tools should be used with function invocation.

How to reproduce: Look at the Tavily entry in content/tools-registry/registry.ts:

tools: {
  webSearch: tavilySearch,  // Missing parentheses, wrong syntax
}

Compare to cookbook example in content/cookbook/05-node/56-web-search-agent.mdx:

tools: {
  webSearch: tavilySearch(),      // Correct
  webExtract: tavilyExtract(),    // Complete example
}

Result: The registry example shows incorrect syntax that won't work - tavilySearch without parentheses passes the function reference instead of calling it to return the configured tool instance. Also missing tavilyExtract from the example.

Expected: According to official Tavily documentation, both functions must be called with parentheses: tavilySearch() and tavilyExtract(). The registry should demonstrate both available tools like the cookbook does.

Changes made: Updated the Tavily entry to:

  1. Import both tavilySearch and tavilyExtract
  2. Call both functions with parentheses: tavilySearch() and tavilyExtract()
  3. Now matches cookbook example and follows consistent pattern with other tools in registry (Exa, Perplexity)

},
stopWhen: stepCountIs(3),
});

console.log(text);`,
docsUrl: 'https://docs.tavily.com/documentation/integrations/vercel',
apiKeyUrl: 'https://app.tavily.com/home',
websiteUrl: 'https://tavily.com',
npmUrl: 'https://www.npmjs.com/package/@tavily/ai-sdk',
},
{
slug: 'firecrawl',
name: 'Firecrawl',
Expand Down
Loading