Skip to content

Perplexity Search API

Perplexity provides high-quality conversational search. It excels at answering complex questions with citations from diverse web sources.

Endpoint

POST https://llm.siraya.pro/v1/perplexity

Request Parameters

Parameter Type Required Description
model string Yes Use perplexity-search.
query string Yes The search query or question.
max_results integer No Maximum number of results to return (default: 10, range: 1-20).
search_recency_filter string No hour, day, week, month, or year.

Example Request

curl https://llm.siraya.pro/v1/perplexity \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  -d '{
    "model": "perplexity-search",
    "query": "What is the status of the James Webb Space Telescope?",
    "max_results": 5
  }'
import requests

url = "https://llm.siraya.pro/v1/perplexity"
headers = {"Authorization": "Bearer <API_KEY>"}
data = {
    "model": "perplexity-search",
    "query": "What is the status of the James Webb Space Telescope?"
}

response = requests.post(url, headers=headers, json=data)
results = response.json().get("results", [])

Response Body

Returns a list of structured results, including titles, URLs, and snippets.

{
  "results": [
    {
      "title": "James Webb Space Telescope (JWST) NASA",
      "url": "https://webb.nasa.gov/",
      "snippet": "The James Webb Space Telescope is the largest, most powerful space telescope ever built...",
      "date": "2024-03-01",
      "last_updated": "2024-03-05"
    }
  ]
}