diff --git a/content/cookbook/05-node/56-web-search-agent.mdx b/content/cookbook/05-node/56-web-search-agent.mdx index a724b67dc689..b6390f26a792 100644 --- a/content/cookbook/05-node/56-web-search-agent.mdx +++ b/content/cookbook/05-node/56-web-search-agent.mdx @@ -130,7 +130,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 @@ -193,6 +193,40 @@ const { text } = await generateText({ console.log(text); ``` +#### Perplexity Search + + + Get your API key from the [Perplexity API Keys + page](https://www.perplexity.ai/account/api/keys). + + +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 diff --git a/content/docs/02-foundations/04-tools.mdx b/content/docs/02-foundations/04-tools.mdx index 617d6a22db94..81d20d9c0789 100644 --- a/content/docs/02-foundations/04-tools.mdx +++ b/content/docs/02-foundations/04-tools.mdx @@ -150,6 +150,7 @@ 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. diff --git a/content/tools-registry/registry.ts b/content/tools-registry/registry.ts index 0b1a5c1299fa..4f8b0b2a96f1 100644 --- a/content/tools-registry/registry.ts +++ b/content/tools-registry/registry.ts @@ -118,6 +118,38 @@ 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',