Date filtering not working for academic search mode - Sonar API

:bug: Describe the Bug

When the search_after_date_filter parameter is used together with the academic search mode parameter in a sonar api call, it just gets ignored. When the “web” search mode is used, the date filtering works and is respected.

There are no constraints at all on the date filter parameter (I’m able to pass anything as a date and it won’t give me an error response) when used together with the academic search mode, but constraints work properly when the search mode parameter is omitted or the “web” search mode is specified instead.

The api docs explicitly say that the academic search mode and the date filter should work together: https://docs.perplexity.ai/guides/academic-filter-guide

:white_check_mark: Expected Behavior

The response returning search results that are limited to the specified date filter.

:cross_mark: Actual Behavior

The response contains search results that do not adhere to the specified date filter (e.g. too old).

:counterclockwise_arrows_button: Steps to Reproduce

  1. Call the API with the following request:
curl https://api.perplexity.ai/chat/completions \
  -H "Authorization: Bearer PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar",
    "messages": [{"role": "user", "content": "Avidin biotin interaction"}],
    "search_after_date_filter": "3/5/2021",
    "search_mode": "academic",
    "stream": false
}'
  1. Observe the unexpected behavior.

:pushpin: API Request & Response (if applicable)

I’ve limited max tokens to keep it as concise as possible. It does not change the outcome of the problem.

Academic search mode + date filter

Request

curl https://api.perplexity.ai/chat/completions \
  -H "Authorization: Bearer PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar",
    "messages": [{"role": "user", "content": "Avidin biotin interaction"}],
    "search_after_date_filter": "3/5/2021",
    "search_mode": "academic",
    "stream": false,
	"max_tokens": 1
  }'

Response (old results)

{"id": "9e76717b-12b1-4e8d-a7bf-5fdb9603c640", "model": "sonar", "created": 1749723754, "usage": {"prompt_tokens": 7, "completion_tokens": 1, "total_tokens": 8, "search_context_size": "low"}, "citations": ["https://journals.sagepub.com/doi/10.1177/27.8.90074", "https://journals.physiology.org/doi/10.1152/ajpheart.00478.2021", "https://linkinghub.elsevier.com/retrieve/pii/S0039914021005701", "https://www.semanticscholar.org/paper/2611fc52942cb5cb50d8adc213ea94dbf4624996", "https://xlink.rsc.org/?DOI=c3tb00226h"], "search_results": [{"title": "The use of avidin-biotin interaction in immunoenzymatic techniques.", "url": "https://journals.sagepub.com/doi/10.1177/27.8.90074", "date": "1979-08-01"}, {"title": "Leveraging avidin-biotin interaction to quantify permeability property of microvessels-on-a-chip networks", "url": "https://journals.physiology.org/doi/10.1152/ajpheart.00478.2021", "date": "2021-11-12"}, {"title": "Electrochemical detection of kinase by converting homogeneous analysis into heterogeneous assay through avidin-biotin interaction.", "url": "https://linkinghub.elsevier.com/retrieve/pii/S0039914021005701", "date": "2021-11-01"}, {"title": "A comparison of two immunoperoxidase staining methods based on the avidin-biotin interaction.", "url": "https://www.semanticscholar.org/paper/2611fc52942cb5cb50d8adc213ea94dbf4624996", "date": null}, {"title": "Peptide-based vectors mediated by avidin-biotin interaction for tumor targeted gene delivery.", "url": "https://xlink.rsc.org/?DOI=c3tb00226h", "date": "2013-03-27"}], "object": "chat.completion", "choices": [{"index": 0, "finish_reason": "length", "message": {"role": "assistant", "content": "##"}, "delta": {"role": "assistant", "content": ""}}]}

Web search mode + date filter

Request

curl https://api.perplexity.ai/chat/completions \
  -H "Authorization: Bearer PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar",
    "messages": [{"role": "user", "content": "Avidin biotin interaction"}],
    "search_after_date_filter": "3/5/2021",
    "search_mode": "web",
    "stream": false,
	"max_tokens": 1
  }'

Response (date filter respected)

