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 add @perplexity-ai/ai-sdk
# Add to your .env file
PERPLEXITY_API_KEY=your_api_key_here

Usage

import { generateText, isStepCount } from 'ai';
import { perplexitySearch } from '@perplexity-ai/ai-sdk';

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

console.log(text);