Felo API PlatformFelo API Platform

Data API / Perplexity / Sonar

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.

Parameters

No path, query, or header parameters.

Request body

  • modelstringRequired

    Allowed values: sonar · sonar-pro · sonar-reasoning-pro · sonar-deep-research

    The Sonar model to use.

  • messagesobject[]Required

    A list of messages comprising the conversation so far.

  • rolestringRequired

    Allowed values: system · user · assistant

    The role of the message author.

  • contentstringRequired

    The content of the message.

  • max_tokensintegerOptional

    The maximum number of tokens to generate in the response.

  • temperaturenumberOptional

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

  • top_pnumberOptional

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

  • top_kintegerOptional

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

  • streambooleanOptional

    Allowed values: false

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

  • search_contextstringOptional

    Allowed values: low · medium · high

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

  • frequency_penaltynumberOptional

    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_penaltynumberOptional

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

  • return_citationsbooleanOptional

    Whether to return citations and search results in the response.

  • search_recency_filterstringOptional

    Allowed values: month · week · day · hour

    Filter search results by recency.

  • search_domain_filterstring[]Optional

    Limit search to specific domains.

Example request

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

Response

Example response

{
  "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
  }
}

Response fields

  • idstringOptional

    Unique identifier for the completion.

  • modelstringOptional

    The model used for the completion.

  • objectstringOptional
  • createdintegerOptional

    Unix timestamp of when the completion was created.

  • choicesobject[]Optional
  • indexintegerOptional
  • messageobjectOptional
  • rolestringOptional
  • contentstringOptional

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

  • finish_reasonstringOptional

    Allowed values: stop · length

  • citationsstring[]Optional

    List of source URLs referenced in the answer.

  • search_resultsobject[]Optional

    Detailed search results with titles, snippets, and URLs.

  • titlestringOptional
  • urlstringOptional
  • snippetstringOptional
  • datestringOptional
  • sourcestringOptional
  • usageobjectOptional
  • prompt_tokensintegerOptional
  • completion_tokensintegerOptional
  • total_tokensintegerOptional
  • search_context_sizestringOptional