Production-grade API integration rules covering rate limiting, timeouts, error handling, caching, fallback chains, and cost monitoring for Perplexity applications.
When building applications with the Perplexity API, follow these operational rules: 1. RATE LIMITS: Respect API rate limits. Implement exponential backoff starting at 1 second, doubling up to 32 seconds maximum. Track rate limit headers in responses. 2. TIMEOUT CONFIGURATION: Set timeouts appropriately per model: sonar/sonar-pro: 30-60 seconds. sonar-reasoning-pro: 60-120 seconds. sonar-deep-research: 180-300 seconds (research can take several minutes). 3. ERROR HANDLING: Handle these error codes: 400 (bad request - check input format), 401 (invalid API key), 403 (rate limited - backoff), 429 (too many requests - queue and retry), 500 (server error - retry with backoff), 503 (service unavailable - retry after delay). 4. TOKEN MANAGEMENT: Monitor token usage per request. Set max_tokens appropriately for your use case. Track costs by multiplying input/output tokens by per-model pricing. 5. CACHING: Cache responses for identical queries within a reasonable TTL (5-15 minutes for real-time data, 1-24 hours for stable information). Use content hashing for cache keys. 6. FALLBACK: Implement model fallback chains: Try sonar-pro first, fall back to sonar on error or timeout. For deep research, fall back to pro-search if sonar-deep-research times out. 7. LOGGING: Log all API calls with: timestamp, model used, token count, latency, and response status. This enables cost tracking and performance monitoring.
Perplexity Space rules for researching AI ethics, governance frameworks, responsible AI practices, and regulatory developments in artificial intelligence.
Perplexity Space configuration for researching climate science, energy policy, sustainability metrics, and environmental regulations with scientific rigor.
Perplexity Space rules for researching talent markets, compensation benchmarks, hiring trends, and building data-backed recruitment strategies.
Perplexity Space configuration for cybersecurity threat intelligence research, vulnerability tracking, incident analysis, and security posture assessment.
Rules for controlling Perplexity's output format, citation style, depth of analysis, and response structure for professional research workflows.
Perplexity Space configuration for tracking and researching regulatory compliance requirements across industries and jurisdictions.