Perplexity API
Generate answers and research reports with web citations.
Perplexity Sonar Reasoning Pro
Analyze a question requiring reasoning supported by web search and citations. model and messages are required; use model sonar-reasoning-pro for this endpoint. This public contract covers non-streaming JSON responses with stream false. Read choices[].message.content, citations and search_results for the answer and its sources. usage is 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 枚举必填
The role of the message author.
值- system
- user
- assistant
- 类型: string 枚举model必填
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 枚举search
_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 枚举search
_recency _filter Filter search results by recency.
值- month
- week
- day
- hour
- 类型: boolean 枚举stream常量: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 枚举
_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-reasoning-pro \
--header "Authorization: Bearer ${FELO_API_KEY:?Set FELO_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{"model": "sonar-reasoning-pro", "messages": [{"role": "user", "content": "Explain when conditional HTTP requests save bandwidth, citing the standards."}], "max_tokens": 2048, "stream": false}'
{
"id": "example-sonar-reasoning-pro-completion",
"model": "sonar-reasoning-pro",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A successful cache validation can avoid transferring an unchanged body. [1]"
},
"finish_reason": "stop"
}
],
"citations": [
"https://www.rfc-editor.org/rfc/rfc9110.html"
],
"search_results": [
{
"title": "HTTP Semantics",
"url": "https://www.rfc-editor.org/rfc/rfc9110.html"
}
],
"usage": {
"prompt_tokens": 30,
"completion_tokens": 50,
"total_tokens": 80
}
}