Reference example
# 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?"
}
]
}'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?"
}
]
}
'import requests
url = "https://api.aisa.one/apis/v1/perplexity/sonar"
payload = {
"model": "sonar",
"messages": [
{
"role": "user",
"content": "What are the latest developments in quantum computing?"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'sonar',
messages: [
{
role: 'user',
content: 'What are the latest developments in quantum computing?'
}
]
})
};
fetch('https://api.aisa.one/apis/v1/perplexity/sonar', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/perplexity/sonar",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'sonar',
'messages' => [
[
'role' => 'user',
'content' => 'What are the latest developments in quantum computing?'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/perplexity/sonar"
payload := strings.NewReader("{\n \"model\": \"sonar\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What are the latest developments in quantum computing?\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/perplexity/sonar")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"sonar\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What are the latest developments in quantum computing?\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/perplexity/sonar")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"sonar\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What are the latest developments in quantum computing?\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"model": "<string>",
"object": "chat.completion",
"created": 123,
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>"
},
"finish_reason": "stop"
}
],
"citations": [
"<string>"
],
"search_results": [
{
"title": "<string>",
"url": "<string>",
"snippet": "<string>",
"date": "<string>",
"source": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"search_context_size": "<string>"
}
}Perplexity API
Sonar
提一个问题,拿回一段带网页引用的文字答案,而不是一堆需要自己读的链接。
POST
https://api.aisa.one
/
apis
/
v1
/
perplexity
/
sonar
Reference example
# 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?"
}
]
}'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?"
}
]
}
'import requests
url = "https://api.aisa.one/apis/v1/perplexity/sonar"
payload = {
"model": "sonar",
"messages": [
{
"role": "user",
"content": "What are the latest developments in quantum computing?"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'sonar',
messages: [
{
role: 'user',
content: 'What are the latest developments in quantum computing?'
}
]
})
};
fetch('https://api.aisa.one/apis/v1/perplexity/sonar', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/perplexity/sonar",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'sonar',
'messages' => [
[
'role' => 'user',
'content' => 'What are the latest developments in quantum computing?'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/perplexity/sonar"
payload := strings.NewReader("{\n \"model\": \"sonar\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What are the latest developments in quantum computing?\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/perplexity/sonar")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"sonar\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What are the latest developments in quantum computing?\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/perplexity/sonar")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"sonar\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What are the latest developments in quantum computing?\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"model": "<string>",
"object": "chat.completion",
"created": 123,
"choices": [
{
"index": 123,
"message": {
"role": "<string>",
"content": "<string>"
},
"finish_reason": "stop"
}
],
"citations": [
"<string>"
],
"search_results": [
{
"title": "<string>",
"url": "<string>",
"snippet": "<string>",
"date": "<string>",
"source": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"search_context_size": "<string>"
}
}提一个问题,拿回一段带网页引用的文字答案,而不是一堆需要自己读的链接。请求体是 OpenAI chat-completions 形状:
在你的 agent 里把这个端点跑起来 →
model(必填,sonar)和 messages。返回 choices[0].message.content 作为正文,外加 citations(URL 字符串数组)、search_results[](含 title、url、snippet、date、source)和一个 usage 块。实测约 3 秒。按次固定费率计费。这是四个 Perplexity 端点里最快最便宜的一个,适合单个事实性问题。问题分多个部分时升级到 post_perplexity_sonar_pro,需要一步步推演时用 post_perplexity_sonar_reasoning_pro。如果你要的是可遍历的结果而不是成段文字,用 post_tavily_search;post_exa_answer 用语义检索回答同一类问题。
第一次用? 把任意 MCP 客户端指向
https://mcp.aisa.one/mcp —— Claude Code、
Codex、Cursor、VS Code 都可以。鉴权走 OAuth:客户端打开浏览器,你点一次
Allow,不需要粘贴任何 key。各客户端的具体命令和每次调用的价格见
aisa.one/zh-cn/mcp。费用与请求规则
公开参考值不是你的账户报价或最终扣费。对于支持 X-AISA-Cost-Mode: quote 的接口,执行前请针对完整请求获取免费报价;执行后通过响应费用元数据和 Usage Logs 核对结算费用。1 USD 等于 1,000,000 个整数 micro-USD。- 默认请求参考估价(USD): 0.12783
- 计费依据: response_usd
- 公开参考倍率: 1.0
- 结算证据来源: response_body
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
要使用的 Sonar 模型。
可用选项:
sonar, sonar-pro, sonar-reasoning-pro, sonar-deep-research 由截至目前的对话内容组成的消息列表。
Show child attributes
Show child attributes
响应中要生成的最大词元数。
介于 0 和 2 之间的采样温度。较低的值会使输出更集中且更具确定性。
必填范围:
0 <= x <= 2核采样参数。模型会考虑累计概率质量达到 top_p 的词元。
必填范围:
0 <= x <= 1用于 top-k 筛选的保留词元数。
必填范围:
0 <= x <= 2048是否使用服务器发送事件以流式方式返回响应。
控制使用的搜索上下文量。会影响单次请求的成本。
可用选项:
low, medium, high 根据新词元目前在文本中的出现频率对其施加惩罚。正值会降低逐字重复同一行的可能性。
必填范围:
0 <= x <= 2根据新词元此前是否已出现在文本中对其施加惩罚。正值会提高谈论新主题的可能性。
必填范围:
-2 <= x <= 2是否在响应中返回引用和搜索结果。
按时效性筛选搜索结果。
可用选项:
month, week, day, hour 将搜索限制在特定域名。