> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# Sonar

> 提一个问题，拿回一段带网页引用的文字答案，而不是一堆需要自己读的链接。

提一个问题，拿回一段带网页引用的文字答案，而不是一堆需要自己读的链接。请求体是 OpenAI chat-completions 形状：`model`（必填，`sonar`）和 `messages`。返回 `choices[0].message.content` 作为正文，外加 `citations`（URL 字符串数组）、`search_results[]`（含 `title`、`url`、`snippet`、`date`、`source`）和一个 `usage` 块。实测约 3 秒。按次固定费率计费。这是四个 Perplexity 端点里最快最便宜的一个，适合单个事实性问题。问题分多个部分时升级到 [`post_perplexity_sonar_pro`](https://aisa.one/docs/zh/api-reference/perplexity/post_perplexity-sonar-pro)，需要一步步推演时用 [`post_perplexity_sonar_reasoning_pro`](https://aisa.one/docs/zh/api-reference/perplexity/post_perplexity-sonar-reasoning-pro)。如果你要的是可遍历的结果而不是成段文字，用 [`post_tavily_search`](https://aisa.one/docs/zh/api-reference/search/post_tavily-search)；`post_exa_answer` 用语义检索回答同一类问题。

> [!NOTE]
>
> **第一次用？** 把任意 MCP 客户端指向 `https://mcp.aisa.one/mcp` —— Claude Code、
> Codex、Cursor、VS Code 都可以。鉴权走 OAuth：客户端打开浏览器，你点一次
> Allow，不需要粘贴任何 key。之后智能体通过几个元工具调用所有端点：
> `search`、`list_categories`、`get_details` 和 `batch_quote` 免费，`batch_use`
> 按次计费。各客户端的接入步骤见[通过 MCP 连接](https://aisa.one/docs/zh/agent-quickstart.md)；实时工具列表和
> 每次调用的价格见 [aisa.one/zh-cn/mcp](https://aisa.one/zh-cn/mcp#connect)。

[在你的 agent 里把这个端点跑起来 →](https://aisa.one/mcp?from=/zh/api-reference/perplexity/post_perplexity-sonar)

## 请求规范

* **方法与路径:** POST /apis/v1/perplexity/sonar
* **可用状态:** enabled
* **请求 URL 模板:** `https://api.aisa.one/apis/v1/perplexity/sonar`

[完整 OpenAPI 定义](https://aisa.one/docs/openapi/zh/perplexity.json)

有效请求声明（包括认证和引用的 schema）：

```json theme={null}
{
  "operationId": "post_perplexity_sonar",
  "method": "POST",
  "path": "/apis/v1/perplexity/sonar",
  "servers": [
    {
      "url": "https://api.aisa.one"
    }
  ],
  "parameters": [],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "example": {
          "messages": [
            {
              "content": "What are the latest developments in quantum computing?",
              "role": "user"
            }
          ],
          "model": "sonar"
        },
        "schema": {
          "properties": {
            "frequency_penalty": {
              "default": 1,
              "description": "Penalizes new tokens based on their existing frequency in the text so far. Positive values decrease the likelihood of repeating the same line verbatim.",
              "maximum": 2,
              "minimum": 0,
              "type": "number"
            },
            "max_tokens": {
              "description": "The maximum number of tokens to generate in the response.",
              "type": "integer"
            },
            "messages": {
              "description": "A list of messages comprising the conversation so far.",
              "items": {
                "properties": {
                  "content": {
                    "description": "The content of the message.",
                    "type": "string"
                  },
                  "role": {
                    "description": "The role of the message author.",
                    "enum": [
                      "system",
                      "user",
                      "assistant"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "role",
                  "content"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "model": {
              "description": "The Sonar model to use.",
              "enum": [
                "sonar",
                "sonar-pro",
                "sonar-reasoning-pro",
                "sonar-deep-research"
              ],
              "type": "string"
            },
            "presence_penalty": {
              "default": 0,
              "description": "Penalizes new tokens based on whether they appear in the text so far. Positive values increase the likelihood of talking about new topics.",
              "maximum": 2,
              "minimum": -2,
              "type": "number"
            },
            "return_citations": {
              "default": true,
              "description": "Whether to return citations and search results in the response.",
              "type": "boolean"
            },
            "search_context": {
              "default": "low",
              "description": "Controls how much search context to use. Affects per-request cost.",
              "enum": [
                "low",
                "medium",
                "high"
              ],
              "type": "string"
            },
            "search_domain_filter": {
              "description": "Limit search to specific domains.",
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "search_recency_filter": {
              "description": "Filter search results by recency.",
              "enum": [
                "month",
                "week",
                "day",
                "hour"
              ],
              "type": "string"
            },
            "stream": {
              "default": false,
              "description": "Whether to stream the response using server-sent events.",
              "type": "boolean"
            },
            "temperature": {
              "default": 0.2,
              "description": "Sampling temperature between 0 and 2. Lower values make output more focused and deterministic.",
              "maximum": 2,
              "minimum": 0,
              "type": "number"
            },
            "top_k": {
              "default": 0,
              "description": "The number of tokens to keep for top-k filtering.",
              "maximum": 2048,
              "minimum": 0,
              "type": "integer"
            },
            "top_p": {
              "default": 0.9,
              "description": "Nucleus sampling parameter. The model considers tokens with top_p probability mass.",
              "maximum": 1,
              "minimum": 0,
              "type": "number"
            }
          },
          "required": [
            "model",
            "messages"
          ],
          "type": "object"
        }
      }
    },
    "required": true
  },
  "x-aisa-status": "enabled",
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
```

## 费用与请求规则

按实际用量收费。 默认请求预估费用：\$0.12783 USD。 最终费用以实际用量为准。 账户适用价格可能不同；支持报价的接口可按实际请求获取报价。


## OpenAPI

````yaml openapi/zh/perplexity.json POST /apis/v1/perplexity/sonar
openapi: 3.1.0
info:
  description: ''
  title: Perplexity
  version: '1'
  x-aisa-capabilities:
    idempotency: Idempotency-Key
    max_price: X-AISA-Max-Price-USD
    quote:
      header: X-AISA-Cost-Mode
      value: quote
  x-aisa-catalogs:
    perplexity:
      description: ''
      title: Perplexity
      x-aisa-capabilities:
        idempotency: Idempotency-Key
        max_price: X-AISA-Max-Price-USD
        quote:
          header: X-AISA-Cost-Mode
          value: quote
      x-aisa-document:
        facts_hash: fb88776539957bfc86000a34a6c0da10e10cbeecf9d65c8ae1d78688c170faac
        generator_version: '3'
        protocol_version: '1'
        schema_version: '1'
      x-aisa-plans:
        builder: 1
        display_plan: payg
        payg: 1
        similarweb_payg: 1
        team: 1
        version: e70a0959cd1b93b84ae16dffd7a538273ddb9c1d46277b82823c37ff1b6bc0fb
  x-aisa-configured-paths:
    - /apis/v1/perplexity/sonar
    - /apis/v1/perplexity/sonar-deep-research
    - /apis/v1/perplexity/sonar-pro
    - /apis/v1/perplexity/sonar-reasoning-pro
  x-aisa-document:
    composer_version: '31'
    document_hash: sha256:69711bcc6173479fb76ccc00020e928332bd1163f25aad40bcecde2d40b25bae
    facts_hash: fb88776539957bfc86000a34a6c0da10e10cbeecf9d65c8ae1d78688c170faac
    generator_version: '3'
    protocol_version: '1'
    response_pending: []
    schema_version: '1'
  x-aisa-plans:
    builder: 1
    display_plan: payg
    payg: 1
    similarweb_payg: 1
    team: 1
    version: e70a0959cd1b93b84ae16dffd7a538273ddb9c1d46277b82823c37ff1b6bc0fb
  x-aisa-provider: perplexity
servers:
  - url: https://api.aisa.one
security:
  - bearerAuth: []
paths:
  /apis/v1/perplexity/sonar:
    post:
      tags:
        - sonar
      summary: Sonar
      description: >-
        Ask a question and get a written answer with web citations, rather than
        a list of links to read yourself. Body is OpenAI chat-completions
        shaped: `model` (required, `sonar`) and `messages`. Returns
        `choices[0].message.content` as prose, plus `citations` (an array of URL
        strings) and `search_results[]` with `title`, `url`, `snippet`, `date`
        and `source`, and a `usage` block. Measured at about 3 seconds.  This is
        the cheapest and fastest of the four Perplexity endpoints — use it for a
        single factual question. Step up to `post_perplexity_sonar_pro` for
        multi-part questions, or `post_perplexity_sonar_reasoning_pro` when the
        answer requires working through steps. If you need results you can
        iterate over rather than prose, use `post_tavily_search`;
      operationId: post_perplexity_sonar
      requestBody:
        content:
          application/json:
            example:
              messages:
                - content: What are the latest developments in quantum computing?
                  role: user
              model: sonar
            schema:
              properties:
                frequency_penalty:
                  default: 1
                  description: 根据新词元目前在文本中的出现频率对其施加惩罚。正值会降低逐字重复同一行的可能性。
                  maximum: 2
                  minimum: 0
                  type: number
                max_tokens:
                  description: 响应中要生成的最大词元数。
                  type: integer
                messages:
                  description: 由截至目前的对话内容组成的消息列表。
                  items:
                    properties:
                      content:
                        description: 消息内容。
                        type: string
                      role:
                        description: 消息作者的角色。
                        enum:
                          - system
                          - user
                          - assistant
                        type: string
                    required:
                      - role
                      - content
                    type: object
                  type: array
                model:
                  description: 要使用的 Sonar 模型。
                  enum:
                    - sonar
                    - sonar-pro
                    - sonar-reasoning-pro
                    - sonar-deep-research
                  type: string
                presence_penalty:
                  default: 0
                  description: 根据新词元此前是否已出现在文本中对其施加惩罚。正值会提高谈论新主题的可能性。
                  maximum: 2
                  minimum: -2
                  type: number
                return_citations:
                  default: true
                  description: 是否在响应中返回引用和搜索结果。
                  type: boolean
                search_context:
                  default: low
                  description: 控制使用的搜索上下文量。会影响单次请求的成本。
                  enum:
                    - low
                    - medium
                    - high
                  type: string
                search_domain_filter:
                  description: 将搜索限制在特定域名。
                  items:
                    type: string
                  type: array
                search_recency_filter:
                  description: 按时效性筛选搜索结果。
                  enum:
                    - month
                    - week
                    - day
                    - hour
                  type: string
                stream:
                  default: false
                  description: 是否使用服务器发送事件以流式方式返回响应。
                  type: boolean
                temperature:
                  default: 0.2
                  description: 介于 0 和 2 之间的采样温度。较低的值会使输出更集中且更具确定性。
                  maximum: 2
                  minimum: 0
                  type: number
                top_k:
                  default: 0
                  description: 用于 top-k 筛选的保留词元数。
                  maximum: 2048
                  minimum: 0
                  type: integer
                top_p:
                  default: 0.9
                  description: 核采样参数。模型会考虑累计概率质量达到 top_p 的词元。
                  maximum: 1
                  minimum: 0
                  type: number
              required:
                - model
                - messages
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/ResponseD5E2470Dd28B_ChatCompletionResponse
          description: 包含 AI 答案和引用的成功响应
        default:
          content:
            application/json:
              schema: {}
          description: >-
            Error response; upstream passthrough responses may use provider
            formats
      x-codeSamples:
        - label: Reference example
          lang: text
          source: >-
            # Fixed reference example. Playground inputs do not update this
            sample.

            curl --request POST \
              --url https://api.aisa.one/apis/v1/perplexity/sonar \
              --header 'Authorization: Bearer <token>' \
              --header 'Content-Type: application/json' \
              --data '{
              "model": "sonar",
              "messages": [
                {
                  "role": "user",
                  "content": "What are the latest developments in quantum computing?"
                }
              ]
            }'
components:
  schemas:
    ResponseD5E2470Dd28B_ChatCompletionResponse:
      properties:
        choices:
          items:
            properties:
              finish_reason:
                enum:
                  - stop
                  - length
                type: string
              index:
                type: integer
              message:
                properties:
                  content:
                    description: AI 生成的答案，包含类似 [1][2] 的内联引用。
                    type: string
                  role:
                    type: string
                type: object
            type: object
          type: array
        citations:
          description: 答案中引用的来源 URL 列表。
          items:
            type: string
          type: array
        created:
          description: 补全创建时间的 Unix 时间戳。
          type: integer
        id:
          description: 补全结果的唯一标识符。
          type: string
        model:
          description: 用于生成补全内容的模型。
          type: string
        object:
          example: chat.completion
          type: string
        search_results:
          description: 包含标题、摘要和 URL 的详细搜索结果。
          items:
            properties:
              date:
                type: string
              snippet:
                type: string
              source:
                type: string
              title:
                type: string
              url:
                type: string
            type: object
          type: array
        usage:
          properties:
            completion_tokens:
              type: integer
            prompt_tokens:
              type: integer
            search_context_size:
              type: string
            total_tokens:
              type: integer
          type: object
      type: object
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.