When you call the Perplexity Sonar model through the API, you expect the response to include citations showing the sources of the information. Instead, the response may contain only the answer text with an empty citations array or no citations field at all. This problem usually occurs because the API request is missing the required parameter that enables citation generation for the Sonar model. This article explains the root cause of missing citations and provides the exact steps to include citations in every Sonar API response.
Key Takeaways: How to Restore Citations in Perplexity Sonar API Responses
- Parameter
return_citationsset totrue: This request parameter tells the Sonar model to include source citations in the response. - Parameter
return_related_questionsset totrue: While not mandatory for citations, this parameter is often included alongside citations for a richer response. - POST endpoint
/sonar/chat/completions: Use this specific endpoint and include the parameters in the JSON body of your request.
Why the Sonar API Returns Responses Without Citations
The Perplexity API Sonar model is designed to generate answers grounded in real-time web search results. By default, the API response includes only the generated text in the choices array. The model does not automatically attach citations because the API treats citation generation as an optional feature controlled by request parameters.
When you omit the return_citations parameter from your API request, the server assumes you do not want citations. This is the most common cause of missing citations. Other causes include using an older API endpoint that does not support citations or sending the parameter with an incorrect value type. The Sonar model supports citations only when you explicitly request them.
Understanding the return_citations Parameter
The return_citations parameter is a boolean value that you must include in the JSON body of your POST request to the /sonar/chat/completions endpoint. When set to true, the API returns a citations array in the response object. Each element in the array is a URL string pointing to the source used to generate the answer.
The Sonar model also supports the return_related_questions parameter. Although this parameter does not affect citations, many developers include both parameters together to obtain a comprehensive response.
Steps to Fix Missing Citations in the Sonar API Response
Follow these steps to modify your API request and ensure the Sonar model returns citations with every answer.
- Verify You Are Using the Correct Endpoint
Send your request tohttps://api.perplexity.ai/sonar/chat/completions. Using a different endpoint such as the general chat completions endpoint may not support the citation parameters. Check your code and confirm the URL is exactlyhttps://api.perplexity.ai/sonar/chat/completions. - Add the
return_citationsParameter to the Request Body
In your JSON request body, include the keyreturn_citationswith the valuetrue. Example body:{ "model": "sonar", "messages": [{"role": "user", "content": "What is the capital of France?"}], "return_citations": true }. Do not use string values like"true"; use the booleantruewithout quotes. - Optionally Add the
return_related_questionsParameter
Include"return_related_questions": truein the same request body. This parameter adds arelated_questionsarray to the response. While not required for citations, it is commonly used together with citations. - Send the Request and Inspect the Response
Execute the request. The response object should now contain acitationskey at the top level. The value is an array of URLs. Example response snippet:{ "id": "...", "citations": ["https://example.com/source1", "https://example.com/source2"], "choices": [...] }. If thecitationsarray is empty, the model could not find verifiable sources for the answer. - Test With a Known Verifiable Query
Use a factual query such as “What is the population of Tokyo?” to confirm citations appear. This query has many reliable sources, so the model should return at least one citation. If citations still do not appear, double-check the parameter name spelling and data type.
If the Sonar API Still Omits Citations After Applying the Fix
Empty Citations Array Despite Setting return_citations to true
An empty citations array means the model could not find any verifiable sources for the answer. This can happen with highly speculative questions, very recent events not yet indexed by search engines, or queries that the model answers from its training data rather than from a live search. To work around this limitation, rephrase the query to be more specific or to ask for current data. For example, instead of “What is the latest news?”, ask “What is the latest news about the Mars rover Perseverance as of October 2023?”
API Returns an Error When return_citations Is Included
If the API returns a 400 error or an invalid request error, the parameter may be misspelled or set to an incorrect type. Verify that the key is exactly return_citations with no typos. Ensure the value is the boolean true and not the string "true". Also confirm your request body is valid JSON. Use a JSON validator to check the body before sending.
Citations Appear but Are Incomplete or Incorrect
The Sonar model returns citations based on the sources it used during generation. If a citation URL is broken or points to a page that does not contain the cited information, the model may have extracted a snippet incorrectly. This is a known limitation of the Sonar model. To improve citation accuracy, ask more precise questions that match well-indexed content. For example, include the year or specific terminology in your query.
Perplexity Sonar API With Citations vs Without Citations
| Item | With return_citations: true |
Without return_citations |
|---|---|---|
| Response includes citations array | Yes | No |
| Response size | Larger due to URLs | Smaller |
| Source verifiability | High | Low |
| API latency | Slightly higher | Standard |
| Ideal use case | Research, fact-checking, academic work | Quick answers, internal tools |
After adding the return_citations parameter to your Sonar API requests, you can consistently retrieve source URLs alongside the generated answer. This feature is essential for applications that require traceable information, such as research assistants, content verification tools, and educational platforms. For best results, always pair the citation parameter with a well-formed query and validate the returned URLs in your application logic.