The Perplexity API for Automated Research
Use the Perplexity API to build automated research pipelines — market monitoring, report generation, and intelligence feeds.
Why Use the API?
The Perplexity API lets you programmatically query Perplexity's models, enabling:
- Scheduled competitive intelligence reports
- Automated market monitoring
- AI agent research pipelines
- Bulk research at scale
The API uses OpenAI-compatible format, making integration straightforward.
Basic API Call
import requests
response = requests.post(
"https://api.perplexity.ai/chat/completions",
headers={"Authorization": f"Bearer {PERPLEXITY_API_KEY}"},
json={
"model": "llama-3.1-sonar-large-128k-online",
"messages": [
{"role": "user", "content": "What are the latest developments in enterprise AI governance?"}
],
"search_recency_filter": "week",
"return_citations": True
}
)
result = response.json()
answer = result["choices"][0]["message"]["content"]
citations = result["citations"]
Model Selection
| Model | Use Case | |-------|---------| | sonar | Fast, lightweight searches | | sonar-pro | Deep research, complex queries | | sonar-reasoning | Multi-step reasoning with citations |
Building a Weekly Intelligence Report
topics = [
"AI governance regulatory updates",
"Enterprise AI adoption trends",
"Key competitor product launches"
]
report = []
for topic in topics:
response = query_perplexity(topic, recency="week")
report.append({"topic": topic, "findings": response})
send_weekly_brief(report)
Recency Filters
The search_recency_filter parameter controls how fresh sources must be:
- "hour" — breaking news
- "day" — last 24 hours
- "week" — last 7 days
- "month" — last 30 days
For competitive intelligence, "week" balances freshness with coverage.
Rate Limits and Cost
The API charges per token. Budget $50–200/month for a moderate automation pipeline. Use caching aggressively — many research queries repeat with minor variations.