perplexity-performance-tuning

Featured

Optimize Perplexity Sonar API performance with caching, streaming, model routing, and batching. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Perplexity integrations. Trigger with phrases like "perplexity performance", "optimize perplexity", "perplexity latency", "perplexity caching", "perplexity slow".

AI & Automation 2,940 stars 439 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 Performance Tuning ## Overview Optimize Perplexity Sonar API for latency, throughput, and cost. Key insight: every Perplexity call performs a live web search, so response times are inherently variable. Typical latencies: sonar 1-3s, sonar-pro 3-8s, sonar-deep-research 10-60s. ## Latency Benchmarks | Model | Typical Latency | Max Tokens | Best For | |-------|----------------|------------|----------| | `sonar` | 1-3s | 4096 | Quick answers, simple facts | | `sonar-pro` | 3-8s | 8192 | Deep research, many citations | | `sonar-reasoning-pro` | 5-15s | 8192 | Multi-step analysis | | `sonar-deep-research` | 10-60s | 8192 | Comprehensive reports | ## Prerequisites - Perplexity API key configured - Understanding of search-augmented generation latency patterns - Cache infrastructure (Redis or in-memory LRU) ## Instructions ### Step 1: Smart Model Routing ```typescript import OpenAI from "openai"; const perplexity = new OpenAI({ apiKey: process.env.PERPLEXITY_API_KEY, baseURL: "https://api.perplexity.ai", }); type QueryComplexity = "simple" | "standard" | "deep"; function classifyQuery(query: string): QueryComplexity { const words = query.split(/\s+/).length; const simplePatterns = [/^what is/i, /^who is/i, /^when did/i, /^define/i, /^how many/i]; const deepPatterns = [/compare.*vs/i, /analysis of/i, /comprehensive/i, /pros and cons/i, /in-depth/i]; if (simplePatterns.some((p) => p.test(query)) && words < 15) return "simple"; if (deepPatterns.some((...

Details

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

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category