using-perplexity-platform
БесплатноБез исполняемых скриптовНе проверенPerplexity Sonar API development with search-augmented generation, real-time web search, citations, and OpenAI-compatible Chat Completions. Use for AI-powered…
от majiayu000★ 31 звезда на GitHubОб этом скилле
Perplexity Sonar API Development Skill
Quick Reference
Perplexity Sonar API development with Python and TypeScript/JavaScript clients. Covers Sonar model family for search-augmented generation, Chat Completions API (OpenAI-compatible), real-time web search, citations, and streaming.
Table of Contents
- When to Use
- Sonar Model Family
- Quick Start
- Chat Completions API
- Citations and Sources
- Search Configuration
- Streaming
- Error Handling
- Best Practices
- Anti-Patterns
- Integration Checklist
- When to Use Perplexity vs Others
- CLI Quick Test
- See Also
When to Use
This skill is loaded by backend-developer when:
openaipackage inrequirements.txtorpyproject.tomlwith Perplexity base URL- Environment variables
PERPLEXITY_API_KEYorPPLX_API_KEYpresent - User mentions "Perplexity", "Sonar", or "search-augmented" in task
- Code uses
api.perplexity.aibase URL
Minimum Detection Confidence: 0.8 (80%)
Sonar Model Family
Available Models
| Model | Context | Search | Use Case | Speed |
|---|---|---|---|---|
sonar |
128K | Yes | General search-augmented | Fast |
sonar-pro |
200K | Yes | Complex research, deeper search | Medium |
sonar-reasoning |
128K | Yes | Multi-step reasoning with search | Slower |
sonar-reasoning-pro |
200K | Yes | Advanced reasoning, citations | Slowest |
Model Selection Guide
Task Complexity -> Model Selection
+-- Simple factual queries -> sonar (fast, affordable)
+-- Research with citations -> sonar-pro (deeper search)
+-- Multi-step reasoning -> sonar-reasoning
+-- Complex analysis -> sonar-reasoning-pro
Pricing (per 1M tokens)
| Model | Input | Output |
|---|---|---|
| sonar | $1.00 | $1.00 |
| sonar-pro | $3.00 | $15.00 |
| sonar-reasoning | $1.00 | $5.00 |
| sonar-reasoning-pro | $2.00 | $8.00 |
Quick Start
Python Setup (Using OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="pplx-...", # or use PERPLEXITY_API_KEY env var
base_url="https://api.perplexity.ai"
)
response = client.chat.completions.create(
model="sonar",
messages=[
{"role": "system", "content": "Be precise and concise. Cite sources."},
{"role": "user", "content": "What are the latest developments in AI?"}
]
)
print(response.choices[0].message.content)
# Access citations if available
if hasattr(response, 'citations'):
for citation in response.citations:
print(f" - {citation}")
TypeScript Setup
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.PERPLEXITY_API_KEY,
baseURL: 'https://api.perplexity.ai'
});
const response = await client.chat.completions.create({
model: 'sonar',
messages: [
{ role: 'system', content: 'Be precise and concise. Cite sources.' },
{ role: 'user', content: 'What are the latest developments in AI?' }
]
});
console.log(response.choices[0].message.content);
Environment Configuration
export PERPLEXITY_API_KEY="pplx-..."
# Alternative: export PPLX_API_KEY="pplx-..."
Chat Completions API
Common Parameters
| Parameter | Type | Description |
|---|---|---|
model |
string | Model ID (required) |
messages |
array | Conversation messages (required) |
temperature |
float (0-2) | Randomness (0=deterministic) |
max_tokens |
int | Max response tokens |
stream |
boolean | Enable streaming |
Perplexity-Specific Parameters
| Parameter | Type | Description |
|---|---|---|
search_domain_filter |
array | Limit search to specific domains |
return_images |
boolean | Include relevant images |
return_related_questions |
boolean | Suggest follow-up questions |
search_recency_filter |
string | Filter by recency (day, week, month, year) |
# Advanced search configuration
response = client.chat.completions.create(
model="sonar-pro",
messages=[{"role": "user", "content": "Recent tech layoffs?"}],
extra_body={
"search_domain_filter": ["techcrunch.com", "theverge.com"],
"search_recency_filter": "week",
"return_related_questions": True
}
)
Citations and Sources
Perplexity automatically includes citations. Extract and display them:
def get_response_with_citations(client, query, model="sonar"):
"""Get response with structured citations."""
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": query}]
)
content = response.choices[0].m
Установить using-perplexity-platform в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл using-perplexity-platform?
Perplexity Sonar API development with search-augmented generation, real-time web search, citations, and OpenAI-compatible Chat Completions. Use for AI-powered applications requiring up-to-date information, research assistants, and grounded responses with sources.
Как установить скилл using-perplexity-platform?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл using-perplexity-platform запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic