Data API / Perplexity / Sonar
Perplexity Sonar
Generate a concise answer with web citations. model and messages are required; use model sonar for this endpoint. This public contract covers non-streaming JSON responses with stream false. Read the answer from choices[].message.content and sources from citations and search_results. usage reports resource consumption, not a Felo credit charge.
Parameters
No path, query, or header parameters.
Request body
modelstringRequiredAllowed values: sonar · sonar-pro · sonar-reasoning-pro · sonar-deep-research
The Sonar model to use.
messagesobject[]RequiredA list of messages comprising the conversation so far.
rolestringRequiredAllowed values: system · user · assistant
The role of the message author.
contentstringRequiredThe content of the message.
max_tokensintegerOptionalThe maximum number of tokens to generate in the response.
temperaturenumberOptionalSampling temperature between 0 and 2. Lower values make output more focused and deterministic.
top_pnumberOptionalNucleus sampling parameter. The model considers tokens with top_p probability mass.
top_kintegerOptionalThe number of tokens to keep for top-k filtering.
streambooleanOptionalAllowed values: false
Only non-streaming JSON responses are covered by this public contract. Set false.
search_contextstringOptionalAllowed values: low · medium · high
Controls how much search context to use. Affects per-request cost.
frequency_penaltynumberOptionalPenalizes new tokens based on their existing frequency in the text so far. Positive values decrease the likelihood of repeating the same line verbatim.
presence_penaltynumberOptionalPenalizes new tokens based on whether they appear in the text so far. Positive values increase the likelihood of talking about new topics.
return_citationsbooleanOptionalWhether to return citations and search results in the response.
search_recency_filterstringOptionalAllowed values: month · week · day · hour
Filter search results by recency.
search_domain_filterstring[]OptionalLimit search to specific domains.
Example request
curl -X POST "https://openapi.felo.ai/v1/beta/perplexity/sonar" \
-H "Authorization: Bearer $FELO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<string>",
"messages": [
{}
],
"max_tokens": 0,
"temperature": 0,
"top_p": 0,
"top_k": 0,
"stream": false,
"search_context": "<string>"
}'Response
Example response
{
"id": "example-sonar-completion",
"model": "sonar",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "HTTP caching reuses stored responses when permitted by cache rules. [1]"
},
"finish_reason": "stop"
}
],
"citations": [
"https://www.rfc-editor.org/rfc/rfc9111.html"
],
"search_results": [
{
"title": "HTTP Caching",
"url": "https://www.rfc-editor.org/rfc/rfc9111.html"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 30,
"total_tokens": 50
}
}Response fields
idstringOptionalUnique identifier for the completion.
modelstringOptionalThe model used for the completion.
objectstringOptionalcreatedintegerOptionalUnix timestamp of when the completion was created.
choicesobject[]OptionalindexintegerOptionalmessageobjectOptionalrolestringOptionalcontentstringOptionalThe AI-generated answer, with inline citation references like [1][2].
finish_reasonstringOptionalAllowed values: stop · length
citationsstring[]OptionalList of source URLs referenced in the answer.
search_resultsobject[]OptionalDetailed search results with titles, snippets, and URLs.
titlestringOptionalurlstringOptionalsnippetstringOptionaldatestringOptionalsourcestringOptionalusageobjectOptionalprompt_tokensintegerOptionalcompletion_tokensintegerOptionaltotal_tokensintegerOptionalsearch_context_sizestringOptional