A shared folder with AI prompts and code snippets
From workspace: Perplexity
Team: Main
Total snippets: 6
6 snippets
- Adding domain filters may slightly increase response time as the search engine needs to apply additional filtering. - Overly restrictive domain filters might result in fewer search results, potentially affecting the quality of the response.
- Be specific: Use domains that are most relevant to your query to get the best results. - Combine approaches: You can mix inclusion and exclusion in the same request (e.g., ["wikipedia.org", "-pinterest.com"]). - Limit filter size: Although you...
- Use simple domain names: Specify domains in their simplest form (e.g., example.com) without protocol prefixes (http://, https://) or subdomain specifiers (www.). - Main domains only: Using the main domain (e.g., nytimes.com) will filter all...
This example shows how to exclude specific domains from search results by prefixing the domain name with a minus sign (-). Best Practice: Use simple domain names with a minus prefix (e.g., -pinterest.com) to exclude domains from search results.
import requests url = "https://api.perplexity.ai/chat/completions" headers = {"Authorization": "Bearer YOUR_API_KEY"} payload = { "model": "sonar-deep-research", "messages": [ {"role": "system", "content": "You are a helpful...
This example shows how to limit search results to only include content from specific domains. Best Practice: Use simple domain names (e.g., wikipedia.org) without additional elements like https:// or www. prefixes.
import requests url = "https://api.perplexity.ai/chat/completions" headers = {"Authorization": "Bearer YOUR_API_KEY"} payload = { "model": "sonar-reasoning-pro", "messages": [ {"role": "system", "content": "You are a helpful...
The search_domain_filter parameter allows you to control which websites are included in or excluded from the search results used by the Sonar models. This feature is particularly useful when you want to. Each entry in the list should be a simple domain name. To exclude a domain, prefix it with a minus sign (-). Restrict search results to trusted sources Filter out specific domains from search results Focus research on particular websites Enabling domain filtering can be done by adding a search_domain_filter field in the request:
"search_domain_filter": [ "<domain1>", "<domain2>", ... ]