Mixed Results with Perplexity API

So overall I’m happy with the API. As far as I know it’s the only one that is actually returning web results. I do not believe that this is a feature as of yet with ChatGPT or Gemini.

What I’ve found is an extreme inconsistency with our results. If we pull in 10 API searches for the same (similar) query maybe 3 of them appear to be complete results with full details and the other 7 are very abbreviated with far fewer details. Sometimes the ratio changes to 50/50 etc. The interesting thing is, for the 7 or so that return abbreviated results IF we run the exact same query again almost 100% of the time the next results is far superior with more sources cited and the results being far more detailed and useful for our needs.

Because of the type of app that we have that includes personal names and data I cannot share specific queries on here but I believe quite a few users have expressed having the same issues. So my questions are; is there anything I can do with my API calls to increase the return value on the first query. It seems odd to me that I’m running the exact same query twice and get much better results on the 2nd attempt so often. OR is this just an issue on the end of Perplexity that will improve over time?

We are probably using 60%-70% more tokens than necessary by having to run so many of these twice.

If someone that actually works with Perplexity would like to chat with me personally I would be happy to run through my code and give examples. I have also made a video of these occurrences that I’d be happy to send to their tech team.

Any advice would be great. Thanks!

Follow-up: The staff at perplexity API department got back to me to assist.

I’m posting the resolution here for anyone that might be experiencing the same issues. I was pushing through parameters such as top_k, top_p, presence_penalty, temperature and these parameters were actually preventing the return of optimal results. It seems as though a very simple query with just the user content message and possibly some instruction as system content is really needed for optimal returns.

Example code:
curl --request POST --url https://api.perplexity.ai/chat/completions --header ‘accept: application/json’ --header “authorization: Bearer ${PPLX_KEY}” --header ‘content-type: application/json’ --data ‘{“model”: “llama-3.1-sonar-large-128k-online”, “messages”: [{“role”: “user”, “content”: “Your query here”}], “stream”: false}’ | jq

Hopefully this helps anyone who might be experiencing similar issues with the API.