Citations not returned when using AI Gateway with Perplexity

Hi everyone,

I’m currently using the Vercel AI Gateway with the OpenAI SDK and routing requests to Perplexity. The responses are coming back correctly, but the citations are not included in the response payload.

When I call Perplexity directly (without going through the AI Gateway), I do receive the citations as expected. But when I use the AI Gateway, those citations are missing.

Has anyone else experienced this issue? Is this a known limitation or a potential bug in how the AI Gateway handles Perplexity responses?

Thanks in advance!

2 Likes

Same issue here: via Vercel AI Gateway (OpenAI SDK → Perplexity) I’m missing citations in the response payload, but direct Perplexity returns them.

Hi @rafaelscloud-8927, @techbeme, do you have any code example that I can use to recreate the issue? It’ll greatly speed up the process for a resolution.

When calling Perplexity Sonar through Vercel AI Gateway using the OpenAI-compatible /v1/chat/completions endpoint, the response does not include citations/sources.
If I call Perplexity directly (bypassing the Gateway), the same prompt returns the expected citations. This suggests the Gateway/OpenAI compatibility layer is dropping or not forwarding the citation parts.

Repro with cURL

curl -X POST "https://ai-gateway.vercel.sh/v1/chat/completions" \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "perplexity/sonar",
    "messages": [
      {
        "role": "user",
        "content": "Why is the sky blue?"
      }
    ],
    "stream": false
  }'

Actual result

  • The JSON response contains the answer text, but no citations/sources (e.g., no source parts or citation metadata surfaced to the client).
{
   "id":"...",
   "object":"chat.completion",
   "created":1759481405,
   "model":"perplexity/sonar",
   "choices":[
      {
         "index":0,
         "message":{
            "role":"assistant",
            "content":"The sky is blue because molecules in Earth's atmosphere scatter blue light more than other colors due to Rayleigh scattering, which affects shorter wavelengths of light more strongly. Blue and violet light have shorter wavelengths, so they are scattered in all directions by air molecules, making the sky appear blue to our eyes[1][2][3][4].\n\nSunlight is composed of all colors mixed together, appearing white. When sunlight reaches the atmosphere, blue light's short wavelengths scatter more than red or orange light, which have longer wavelengths. This scattering sends blue light across the sky, visible from any direction[1][3][4].\n\nAt sunrise and sunset, sunlight travels through more atmosphere, scattering away most of the blue light and allowing longer red and orange wavelengths to dominate, which is why the sky appears reddish during those times[3].\n\nIn summary, **Rayleigh scattering of shorter-wavelength blue light by atmospheric molecules is the fundamental reason the sky looks blue during the day**[1][2][3][4][6].",
            "provider_metadata":{
               "perplexity":{
                  "images":null,
                  "usage":{
                     "citationTokens":null,
                     "numSearchQueries":null
                  }
               },
               "gateway":{
                  "routing":{
                     "originalModelId":"perplexity/sonar",
                     "resolvedProvider":"perplexity",
                     "resolvedProviderApiModelId":"sonar",
                     "internalResolvedModelId":"perplexity:sonar",
                     "fallbacksAvailable":[
                        
                     ],
                     "internalReasoning":"Selected perplexity as preferred provider for sonar. 0 fallback(s) available: ",
                     "planningReasoning":"System credentials planned for: perplexity. Total execution order: perplexity(system)",
                     "canonicalSlug":"perplexity/sonar",
                     "finalProvider":"perplexity",
                     "attempts":[
                        {
                           "provider":"perplexity",
                           "internalModelId":"perplexity:sonar",
                           "providerApiModelId":"sonar",
                           "credentialType":"system",
                           "success":true,
                           "startTime":236996.161208,
                           "endTime":241940.290571
                        }
                     ]
                  },
                  "cost":"0.000212",
                  "generationId":"..."
               }
            }
         },
         "logprobs":null,
         "finish_reason":"stop"
      }
   ],
   "usage":{
      "prompt_tokens":6,
      "completion_tokens":206,
      "total_tokens":212,
      "prompt_tokens_details":{
         "cached_tokens":0
      },
      "completion_tokens_details":{
         "reasoning_tokens":0
      },
      "cache_creation_input_tokens":0,
      "cost":0.000212,
      "is_byok":false
   },
   "system_fingerprint":"...",
   "generationId":"..."
}

Expected behavior

  • Citations/sources provided by Perplexity Sonar should be present in the response when routed via AI Gateway’s OpenAI-compatible endpoint, matching the behavior of calling Perplexity’s API directly and the docs that state Sonar returns citations.

https://docs.perplexity.ai/getting-started/quickstart#heres-an-example-response-raw-response-at-the-end

