Perplexity API
Generate answers and research reports with web citations.
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.
- Тип: array object[]messagesобязательно
A list of messages comprising the conversation so far.
- contentТип: stringобязательно
The content of the message.
- roleТип: string enumобязательно
The role of the message author.
значения- system
- user
- assistant
- Тип: string enummodelобязательно
The Sonar model to use.
значения- sonar
- sonar
-pro - sonar
-reasoning -pro - sonar
-deep -research
- Тип: numberfrequency
_penalty мин.:0макс.:2Penalizes new tokens based on their existing frequency in the text so far. Positive values decrease the likelihood of repeating the same line verbatim.
- Тип: integermax
_tokens The maximum number of tokens to generate in the response.
- Тип: numberpresence
_penalty мин.:-2макс.:2Penalizes new tokens based on whether they appear in the text so far. Positive values increase the likelihood of talking about new topics.
- Тип: booleanreturn
_citations Whether to return citations and search results in the response.
- Тип: string enumsearch
_context Controls how much search context to use. Affects per-request cost.
значения- low
- medium
- high
- Тип: array string[]search
_domain _filter Limit search to specific domains.
- Тип: string enumsearch
_recency _filter Filter search results by recency.
значения- month
- week
- day
- hour
- Тип: boolean enumstreamконстанта:false
Only non-streaming JSON responses are covered by this public contract. Set false.
значения- false
- Тип: numbertemperatureмин.:0макс.:2
Sampling temperature between 0 and 2. Lower values make output more focused and deterministic.
- Тип: integertop
_k мин.:0макс.:2048The number of tokens to keep for top-k filtering.
- Тип: numbertop
_p мин.:0макс.:1Nucleus sampling parameter. The model considers tokens with top_p probability mass.
- Тип: object · ChatCompletionResponse200
Successful response with AI answer and citations
- Тип: array object[]choices
- finishТип: string enum
_reason значения- stop
- length
- indexТип: integer
Integer numbers.
- messageТип: object
- contentТип: string
The AI-generated answer, with inline citation references like [1][2].
- roleТип: string
- Тип: array string[]citations
List of source URLs referenced in the answer.
- Тип: integercreated
Unix timestamp of when the completion was created.
- Тип: stringid
Unique identifier for the completion.
- Тип: stringmodel
The model used for the completion.
- Тип: stringobject
- Тип: array object[]search
_results Detailed search results with titles, snippets, and URLs.
- dateТип: string
- snippetТип: string
- sourceТип: string
- titleТип: string
- urlТип: string
- Тип: objectusage
- completionТип: integer
_tokens Integer numbers.
- promptТип: integer
_tokens Integer numbers.
- searchТип: string
_context _size - totalТип: integer
_tokens Integer numbers.
application/json - 400
The request could not be processed. Check the request parameters.
- 401
A valid Felo API key is required.
- 402
The request cannot proceed because a billing requirement is not met.
- 403
The account is not permitted to perform this operation.
- 429
A request or spending limit has been reached.
- 502
The service could not complete the request.
- 503
The API or billing service is temporarily unavailable.
- 504
The service timed out while processing the request.
- default
The operation failed. Keep the response request ID when contacting Felo support.
curl --request POST https://openapi.felo.ai/v1/beta/perplexity/sonar \
--header "Authorization: Bearer ${FELO_API_KEY:?Set FELO_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{"model": "sonar", "messages": [{"role": "user", "content": "What is HTTP caching? Cite the relevant documentation."}], "max_tokens": 512, "stream": false}'
{
"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
}
}