Perplexity API Recency Filter Returns Old Sources: Fix
🔍 WiseChecker

Perplexity API Recency Filter Returns Old Sources: Fix

When you set a recency filter in the Perplexity API to limit results to the last week or month, the API may still return older sources. This defeats the purpose of the filter and can make your application appear stale. The problem is caused by how the API handles the recency parameter in combination with certain search domains and model versions. This article explains the root cause of the filter not working and provides a step-by-step fix to ensure the API returns only recent sources.

Key Takeaways: Perplexity API Recency Filter Not Working

  • recency parameter in API request body: Must be set to a valid value such as “day”, “week”, “month”, or “year” to limit source age.
  • search_domain parameter: Must be set to “internet” or left empty for recency to apply; the “academic” domain overrides recency.
  • model version check: Use model “sonar-pro” or “sonar-small” for consistent recency behavior; older models may ignore the parameter.

ADVERTISEMENT

Why the Perplexity API Recency Filter Fails

The Perplexity API accepts a recency parameter in the request body that should restrict sources to a specific time window. When this parameter does not work, one of three conditions is usually responsible.

First, the recency parameter is case-sensitive and must be one of the exact string values: day, week, month, or year. Any other value or a typo causes the API to ignore the filter entirely and return all sources regardless of age.

Second, the search_domain parameter can override the recency filter. When search_domain is set to academic, the API searches through academic papers and databases that may not have reliable publication dates. In this mode, the recency filter is not enforced, and the API returns whatever sources match the query regardless of their publication date.

Third, older model versions of the Perplexity API do not support the recency parameter at all. The models sonar-pro and sonar-small support recency filtering. Older models such as pplx-7b-online or pplx-70b-online ignore the parameter silently.

Steps to Make the Recency Filter Work Correctly

Follow these steps in order to ensure your API calls respect the recency filter. Each step addresses one of the root causes described above.

  1. Check the recency parameter value
    Open your API request body and locate the recency field. Verify the value is exactly one of day, week, month, or year in lowercase. Correct any typos or incorrect casing. Example: "recency": "week".
  2. Set search_domain to internet or remove it
    If your request includes search_domain, set it to internet or remove the parameter entirely. Do not use academic if you need recency filtering. Example: "search_domain": "internet".
  3. Update the model to sonar-pro or sonar-small
    Change the model field in your request to sonar-pro or sonar-small. These are the current models that support recency filtering. Example: "model": "sonar-pro".
  4. Send a test request
    Send a simple query such as “latest news on AI” with recency set to day. Inspect the response and check the created_at or published_date fields in each source object. All dates should be within the last 24 hours.
  5. Log the response for debugging
    In your application code, log the full API response after each request. Look for the sources array and check the published_date field of each source. If any source is older than the recency window, the filter is still not working.

ADVERTISEMENT

If the Recency Filter Still Returns Old Sources

“I am using sonar-pro but still see old sources”

The sonar-pro model supports recency filtering, but it also has a fallback behavior. If the API cannot find enough recent sources for a query, it may include older sources to meet the minimum source count. This is by design to prevent empty responses. To mitigate this, make your query more specific to the recent time period. For example, instead of “machine learning trends”, use “machine learning trends 2024”.

“The recency parameter is set but the API response has no published_date field”

Some sources in the response may not have a published_date field at all. This happens when the source is a PDF, a forum post, or a page without a clear publication timestamp. The API still includes these sources even if they are old because it cannot determine their age. In this case, filter the sources in your application by checking if the published_date field exists and if it falls within your desired window.

“I am using the academic domain and need recent papers”

The academic domain does not support recency filtering because many academic papers do not have reliable publication dates. To get recent academic sources, use the internet domain and add the word “recent” or the current year to your query. For example, “recent studies on quantum computing 2024”. This forces the API to search the general web for recent articles that mention academic work.

Item Works with Recency Ignores Recency
Model sonar-pro, sonar-small pplx-7b-online, pplx-70b-online
Search domain internet (or no domain) academic
Recency value day, week, month, year any other value or typo

The conclusion is straightforward. To fix the recency filter in the Perplexity API, use model sonar-pro or sonar-small, set search_domain to internet, and pass a valid recency value. If you still see old sources, add a post-filter in your application that checks the published_date field. For advanced use, consider setting the recency value to day and appending the current year to your query to further narrow results.

ADVERTISEMENT