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.
pnpm add @perplexity-ai/ai-sdk# Add to your .env filePERPLEXITY_API_KEY=your_api_key_hereimport { generateText, stepCountIs } from 'ai';import { perplexitySearch } from '@perplexity-ai/ai-sdk';
const { text } = await generateText({ model: 'openai/gpt-5.2', prompt: 'What are the latest AI developments? Use search to find current information.', tools: { search: perplexitySearch(), }, stopWhen: stepCountIs(3),});
console.log(text);