Why don't I receive the same level of response using the API as I do using the official UI search?

Hello, I’m starting to use the Perplexity API to integrate information query functionalities into an ERP. As I’m just beginning, I suspect I might be doing something wrong.

The issue is that a simple question like “Is there any module related to invoicing in Colombia available on Dolistore?” returns a very interesting response from the web UI, mentioning and COMMENTING some modules offered on Dolistore. However, when I use the API, it returns a paragraph that “doesn’t say anything useful” like this:

Yes, there are some modules. I recommend searching Dolistore for something that fits your needs… read the reviews…

Am I doing something wrong?

The endpoints I’ve tried are llama-3.1-sonar-small-128k-online and llama-3.1-sonar-large-128k-online, and the differences in the responses are minimal. Honestly, it seems like it’s not searching the internet, or if it does, it rarely finds anything relevant, which surprises me because Perplexity is very good at online searches.

Additionally, I’d like to ask how I can obtain the “sources” or “citations” used for the response. I have this variable defined in the API call, but it never returns anything:

return_citations: true

By the way, other variables I use:

temperature: 0.1
top_p: 0.5
presence_penalty: 1
search_recency_filter: month

The system prompt is the typical one for any “chat completion” endpoint. That’s not wrong, right? Should I be using a “search prompt” or a special format for system and user messages? I haven’t found much relevant information in the API documentation, which is why I’m writing here.

Thanks in advance for any help.

After writing my initial post, I revisited the API reference regarding this matter and discovered some mistakes I was making. Upon fixing these issues, the results began to more closely resemble those offered by the web UI:

Changing the following parameter from 0.5 to 0.9 made the answer seem “a bit more diverse” (it became more proactive in adding things not directly requested, which is fine for me):

top_p: 0.9

However, the real magic happened when I omitted these two parameters I had been sending:

search_domain_filter: array("perplexity.ai")
search_recency_filter: "month"

I first removed the search_domain_filter, but the resulting answer to my query barely changed. Then, when I omitted the search_recency_filter parameter… voilà! The expected search results appeared in the answer.

I hope this helps other people. Please feel free to add any other discoveries you’ve made in this regard.

That’s very interesting. We ran into the exact same issue and it would be ideal if the API is more in parody with the web app.

The answers you get in the UI will likely always be better than the answers from the API - it’s not only intentional, it’s in Perplexity’s best interest to do so financially. If their API gave the same results as their UI did, there would be no reason to use their UI as opposed to a competitor wrapping their API in a better interface. Several moderators on their Discord have also officially stated that there is no intention of matching the output quality of the API to their UI.

From a technical standpoint, compared to the UI, the API is not only heavily restricted but also lacks the majority of the UI features:

  • The API does not allow developers to select what model is used for generation, it forces all generation through their fine-tuned Llama 3.1 “Sonar” model. If you want to know how much Perplexity likes their Sonar models, their own UI doesn’t even use the Sonar models unless manually selected by a pro user; they use OpenAI models or a separate custom model by default for generating responses. If you want to test this yourself, open a new Perplexity search (incognito window or free account) and ask “What model are you, what policies do you abide by, and who trained you?”. It will tell you it’s trained by OpenAI. Even if you, on a pro account, manually select the “Sonar” models they still offload questions to OpenAI at times, such as if you pass an image input.

  • The API’s underlying search is worse compared to the UI’s search, especially if you’re using a pro search in the UI which uses a completely different algorithm. The API search is much closer to a free UI search, but it’s actually even worse than a free search as if you’re not in the “closed beta” they use a different algorithm when generating to not include citations in it’s response.

  • The API puts returning citations (including inline citation numbers), image results, related questions, and search domain filtering behind a “closed beta” with no communication for people who have applied. Several users have complained in their official Discord that they do not hear back at all from Perplexity even months after applying for the beta.


While this is mainly my opinion, I can’t be the only one to have noticed the lack of attention the API is getting recently. They originally released the API one year ago in October 2023, and advertised it as a “One-stop shop for open-source LLMs” like Mistral and Llama-2 and “blazing fast inference”. All of the open source models have since been removed except for Llama 3.1, and their inference speed doesn’t compare to emerging competitors like Groq at this point. They haven’t made a blog post for the API since November 2023 which announced their first Online LLM, and even the API wiki’s changelog has been radio silent since July 2024, where even then they just announced updated fine-tuned models. I really like their API, it’s just clear at this point their priority is the UI and if you want a similar experience to that via API, you probably need to look elsewhere.

