Skip to content
Dashboard

Access Perplexity Web Search on Vercel AI Gateway with any model

import { generateText } from "ai"
import { gateway } from "@ai-sdk/gateway"
const result = await generateText({
model: "openai/gpt-5.2",
tools: {
perplexity_search: gateway.tools.perplexitySearch(),
},
prompt: "What changed in Next.js this week?",
})
console.log(result.text)

import { streamText } from "ai"
import { gateway } from "@ai-sdk/gateway"
const result = await streamText({
model: "zai/glm-4.7",
prompt:
"What are the latest AI safety guidelines " +
"published by major tech companies?",
tools: {
perplexity_search: gateway.tools.perplexitySearch({
maxResults: 5,
searchRecencyFilter: "month",
searchLanguageFilter: ["en"],
}),
},
})

import { generateText } from "ai"
import { gateway } from "@ai-sdk/gateway"
const { text } = await generateText({
model: "minimax/minimax-m2.1",
prompt:
"What breaking changes were introduced in " +
"Next.js 16.1? Check the latest release notes " +
"and migration guide.",
tools: {
perplexity_search: gateway.tools.perplexitySearch({
maxResults: 5,
searchDomainFilter: [
"github.com",
"nextjs.org",
"vercel.com",
],
searchRecencyFilter: "month",
}),
},
})

import { streamText } from "ai"
import { gateway } from "@ai-sdk/gateway"
const result = await streamText({
model: "meta/llama-3.3-70b",
prompt:
"What are the latest critical CVEs disclosed " +
"for Node.js in the past week?",
tools: {
perplexity_search: gateway.tools.perplexitySearch({
maxResults: 5,
searchDomainFilter: [
"nodejs.org",
"cve.mitre.org",
"github.com",
],
}),
},
providerOptions: {
order: ["cerebras", "togetherai"],
},
})