{
  "id": "66f3900f-e32e-4d59-b677-1a55de188262",
  "model": "sonar-pro",
  "created": 1756485272,
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 315,
    "total_tokens": 327,
    "search_context_size": "low",
    "cost": {
      "input_tokens_cost": 0.0,
      "output_tokens_cost": 0.005,
      "request_cost": 0.006,
      "total_cost": 0.011
    }
  },
  "citations": [
    "https://en.wikipedia.org/wiki/2025_French_Open_%E2%80%93_Men's_singles_final",
    "https://www.espn.com/tennis/scoreboard/tournament/_/eventId/172-2025/competitionType/1",
    "https://www.cbssports.com/tennis/news/2025-french-open-results-schedule-as-jannik-sinner-faces-carlos-alcaraz-coco-gauff-earns-first-title/",
    "https://www.youtube.com/watch?v=jrkwqoI-gEg",
    "https://en.wikipedia.org/wiki/2025_French_Open_%E2%80%93_Men's_singles"
  ],
  "search_results": [
    {
      "title": "2025 French Open – Men's singles final",
      "url": "https://en.wikipedia.org/wiki/2025_French_Open_%E2%80%93_Men's_singles_final",
      "date": "2025-06-08",
      "last_updated": "2025-08-09",
      "snippet": "After 5 hours and 29 minutes of play, Alcaraz defeated Sinner 4–6, 6–7 (4–7) , 6–4, 7–6 (7–3) , 7–6 (10–2) , in the longest French Open final in history."
    },
    {
      "title": "2025 Roland Garros Men's Singles Tennis Live Scores - ESPN",
      "url": "https://www.espn.com/tennis/scoreboard/tournament/_/eventId/172-2025/competitionType/1",
      "date": "2025-06-08",
      "last_updated": "2025-08-29",
      "snippet": "2025 Roland Garros Scores May 18 - June 8, 2025 Court Philippe-Chatrier, Paris, France Men's Singles 2025 Carlos Alcaraz Defending Champion Carlos Alcaraz."
    },
    {
      "title": "2025 French Open: Results, schedule as Jannik Sinner ...",
      "url": "https://www.cbssports.com/tennis/news/2025-french-open-results-schedule-as-jannik-sinner-faces-carlos-alcaraz-coco-gauff-earns-first-title/",
      "date": "2025-06-07",
      "last_updated": "2025-08-29",
      "snippet": "The women's final is on June 7, and the men's final is one day later on June 8. Men's final. (1) Jannik Sinner vs. (2) Carlos Alcaraz -- Sunday, ..."
    },
    {
      "title": "Alcaraz, Gauff Win French Open 2025 | Swiatek, Ruud Fall - YouTube",
      "url": "https://www.youtube.com/watch?v=jrkwqoI-gEg",
      "date": "2025-06-09",
      "last_updated": "2025-08-04",
      "snippet": "We had some big changes in the rankings also. What was your favorite moment? 0:00 | Intro 0:14 | Weekly Results 0:36 | Rise & Fall 1:24 ..."
    },
    {
      "title": "2025 French Open – Men's singles",
      "url": "https://en.wikipedia.org/wiki/2025_French_Open_%E2%80%93_Men's_singles",
      "date": "2025-04-27",
      "last_updated": "2025-08-29",
      "snippet": "Defending champion Carlos Alcaraz defeated Jannik Sinner in the final, 4–6, 6–7, 6–4, 7–6, 7–6 to win the men's singles tennis title at the 2025 French Open. ..."
    }
  ],
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "**Carlos Alcaraz won the 2025 French Open men's singles final, defeating Jannik Sinner 4–6, 6–7(4–7), 6–4, 7–6(7–3), 7–6(10–2), while Coco Gauff won the women's singles title by rallying past Aryna Sabalenka in three sets**[1][3][5][4].\n\nKey details from the finals:\n\n- **Men's Singles:**  \n  - Alcaraz came back from two sets down to win in the longest French Open final ever (5 hours, 29 minutes)[1][5].\n  - He saved three championship points, a record in the Open Era for men's majors[1][5].\n  - This marked his second Roland Garros title and fifth Grand Slam overall[5].\n  - The match was the first French Open singles final decided by a match tiebreak (final set tiebreak introduced in 2022)[1][5].\n\n- **Women's Singles:**  \n  - Coco Gauff defeated Aryna Sabalenka after losing the first set, showcasing a strong comeback[3].\n  - Gauff secured her second Grand Slam (her first was at the 2023 US Open)[3].\n  - The final was played June 7, 2025; Gauff overcame an early deficit to win in three sets[3].\n\nThese finals were historic for their drama, length, and the milestone achievements for both Alcaraz and Gauff."
      },
      "delta": {
        "role": "assistant",
        "content": ""
      }
    }
  ]
}

Steps to reproduce

  1. Run the cURL command above with a valid $AI_GATEWAY_API_KEY.
  2. Observe that the response does not include any citation/source fields.
  3. Call Perplexity’s API directly with the same prompt (without the Gateway).
  4. Observe that citations are present there.

AI SDK Version

  • AI Gateway: enabled, using OpenAI-compatible endpoint (/v1/chat/completions)
  • Model(s): perplexity/sonar (also affects other Sonar variants)
  • Client: raw HTTP (cURL)
1 Like

Thanks for the detailed example. Let me share it with our team.

1 Like

Any way we can also get inline citations? It doesn’t seem to be supported. Thanks!

Hi @vinayakvadoothker, welcome to the Vercel Community!

I’ve asked our team to provide some updates. Last I checked, they were still working on it. I’ll keep you all posted in this thread.

Hi @anshumanb, is there any update or expectation for the resolution of this issue?

Hi @techbeme, I’m sorry that it’s taking longer. I’ve asked for an update from our team. I’ll keep you posted here.

Hi @techbeme, have you tried using the AI SDK for your use case? Because as per the AI SDK Providers: Perplexity docs we’re sending back sources data.