Comprehensive API configuration rules covering search depth, domain filtering, recency, model selection, and hallucination prevention for Perplexity Sonar models.
When using the Perplexity API (Sonar models), follow these configuration rules for optimal results: 1. SEARCH DEPTH: Use search_context_size "high" for comprehensive research and complex queries. Use "medium" (default) for balanced queries. Use "low" for simple factual lookups to reduce cost. 2. DOMAIN FILTERING: Apply search_domain_filter for specialized queries. Academic: ["scholar.google.com", "arxiv.org", "pubmed.ncbi.nlm.nih.gov"]. Technical: ["stackoverflow.com", "github.com", "docs.python.org"]. News: ["reuters.com", "apnews.com", "bbc.com"]. 3. RECENCY: Add web_search_options.search_recency_filter: "day" for breaking news, "week" for recent developments, "month" for recent trends. Omit for evergreen topics. 4. SYSTEM PROMPTS: Keep system prompts concise (under 500 tokens). Avoid special markers resembling internal tokens (<goal>, ##system##). Focus on output format and source quality requirements. 5. MODEL SELECTION: sonar (fast, cheap, simple factual queries), sonar-pro (balanced, most queries), sonar-reasoning-pro (complex analysis needing chain-of-thought), sonar-deep-research (exhaustive multi-source research, 128K context). 6. ANTI-HALLUCINATION: Always include a fail-fast instruction: "If you cannot find relevant search results, state that clearly rather than speculating."
Workflows from the Neura Market marketplace related to this Perplexity resource