Felo API PlatformFelo API Platform

資料 API / Perplexity / Sonar Pro

Perplexity Sonar Pro

Generate an answer to a multi-part question using web search and citations. model and messages are required; use model sonar-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 reports resource consumption, not a Felo credit charge.

參數

沒有路徑、查詢或請求標頭參數。

請求主體

  • modelstring必填

    允許值: sonar · sonar-pro · sonar-reasoning-pro · sonar-deep-research

    The Sonar model to use.

  • messagesobject[]必填

    A list of messages comprising the conversation so far.

  • rolestring必填

    允許值: system · user · assistant

    The role of the message author.

  • contentstring必填

    The content of the message.

  • max_tokensinteger選填

    The maximum number of tokens to generate in the response.

  • temperaturenumber選填

    Sampling temperature between 0 and 2. Lower values make output more focused and deterministic.

  • top_pnumber選填

    Nucleus sampling parameter. The model considers tokens with top_p probability mass.

  • top_kinteger選填

    The number of tokens to keep for top-k filtering.

  • streamboolean選填

    允許值: false

    Only non-streaming JSON responses are covered by this public contract. Set false.

  • search_contextstring選填

    允許值: low · medium · high

    Controls how much search context to use. Affects per-request cost.

  • frequency_penaltynumber選填

    Penalizes new tokens based on their existing frequency in the text so far. Positive values decrease the likelihood of repeating the same line verbatim.

  • presence_penaltynumber選填

    Penalizes new tokens based on whether they appear in the text so far. Positive values increase the likelihood of talking about new topics.

  • return_citationsboolean選填

    Whether to return citations and search results in the response.

  • search_recency_filterstring選填

    允許值: month · week · day · hour

    Filter search results by recency.

  • search_domain_filterstring[]選填

    Limit search to specific domains.

請求範例

curl -X POST "https://openapi.felo.ai/v1/beta/perplexity/sonar-pro" \
  -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>"
}'

回應

回應範例

{
  "id": "example-sonar-pro-completion",
  "model": "sonar-pro",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "no-cache requires validation before reuse; no-store prohibits storage. [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": 25,
    "completion_tokens": 40,
    "total_tokens": 65
  }
}

回應欄位

  • idstring選填

    Unique identifier for the completion.

  • modelstring選填

    The model used for the completion.

  • objectstring選填
  • createdinteger選填

    Unix timestamp of when the completion was created.

  • choicesobject[]選填
  • indexinteger選填
  • messageobject選填
  • rolestring選填
  • contentstring選填

    The AI-generated answer, with inline citation references like [1][2].

  • finish_reasonstring選填

    允許值: stop · length

  • citationsstring[]選填

    List of source URLs referenced in the answer.

  • search_resultsobject[]選填

    Detailed search results with titles, snippets, and URLs.

  • titlestring選填
  • urlstring選填
  • snippetstring選填
  • datestring選填
  • sourcestring選填
  • usageobject選填
  • prompt_tokensinteger選填
  • completion_tokensinteger選填
  • total_tokensinteger選填
  • search_context_sizestring選填