When you query the Perplexity API, the default search behavior returns results from any time period. This can include outdated information that is not useful for tasks requiring the latest news, recent events, or time-sensitive data. The search recency filter lets you restrict results to a specific time range, such as the past day, week, or month.
This article explains how to configure the recency parameter in your API requests. You will learn the exact JSON field name, accepted values, and how to set it using Python, cURL, or any HTTP client. By the end, you will be able to control the freshness of search results from your Perplexity API calls.
Key Takeaways: Setting the Search Recency Filter
- API parameter
search_recency_filter: Accepts valuesday,week,month, oranyto limit search results by time. - Place in the request body: Add the parameter inside the top-level JSON object alongside
modelandmessages. - Works with all Perplexity API models: Supported on pplx-7b-online, pplx-70b-online, mixtral-8x7b-instruct, and others.
What the Search Recency Filter Does
The Perplexity API uses an online language model that searches the web in real time. Without a recency filter, the model retrieves the most authoritative result regardless of its publication date. This is fine for evergreen topics like historical facts or scientific principles but fails for breaking news, stock prices, or recent product launches.
The search_recency_filter parameter instructs the model to prioritize or restrict results to a specific time window. The filter works by passing the time constraint to the underlying search engine before the model processes the results. The model then generates an answer based only on sources that match the recency requirement.
Supported Values
The parameter accepts four string values:
- day — restrict results to the past 24 hours
- week — restrict results to the past 7 days
- month — restrict results to the past 30 days
- any — no time restriction, equivalent to not setting the filter
Prerequisites
Before using the recency filter, ensure you have:
- A valid Perplexity API key from the Perplexity API dashboard
- An HTTP client such as cURL, Python with the
requestslibrary, or Postman - Knowledge of how to send a POST request to the Perplexity API endpoint
Steps to Set the Search Recency Filter in Your API Request
The filter is set by adding a single JSON key-value pair to the request body. The exact placement matters: the parameter must be at the top level of the JSON object, not inside the messages array.
Method 1: Using cURL
- Open your terminal or command prompt
Ensure cURL is installed on your system. On Windows 10 and Windows 11, you can use PowerShell or the Command Prompt. - Compose the POST request
Use the following command, replacing YOUR_API_KEY with your actual key:curl -X POST https://api.perplexity.ai/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "pplx-7b-online", "messages": [{"role": "user", "content": "What is the latest news about AI regulation?"}], "search_recency_filter": "week"}' - Execute the request
Press Enter. The API will return a response with sources and text limited to the past week. - Verify the filter in the response
Check that theusageobject in the response includessearch_recency_filterset toweek.
Method 2: Using Python with the Requests Library
- Import the requests library
Addimport requestsat the top of your Python script. - Define the API endpoint and headers
url = "https://api.perplexity.ai/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
} - Build the payload with the recency filter
payload = {
"model": "pplx-7b-online",
"messages": [
{"role": "user", "content": "What are the latest cybersecurity threats?"}
],
"search_recency_filter": "day"
} - Send the POST request
response = requests.post(url, headers=headers, json=payload)
print(response.json()) - Run the script
Execute the Python file. The response will contain results from the last 24 hours only.
Method 3: Using Postman
- Create a new POST request
Set the request URL tohttps://api.perplexity.ai/chat/completions. - Set the Authorization header
Add a header with keyAuthorizationand valueBearer YOUR_API_KEY. - Set the Content-Type header
Add a header with keyContent-Typeand valueapplication/json. - Write the JSON body
In the Body tab, select “raw” and paste:{
"model": "pplx-7b-online",
"messages": [
{"role": "user", "content": "What are the latest tech stock prices?"}
],
"search_recency_filter": "month"
} - Send the request
Click Send. The response will show results from the last 30 days.
Common Mistakes and Things to Avoid
Filter Not Applied Even Though Parameter Is Set
If the API returns results from outside the specified time range, check that the search_recency_filter parameter is at the top level of the JSON body. Placing it inside the messages array or nested under another key will cause it to be ignored. Also verify that the string value is lowercase and spelled correctly: day, week, month, or any.
Filter Works with Some Models but Not Others
The recency filter is supported on all online models but may not work on offline models that do not have internet access. Ensure you are using a model name that includes -online in its identifier, such as pplx-7b-online or mixtral-8x7b-instruct.
Filter Is Ignored When Search Disabled
If you set "search_domain": false or omit the search domain entirely, the model does not perform a web search. The recency filter has no effect because no search is executed. Always include a search domain or leave the default behavior intact.
Perplexity API Search Recency Filter: Available Values and Effect
| Filter Value | Time Restriction | Use Case |
|---|---|---|
day |
Past 24 hours | Breaking news, live event results, urgent alerts |
week |
Past 7 days | Weekly summaries, recent product reviews, stock market trends |
month |
Past 30 days | Monthly reports, policy changes, software version updates |
any |
No restriction | Evergreen content, historical facts, foundational knowledge |
The recency filter applies to the search results before the model generates the answer. It does not filter the model’s own knowledge cutoff date. For example, if you ask about a historical event using search_recency_filter: "day", the model will still use its training data but will only search the web for recent articles about that event.
You can combine the recency filter with other parameters like temperature, max_tokens, and search_domain. The filter does not affect the number of search results returned; it only restricts their publication time.
Now you can set the search recency filter in any Perplexity API request to get time-bound answers. Start by testing with the week value for the best balance of freshness and result availability. For a more granular approach, combine the recency filter with the search_domain parameter to restrict results to a specific website and time range simultaneously.