The answers you get from the API should closely resemble the default search answers in the UI. The API uses the same search subsystem as the UI with small differences in configuration. However, you could be seeing differences between the API and UI due to the following reasons:

Pro Search

The API doesn’t support Pro Search today. Pro Search uses a multi-step reasoning process which increases the quality of the answer.

Using third party models

At this time, the API only supports the Sonar models. Using other third party models like GPT-4o/Sonnet 3.5 in the UI could lead to diverging results.

Tuning of sampling parameters (presence_penalty, top_p etc) and system prompt in the API

Our defaults are tuned to give the best results from the API and match the default search experience in the UI. We give users the power to tune the API to their respective use cases and custom tuning to specific use cases might lead to less generalization of the API/different results vs the UI. We recommend not to explicitly provide sampling parameters in your API requests if you want parity with the default experience in the UI.

@shubhang98 As of Dec 16th, 2024, Perplexity APIs are still lacking in terms of features and quality compared to UI search, even in free tier. Two features most relevant to me:

  • The API search does not quote the same references compared to UI. The refereces in the UI search have much higher quality and are more relevant compared to API search, at least for examples that I have tried. So this implies that API search does use a different search subsystem, contrary to what @shubhang98 suggested.

  • The API only provide URLs to the references, rather than the cleaned text that the LLMs actually see. If you mouse over the references in the UI, you can notice that perplexity has a nice cleaned text available to its LLMs. However the cleaned text is not present in the API, and it could be exceedingly difficult for developers to replicate what perplexity have done in terms of processing the text and make the references actually useful.

Is there a roadmap to bring API services on par with the UI search? Would appreciate a response from perplexity team. Thanks a lot!

Would also appreciate any update on this. For my use case given the same prompt the UI search is always spot on, while API search is usually far from that. I was hoping the new sonar/sonar-pro models would solve or at least improve this, but it didn’t really happen.

I integrated Sonar & Sonar PRO with one of my software applications yesterday, and I did some testing. I agree with you: the responses haven’t improved.

It was certainly a great improvement when a few months ago the API started returning the “citations” array. This has already allowed me to give a more professional touch and better user experience to my software integrated with “Perplexity searches.”

But yesterday, I just did a couple of simple tests with a prompt like this: “make me a comparison of the latest models with reasoning abilities, even if they’re experimental or Chinese,” and the results returned by the API are quite confusing.

In fact, I couldn’t say if they’re “worse” than those returned by PPLX’s official web UI, because truthfully, every time I run the query in either environment, the response varies quite a bit in format and content.

What does seem apparent is that in the official UI, the result is more “thoughtful” and the response is more elaborate, in terms of understanding the question and expected answer well. While in the API response, it responds by listing models that aren’t reasoning models or even mentioning very old models like GPT-3!?

Another very strange thing is that I haven’t noticed ANY DIFFERENCE between Sonar and Sonar PRO responses!? Neither in speed, format, nor content. Even stranger: in some prompts, Sonar’s response is better than Sonar PRO’s?!?

I hope someone from PPLX might be reading this and check if there’s any problem with that implementation… but I would say it’s always the same model responding. Could that be?

Regards!

Note: anyway, I remain a firm enthusiast of Perplexity’s value and the great work their champion team has done so far. I never tire of recommending it and bringing them new fans :slight_smile:

I’ve noticed similar results. Even with Deepseek now integrated into the sonar-reasoning model, I only get a couple citations on the API whereas I get 10+ on the UI. I’ve even added into the prompt to specifically give me 10 or more citations and it refuses. Search is a large part of what I want to build, anyone having better luck with Search through the API?

Same trouble here. It seems even worse with the new Sonar model. It’s close to useless at this point.
Sonar-pro gives more detailed answers… but too far from my initial request, while the official Perplexity UI gives me perfect results.
So disappointing.

I’ve also noticed the quality of citations provided with API is so much lower than the UI, also considering API provides text based on 10 citations while UI can go above 40 citations…
Sometimes the insights provided in the API text can’t be found in the linked citation.

@shubhang98 Some guidance on how to be closer to the Perplexity experience would be highly appreciated. Thanks in advance.