Perplexity API
Generate answers and research reports with web citations.
Perplexity Sonar Deep Research
通过多次网络搜索和引用来源生成研究报告。model 和 messages 为必填;本端点请使用模型 sonar-deep-research。本公开契约涵盖 stream 为 false 的非流式 JSON 响应。研究可能需要数分钟,且可能超出网关或客户端超时。从 choices[].message.content、citations 和 search_results 读取报告及其来源。usage 并非 Felo 额度扣费。
计费参考
- 计量方式:按上报的响应成本计量。
- 参考请求估算:0.23932 美元。
- 参考客户倍率:1.0。不得对已结算的客户金额再次应用。
仅供参考的元数据,不是账户报价、保证价格或消费上限。资源额度不同于 Felo 额度。最终扣费以 Felo 计费记录为准。
- 类型: array object[]messages必填
包含迄今对话的消息列表。
- content类型: string必填
消息内容。
- role类型: string 枚举必填
消息作者的角色。
值- system
- user
- assistant
- 类型: string 枚举model必填
要使用的 Sonar 模型。
值- sonar
- sonar
-pro - sonar
-reasoning -pro - sonar
-deep -research
- 类型: numberfrequency
_penalty 最小值:0最大值:2根据新 token 在迄今文本中的出现频率对其进行惩罚。正值会降低逐字重复同一行的可能性。
- 类型: integermax
_tokens 响应中要生成的最大 token 数。
- 类型: numberpresence
_penalty 最小值:-2最大值:2根据新 token 是否已出现在迄今文本中对其进行惩罚。正值会提高谈论新话题的可能性。
- 类型: booleanreturn
_citations 是否在响应中返回引用和搜索结果。
- 类型: string 枚举search
_context 控制使用的搜索上下文数量。会影响每次请求的成本。
值- low
- medium
- high
- 类型: array string[]search
_domain _filter 将搜索限制在特定域名。
- 类型: string 枚举search
_recency _filter 按新鲜度筛选搜索结果。
值- month
- week
- day
- hour
- 类型: booleanstream
是否使用服务器发送事件流式返回响应。
- 类型: numbertemperature最小值:0最大值:2
采样温度,介于 0 到 2 之间。值越低,输出越聚焦、越确定。
- 类型: integertop
_k 最小值:0最大值:2048top-k 过滤保留的 token 数。
- 类型: numbertop
_p 最小值:0最大值:1核采样参数。模型只考虑累计概率达到 top_p 的 token。
- 类型: object · ResponseD5E2470Dd28B_ChatCompletionResponse200
成功响应,包含 AI 回答和引用
- 类型: array object[]choices
- finish类型: string 枚举
_reason 值- stop
- length
- index类型: integer
Integer numbers.
- message类型: object
- content类型: string
AI 生成的回答,带 [1][2] 这类行内引用标记。
- role类型: string
- 类型: array string[]citations
回答中引用的来源 URL 列表。
- 类型: integercreated
创建补全时的 Unix 时间戳。
- 类型: stringid
补全的唯一标识符。
- 类型: stringmodel
用于补全的模型。
- 类型: stringobject
- 类型: array object[]search
_results 包含标题、摘要和 URL 的详细搜索结果。
- 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
无法处理该请求。请检查请求参数。
- 401
需要有效的 Felo API 密钥。
- 402
由于未满足计费要求,请求无法继续。
- 403
该账户无权执行此操作。
- 429
已达到请求或支出限额。
- 502
服务无法完成该请求。
- 503
API 或计费服务暂时不可用。
- 504
服务在处理请求时超时。
- default
错误响应;上游透传响应可能采用提供方格式
application/json
curl --request POST https://openapi.felo.ai/v1/beta/perplexity/sonar-deep-research \
--header "Authorization: Bearer ${FELO_API_KEY:?Set FELO_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{"model": "sonar-deep-research", "messages": [{"role": "user", "content": "Research HTTP caching strategies for public APIs, with references to standards."}], "max_tokens": 4096, "stream": false}'
{
"id": "example-sonar-deep-research-completion",
"model": "sonar-deep-research",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Public API caching combines freshness controls and conditional requests. [1][2]"
},
"finish_reason": "stop"
}
],
"citations": [
"https://www.rfc-editor.org/rfc/rfc9111.html",
"https://www.rfc-editor.org/rfc/rfc9110.html"
],
"search_results": [
{
"title": "HTTP Caching",
"url": "https://www.rfc-editor.org/rfc/rfc9111.html"
},
{
"title": "HTTP Semantics",
"url": "https://www.rfc-editor.org/rfc/rfc9110.html"
}
],
"usage": {
"prompt_tokens": 40,
"completion_tokens": 80,
"total_tokens": 120
}
}