Answer

Search-grounded (RAG) answers with citations, from a single query.

POST/api/v1/answer

The answer endpoint returns a synthesized, source-grounded answer rather than a list of links - backed by providers like Perplexity Sonar and Exa Answer. Swap between them by changing the model slug; the response shape stays the same.

Request

ParameterTypeRequiredDescription
modelstringrequiredAnswer model slug, e.g. perplexity/sonar or exa/answer.
querystringrequiredThe question to answer.
include_citationsbooleanoptionalReturn supporting source citations. Default true.
json
{
  "model": "perplexity/sonar",
  "query": "Who won the 2026 Champions League?",
  "include_citations": true
}

Response

FieldTypeRequiredDescription
idstringoptionalUnique request id.
modelstringoptionalThe resolved model slug.
providerstringoptionalThe provider that served the request.
answerstringoptionalThe synthesized, source-grounded answer.
citationsobject[]optionalSource list of { title, url, snippet }, when requested.
usageobjectoptional{ cost } - cost in USD.
json
{
  "id": "sr-ans-1",
  "model": "perplexity/sonar",
  "provider": "perplexity",
  "answer": "…",
  "citations": [
    { "title": "...", "url": "...", "snippet": "..." }
  ],
  "usage": { "cost": 0.005 }
}
Citations. When include_citations is true, every cited source is normalized to { title, url, snippet } - the same fields a search result exposes.

Examples

cURL

bash
curl https://searchrouter.ai/api/v1/answer \
  -H "Authorization: Bearer $SR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "perplexity/sonar",
    "query": "Who won the 2026 Champions League?",
    "include_citations": true
  }'

Python

python
import os, requests

resp = requests.post(
    "https://searchrouter.ai/api/v1/answer",
    headers={"Authorization": f"Bearer {os.environ['SR_API_KEY']}"},
    json={
        "model": "perplexity/sonar",
        "query": "Who won the 2026 Champions League?",
        "include_citations": True,
    },
)
resp.raise_for_status()
data = resp.json()
print(data["answer"])
for c in data["citations"]:
    print("-", c["title"], c["url"])

JavaScript

javascript
const resp = await fetch("https://searchrouter.ai/api/v1/answer", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SR_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "perplexity/sonar",
    query: "Who won the 2026 Champions League?",
    include_citations: true,
  }),
});
const data = await resp.json();
console.log(data.answer);
data.citations.forEach((c) => console.log("-", c.title, c.url));