Perplexity's Sonar models search the web before answering. That one difference makes them the right tool when customers ask questions where the answer changes, prices, news, current availability, and a fixed knowledge base will not do.
Every other AI provider in this series generates replies from a trained model's fixed knowledge. Perplexity's Sonar models search the live web as part of the request, then cite their sources in the response. The API format is nearly identical to OpenAI's, which means the setup is quick if you have done any of the other AI connection guides.
The use-case fit matters: Sonar is valuable when your customers ask questions whose answers change over time. For scripted support, FAQ-style flows, or tasks where your own content is the knowledge base, a standard model without web search is faster and cheaper.
New to the External API Request step? Read the foundation guide first.
Current model list and pricing: docs.perplexity.ai/guides/model-cards. Perplexity releases new model versions regularly; check the docs for the current recommended Sonar model name.
https://api.perplexity.ai/chat/completions| Header | Value |
|---|---|
| Authorization | Bearer YOUR_PPLX_KEY |
| Content-Type | application/json |
{
"model": "sonar",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant. Answer concisely."
},
{
"role": "user",
"content": "{{customer_message}}"
}
]
}The sonar model uses web search to answer. The response includes a citations array alongside the answer text. If you want a version without web search, Perplexity also offers sonar-pro and other models; check their model cards for current options.
{
"choices": [
{
"message": {
"role": "assistant",
"content": "...Perplexity's answer is here..."
}
}
],
"citations": [
"https://source-used-to-answer.com/page"
]
}Map choices[0].message.content for the answer text. The citations array is available separately if you want to append source links to the WhatsApp message; it can be ignored if you only need the answer.
| Symptom | Likely cause | Fix |
|---|---|---|
| 401 Unauthorized | Wrong key or missing Bearer prefix | Check the key starts with pplx- and the header value starts with Bearer |
| 402 Payment Required | No API credits | Add API credits in perplexity.ai settings (separate from Pro subscription) |
| 422 Unprocessable | Invalid model name | Check docs.perplexity.ai for the current model name; sonar is the standard search-augmented option |
| Slow responses | Web search adds latency | Expected behaviour for search-augmented models; add a wait message in your flow if needed |
Free trial, no credit card required. And if you ever get stuck, we are the only platform in India that answers you live on WhatsApp.