saw a q about this arg not working below, but want to flush it out.
seeing:
TypeError: create() got an unexpected keyword argument ‘search_domain_filter’ when using:
response = client.chat.completions.create(
model="sonar-pro",
messages=messages,
search_domain_filter = ['example.domain']
)
is search domain filter only supported for post request?
The OpenAI API doesn’t know anything about Perplexity’s parameters. If you are ever using the OpenAI API for another API, and the other API has unique parameters, you have to pass them in extra_body
.
response = client.chat.completions.create(
model="sonar-pro",
messages=[
{
"role": "user",
"content": "What is the most recent version of Python?"
}
],
extra_body={"search_domain_filter": ["-python.org"]},
)
We know this works as well because you can use their search recency filter this way and the citations are correctly filtered (extra_body={"search_recency_filter": "hour"}
will work).
But I wouldn’t bother with search domain filters, as you said the feature doesn’t work and it hasn’t worked for over a year now. Maybe they plan to support it, but I can’t speak for them.