"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.perplexityDocs = void 0;
exports.perplexityDocs = [
{
id: "perplexity-chat",
title: "Perplexity API",
category: "chat",
provider: "perplexity",
keywords: ["perplexity", "chat", "search", "web", "citations", "grounded"],
content: `# Perplexity API
Perplexity provides grounded, web-search-enabled AI responses with citations.
## Endpoint
POST https://api.perplexity.ai/chat/completions
## Headers
- Authorization: Bearer YOUR_API_KEY
- Content-Type: application/json
## Request Body
\`\`\`json
{
"model": "sonar" | "sonar-pro" | "sonar-reasoning" | "sonar-deep-research",
"messages": [
{
"role": "system" | "user" | "assistant",
"content": "string"
}
],
"max_tokens": number,
"temperature": number (0-2, default 0.2),
"top_p": number (0-1, default 0.9),
"stream": boolean,
"return_citations": boolean (default true),
"return_images": boolean,
"return_related_questions": boolean,
"search_domain_filter": string[],
"search_recency_filter": "month" | "week" | "day" | "hour" | "none",
"language": "string"
}
\`\`\`
## Response
\`\`\`json
{
"id": "xxx",
"model": "sonar",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "Response with citations [1][2]..."
}
}
],
"citations": [
"https://example.com/source1",
"https://example.com/source2"
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
\`\`\`
## Available Models
- sonar: Fast, web-grounded responses
- sonar-pro: Higher quality, more thorough
- sonar-reasoning: With chain-of-thought
- sonar-deep-research: In-depth research mode
## Key Features
- Built-in web search (no separate tool needed)
- Citations in responses
- Domain filtering
- Recency filtering
- Image results
- Related questions
## Python Example
\`\`\`python
from openai import OpenAI
client = OpenAI(
base_url="https://api.perplexity.ai",
api_key="pplx-..."
)
response = client.chat.completions.create(
model="sonar",
messages=[
{"role": "user", "content": "What are the latest AI news?"}
],
return_citations=True,
return_related_questions=True
)
print(response.choices[0].message.content)
print("Citations:", response.citations)
\`\`\`
## Node.js Example
\`\`\`javascript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.perplexity.ai",
apiKey: "pplx-..."
});
const response = await client.chat.completions.create({
model: "sonar",
messages: [{ role: "user", content: "Latest AI news?" }],
});
console.log(response.choices[0].message.content);
\`\`\`
## cURL Example
\`\`\`bash
curl https://api.perplexity.ai/chat/completions \\
-H "Authorization: Bearer $PERPLEXITY_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"model": "sonar",
"messages": [{"role": "user", "content": "Latest AI news?"}],
"return_citations": true
}'
\`\`\``
},
{
id: "perplexity-rate-limits",
title: "Perplexity Rate Limits & Pricing",
category: "limits",
provider: "perplexity",
keywords: ["perplexity", "rate limit", "pricing", "cost", "limits"],
content: `# Perplexity Rate Limits & Pricing
## Rate Limits
- Varies by plan
- Free tier available with limited requests
## Pricing (per 1M tokens)
- sonar: Input $1.00, Output $1.00
- sonar-pro: Input $3.00, Output $15.00
- sonar-reasoning: Input $1.00, Output $5.00
- sonar-deep-research: Higher pricing
## Context Windows
- sonar: 128K tokens
- sonar-pro: 128K tokens
## Features
- Built-in web search
- Real-time information
- Citations included
- No hallucination from web data`
}
];
//# sourceMappingURL=perplexity.js.map