perplexity-sdk-patterns

Featured

Apply production-ready Perplexity Sonar API patterns for TypeScript and Python. Use when implementing Perplexity integrations, refactoring SDK usage, or establishing team coding standards for search-augmented generation. Trigger with phrases like "perplexity SDK patterns", "perplexity best practices", "perplexity code patterns", "idiomatic perplexity", "perplexity wrapper".

AI & Automation 2,266 stars 315 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Perplexity SDK Patterns ## Overview Production-ready patterns for Perplexity Sonar API. Since Perplexity uses the OpenAI wire format, you build wrappers around the `openai` client library with Perplexity-specific response handling (citations, search results, related questions). ## Prerequisites - `openai` package installed (`npm install openai` or `pip install openai`) - API key configured in `PERPLEXITY_API_KEY` - Understanding of OpenAI chat completions format ## Instructions ### Step 1: Typed Client Singleton (TypeScript) ```typescript // src/perplexity/client.ts import OpenAI from "openai"; export interface PerplexityChatCompletion extends OpenAI.ChatCompletion { citations?: string[]; search_results?: Array<{ title: string; url: string; date?: string; snippet: string; }>; related_questions?: string[]; } export interface PerplexityUsage extends OpenAI.CompletionUsage { citation_tokens?: number; num_search_queries?: number; reasoning_tokens?: number; } let instance: OpenAI | null = null; export function getClient(): OpenAI { if (!instance) { if (!process.env.PERPLEXITY_API_KEY) { throw new Error("PERPLEXITY_API_KEY not set"); } instance = new OpenAI({ apiKey: process.env.PERPLEXITY_API_KEY, baseURL: "https://api.perplexity.ai", }); } return instance; } ``` ### Step 2: Search with Full Response Parsing ```typescript // src/perplexity/search.ts import { getClient, PerplexityChatCompletion } from ...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
7 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

perplexity-reliability-patterns

Implement reliability patterns for Perplexity Sonar API: circuit breaker, model fallback, streaming timeout, and citation validation. Trigger with phrases like "perplexity reliability", "perplexity circuit breaker", "perplexity fallback", "perplexity resilience", "perplexity timeout".

2,266 Updated today
jeremylongshore
AI & Automation Featured

perplexity-known-pitfalls

Identify and avoid Perplexity anti-patterns and common integration mistakes. Use when reviewing Perplexity code, onboarding new developers, or auditing existing integrations for best practices violations. Trigger with phrases like "perplexity mistakes", "perplexity anti-patterns", "perplexity pitfalls", "perplexity code review", "perplexity gotchas".

2,266 Updated today
jeremylongshore
AI & Automation Featured

perplexity-install-auth

Install and configure Perplexity Sonar API authentication. Use when setting up a new Perplexity integration, configuring API keys, or initializing the OpenAI-compatible client for Perplexity. Trigger with phrases like "install perplexity", "setup perplexity", "perplexity auth", "configure perplexity API key", "perplexity sonar setup".

2,266 Updated today
jeremylongshore
AI & Automation Featured

perplexity-reference-architecture

Implement Perplexity reference architecture with model routing, citation pipeline, and research automation. Use when designing new Perplexity integrations, reviewing project structure, or establishing architecture for search-augmented apps. Trigger with phrases like "perplexity architecture", "perplexity project structure", "how to organize perplexity", "perplexity design patterns".

2,266 Updated today
jeremylongshore
AI & Automation Featured

perplexity-local-dev-loop

Configure Perplexity local development with mocking, testing, and hot reload. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with Perplexity Sonar API. Trigger with phrases like "perplexity dev setup", "perplexity local development", "perplexity dev environment", "develop with perplexity", "mock perplexity".

2,266 Updated today
jeremylongshore