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
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | required | Answer model slug, e.g. perplexity/sonar or exa/answer. |
| query | string | required | The question to answer. |
| include_citations | boolean | optional | Return supporting source citations. Default true. |
json
{
"model": "perplexity/sonar",
"query": "Who won the 2026 Champions League?",
"include_citations": true
}Response
| Field | Type | Required | Description |
|---|---|---|---|
| id | string | optional | Unique request id. |
| model | string | optional | The resolved model slug. |
| provider | string | optional | The provider that served the request. |
| answer | string | optional | The synthesized, source-grounded answer. |
| citations | object[] | optional | Source list of { title, url, snippet }, when requested. |
| usage | object | optional | { 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));