# Perplexity Sonar Reasoning Pro

**API:** Data API

**Endpoint:** `POST /v1/beta/perplexity/sonar-reasoning-pro`

**Tags:** Perplexity API

分析需要推理且由网络搜索和引用支持的问题。model 和 messages 为必填；本端点请使用模型 sonar-reasoning-pro。本公开契约涵盖 stream 为 false 的非流式 JSON 响应。从 choices[].message.content、citations 和 search_results 读取回答及其来源。usage 并非 Felo 额度扣费。

### 计费参考

- 计量方式：按上报的响应成本计量。
- 参考请求估算：0.03499 美元。
- 参考客户倍率：1.0。不得对已结算的客户金额再次应用。

仅供参考的元数据，不是账户报价、保证价格或消费上限。资源额度不同于 Felo 额度。最终扣费以 Felo 计费记录为准。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **yes**

### application/json

Schema:

```json
{
  "type": "object",
  "required": [
    "model",
    "messages"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "要使用的 Sonar 模型。",
      "enum": [
        "sonar",
        "sonar-pro",
        "sonar-reasoning-pro",
        "sonar-deep-research"
      ]
    },
    "messages": {
      "type": "array",
      "description": "包含迄今对话的消息列表。",
      "items": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "user",
              "assistant"
            ],
            "description": "消息作者的角色。"
          },
          "content": {
            "type": "string",
            "description": "消息内容。"
          }
        }
      }
    },
    "max_tokens": {
      "type": "integer",
      "description": "响应中要生成的最大 token 数。"
    },
    "temperature": {
      "type": "number",
      "description": "采样温度，介于 0 到 2 之间。值越低，输出越聚焦、越确定。",
      "default": 0.2,
      "minimum": 0,
      "maximum": 2
    },
    "top_p": {
      "type": "number",
      "description": "核采样参数。模型只考虑累计概率达到 top_p 的 token。",
      "default": 0.9,
      "minimum": 0,
      "maximum": 1
    },
    "top_k": {
      "type": "integer",
      "description": "top-k 过滤保留的 token 数。",
      "default": 0,
      "minimum": 0,
      "maximum": 2048
    },
    "stream": {
      "type": "boolean",
      "description": "是否使用服务器发送事件流式返回响应。",
      "default": false
    },
    "search_context": {
      "type": "string",
      "description": "控制使用的搜索上下文数量。会影响每次请求的成本。",
      "enum": [
        "low",
        "medium",
        "high"
      ],
      "default": "low"
    },
    "frequency_penalty": {
      "type": "number",
      "description": "根据新 token 在迄今文本中的出现频率对其进行惩罚。正值会降低逐字重复同一行的可能性。",
      "default": 1,
      "minimum": 0,
      "maximum": 2
    },
    "presence_penalty": {
      "type": "number",
      "description": "根据新 token 是否已出现在迄今文本中对其进行惩罚。正值会提高谈论新话题的可能性。",
      "default": 0,
      "minimum": -2,
      "maximum": 2
    },
    "return_citations": {
      "type": "boolean",
      "description": "是否在响应中返回引用和搜索结果。",
      "default": true
    },
    "search_recency_filter": {
      "type": "string",
      "description": "按新鲜度筛选搜索结果。",
      "enum": [
        "month",
        "week",
        "day",
        "hour"
      ]
    },
    "search_domain_filter": {
      "type": "array",
      "description": "将搜索限制在特定域名。",
      "items": {
        "type": "string"
      }
    }
  }
}
```

Example:

```json
{
  "model": "sonar-reasoning-pro",
  "messages": [
    {
      "role": "user",
      "content": "Explain when conditional HTTP requests save bandwidth, citing the standards."
    }
  ],
  "max_tokens": 2048,
  "stream": false
}
```

## Responses

### 200 — 成功响应，包含 AI 回答和引用

Headers:
- `X-Request-Id` (string) — 联系 Felo 支持时需提供的请求标识符。

**application/json**

Schema: `ResponseD5E2470Dd28B_ChatCompletionResponse` (`#/components/schemas/ResponseD5E2470Dd28B_ChatCompletionResponse`)

Example:

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

### 400 — 无法处理该请求。请检查请求参数。

### 401 — 需要有效的 Felo API 密钥。

### 402 — 由于未满足计费要求，请求无法继续。

### 403 — 该账户无权执行此操作。

### 429 — 已达到请求或支出限额。

### 502 — 服务无法完成该请求。

### 503 — API 或计费服务暂时不可用。

### 504 — 服务在处理请求时超时。

### default — 错误响应；上游透传响应可能采用提供方格式

**application/json**

Schema:

```json
{}
```

## Schema definitions

### ResponseD5E2470Dd28B_ChatCompletionResponse

`#/components/schemas/ResponseD5E2470Dd28B_ChatCompletionResponse`

```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "补全的唯一标识符。"
    },
    "model": {
      "type": "string",
      "description": "用于补全的模型。"
    },
    "object": {
      "type": "string",
      "example": "chat.completion"
    },
    "created": {
      "type": "integer",
      "description": "创建补全时的 Unix 时间戳。"
    },
    "choices": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer"
          },
          "message": {
            "type": "object",
            "properties": {
              "role": {
                "type": "string"
              },
              "content": {
                "type": "string",
                "description": "AI 生成的回答，带 [1][2] 这类行内引用标记。"
              }
            }
          },
          "finish_reason": {
            "type": "string",
            "enum": [
              "stop",
              "length"
            ]
          }
        }
      }
    },
    "citations": {
      "type": "array",
      "description": "回答中引用的来源 URL 列表。",
      "items": {
        "type": "string"
      }
    },
    "search_results": {
      "type": "array",
      "description": "包含标题、摘要和 URL 的详细搜索结果。",
      "items": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "snippet": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "source": {
            "type": "string"
          }
        }
      }
    },
    "usage": {
      "type": "object",
      "properties": {
        "prompt_tokens": {
          "type": "integer"
        },
        "completion_tokens": {
          "type": "integer"
        },
        "total_tokens": {
          "type": "integer"
        },
        "search_context_size": {
          "type": "string"
        }
      }
    }
  }
}
```