{"id": "11f96c97-3e35-4a28-90c8-5d5effe171de", "model": "sonar", "created": 1749723986, "usage": {"prompt_tokens": 7, "completion_tokens": 1, "total_tokens": 8, "search_context_size": "low"}, "citations": ["https://www.bosterbio.com/blog/post/avidin-biotin-interaction-in-assays", "https://www.southernbiotech.com/biotin-avidin-streptavidin/", "https://pubmed.ncbi.nlm.nih.gov/34767485/", "https://www.excedr.com/resources/avidin-overview", "https://biocare.net/wp-content/uploads/WP_0084.pdf"], "search_results": [{"title": "Avidin-Biotin Interaction: Applications & Benefits in Research", "url": "https://www.bosterbio.com/blog/post/avidin-biotin-interaction-in-assays", "date": "2023-06-02"}, {"title": "Streptavidin/Avidin-Biotin Interaction", "url": "https://www.southernbiotech.com/biotin-avidin-streptavidin/", "date": "2023-03-23"}, {"title": "Leveraging avidin-biotin interaction to quantify permeability ...", "url": "https://pubmed.ncbi.nlm.nih.gov/34767485/", "date": null}, {"title": "What Is Avidin: Overview, Application, & Industry Uses", "url": "https://www.excedr.com/resources/avidin-overview", "date": "2022-10-10"}, {"title": "Biocare Basics: Avidin and Streptavidin", "url": "https://biocare.net/wp-content/uploads/WP_0084.pdf", "date": "2022-04-22"}], "object": "chat.completion", "choices": [{"index": 0, "finish_reason": "length", "message": {"role": "assistant", "content": "The"}, "delta": {"role": "assistant", "content": ""}}]}

Bonus: Date input validation on different search modes

Request (academic + incorrect date format)

curl https://api.perplexity.ai/chat/completions \
  -H "Authorization: Bearer PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar",
    "messages": [{"role": "user", "content": "Avidin biotin interaction"}],
    "search_after_date_filter": "2021-03-05",
    "search_mode": "academic",
    "stream": false,
	"max_tokens": 1
  }'

Response (no error)

{"id": "ea0e6835-afe9-4273-aa04-027b6e2889a2", "model": "sonar", "created": 1749724276, "usage": {"prompt_tokens": 7, "completion_tokens": 1, "total_tokens": 8, "search_context_size": "low"}, "citations": ["https://journals.sagepub.com/doi/10.1177/27.8.90074", "https://journals.physiology.org/doi/10.1152/ajpheart.00478.2021", "https://linkinghub.elsevier.com/retrieve/pii/S0039914021005701", "https://www.semanticscholar.org/paper/2611fc52942cb5cb50d8adc213ea94dbf4624996", "https://xlink.rsc.org/?DOI=c3tb00226h"], "search_results": [{"title": "The use of avidin-biotin interaction in immunoenzymatic techniques.", "url": "https://journals.sagepub.com/doi/10.1177/27.8.90074", "date": "1979-08-01"}, {"title": "Leveraging avidin-biotin interaction to quantify permeability property of microvessels-on-a-chip networks", "url": "https://journals.physiology.org/doi/10.1152/ajpheart.00478.2021", "date": "2021-11-12"}, {"title": "Electrochemical detection of kinase by converting homogeneous analysis into heterogeneous assay through avidin-biotin interaction.", "url": "https://linkinghub.elsevier.com/retrieve/pii/S0039914021005701", "date": "2021-11-01"}, {"title": "A comparison of two immunoperoxidase staining methods based on the avidin-biotin interaction.", "url": "https://www.semanticscholar.org/paper/2611fc52942cb5cb50d8adc213ea94dbf4624996", "date": null}, {"title": "Peptide-based vectors mediated by avidin-biotin interaction for tumor targeted gene delivery.", "url": "https://xlink.rsc.org/?DOI=c3tb00226h", "date": "2013-03-27"}], "object": "chat.completion", "choices": [{"index": 0, "finish_reason": "length", "message": {"role": "assistant", "content": "The"}, "delta": {"role": "assistant", "content": ""}}]}

Request (web + incorrect date format)

curl https://api.perplexity.ai/chat/completions \
  -H "Authorization: Bearer PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar",
    "messages": [{"role": "user", "content": "Avidin biotin interaction"}],
    "search_after_date_filter": "2021-03-05",
    "search_mode": "web",
    "stream": false,
	"max_tokens": 1
  }'

Response (actual validation done)

{"error":{"message":"Validation error: search_after_date_filter must match the format %m/%d/%Y","type":"invalid_date_format","code":400}}

:globe_showing_europe_africa: Environment

  • API Version: Any sonar model available