| name | perplexity |
| description | Search the web with AI-powered answers and citations via Perplexity API. Use for research queries needing current info with sources. Env: PERPLEXITY_API_KEY. |
Perplexity Search
Web search with AI synthesis and citations.
Setup
export PERPLEXITY_API_KEY=pplx-...
Search Query
curl -s --request POST \
--url https://api.perplexity.ai/chat/completions \
--header "Authorization: Bearer $PERPLEXITY_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "sonar-pro",
"messages": [{"role": "user", "content": "What are the latest developments in quantum computing?"}]
}' | jq -r '.choices[0].message.content'
Models
| Model | Use Case |
|---|
sonar | Fast, simple queries |
sonar-pro | Complex questions (default) |
sonar-deep-research | Thorough research |
sonar-reasoning-pro | Multi-step reasoning |
Streaming
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header "Authorization: Bearer $PERPLEXITY_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "sonar-pro",
"messages": [{"role": "user", "content": "Explain machine learning"}],
"stream": true
}'
Raw Search API
For web results without AI synthesis ($5/1000 requests, no token costs):
curl -s --request POST \
--url https://api.perplexity.ai/search \
--header "Authorization: Bearer $PERPLEXITY_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"query": "latest AI developments",
"max_results": 5,
"max_tokens_per_page": 2048
}'
Response Parsing
| jq -r '.choices[0].message.content'
| jq -r '.citations[]'
| jq '.usage'
Errors
401 — Invalid API key
429 — Rate limited (wait/retry)