searchweb

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.

Installation

pnpm
npm
yarn
bun
pnpm install @perplexity-ai/ai-sdk
# Add to your .env file
PERPLEXITY_API_KEY=your_api_key_here

Usage

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);