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 額度扣費。
定價參考
- 計量方式:依回報的回應成本計量。
- 參考請求預估:USD 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
}
}