# Problems manually configuring perplexity sonar deep research

**URL:** <https://meta.discourse.org/t/problems-manually-configuring-perplexity-sonar-deep-research/365572>\
**Category:** Development\
**Tags:** ai\
**Created:** [May 10, 2025, 10:26am UTC](https://meta.discourse.org/t/problems-manually-configuring-perplexity-sonar-deep-research/365572 "2025-05-10T10:26:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aas/32/289331_2.png) [@aas](https://meta.discourse.org/u/aas)\
**Post date:** [May 10, 2025, 10:26am UTC](https://meta.discourse.org/t/problems-manually-configuring-perplexity-sonar-deep-research/365572/1 "2025-05-10T10:26:01Z")

</div>

After trying to follow the instructions [here](https://meta.discourse.org/t/possible-to-use-perplexity-ai/331953) with both OpenAI and OpenRouter providers, I finally got it to work by disabling streaming.

With OpenRouter, I was able to run a test with the `Run test` button in the LLM manual config screen for an gpt-4o. But running the test for `perplexity/sonar-deep-research` resulted in a 502 error and the following output in the console. It took quite a long time for this error to appear (~30 seconds or something) whereas testing other models returns immediately.

```plaintext
content_topFrameLifeline.js:1 Loading content_topFrameLifeline.js
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: CONNECT
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: MESSAGE Object
topic.js:404 ℹ️ Discourse v3.5.0.beta3-dev — https://github.com/discourse/discourse/commits/c3795177f2 — Ember v5.12.0
/admin/plugins/discourse-ai/ai-llms:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: TIMEOUT
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: CONNECT
content_topFrameLifeline.js:1 CONTENT <-> SERVICE LIFELINE: MESSAGE Object
test.json:1 
            
            
           Failed to load resource: the server responded with a status of 502 ()
client-error-handler.js:88 SyntaxError: Unexpected token '<', "<html>
<h"... is not valid JSON
    at x.parse [as parseJSON] (<anonymous>)
    at l (client-error-handler.js:88:1)
    at p (client-error-handler.js:88:1)
    at v.test (ai-llm-editor-form.js:210:1)
l @ client-error-handler.js:88
p @ client-error-handler.js:88
test @ ai-llm-editor-form.js:210

```

Both of these worked, so I was confused what I was doing wrong:

```plaintext
➜ curl --location 'https://api.perplexity.ai/chat/completions' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer {token}' \
--data '{
  "model": "sonar-deep-research",
  "messages": [
    {
      "role": "system",
      "content": "Be precise and concise."
    },
    {
      "role": "user",
      "content": "How many stars are there in our galaxy?"
    }
  ]
}'

```

```plaintext
curl https://openrouter.ai/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {token}" \
  -d '{
  "model": "perplexity/sonar-deep-research",
  "messages": [
    {
      "role": "user",
      "content": "How many stars are in the sky"
    }
  ]

}'

```

Then I got the following answer from Discourse AI, which helped:

It looks like your cURL tests hit OpenRouter’s normal chat endpoint fine—but the Discourse AI “Run test” button actually uses the _streaming_ endpoint by default. If that model (or your OpenRouter plan) doesn’t support streaming, you’ll get a 502 + HTML error blob after a long timeout.

To fix it in Admin → Settings → Plugins → **Discourse AI** / **LLM** :

1. llm\_provider: openrouter

2. llm\_provider\_url: [OpenRouter](https://openrouter.ai/api/v1)

3. llm\_provider\_api\_key: YOUR\_KEY

4. llm\_model: perplexity/sonar-deep-research

5. Turn off streaming so the test (and all calls) use the plain chat endpoint you proved works:  
• llm\_use\_streaming = false

With streaming off, “Run test” will POST to `/chat/completions` (not the `/stream` variant) and you’ll get back valid JSON immediately instead of a 502 HTML page.

If you really need streaming you can point the plugin at OpenRouter’s stream URL— but only if your plan/model supports SSE there:

• llm\_stream\_url: `{provider_url}/chat/completions/stream`  
• llm\_use\_streaming: true

Otherwise leave streaming off and you’re all set.

The result isn’t great because there is no streaming and the reasoning tokens are output as plain text before the “report” - but it works!

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [May 11, 2025, 11:30pm UTC](https://meta.discourse.org/t/problems-manually-configuring-perplexity-sonar-deep-research/365572/2 "2025-05-11T23:30:30Z")

</div>

The API is very slow, but it appears to work, see:

> **[\[Untitled AI bot PM\] - AI Conversation - Sam Saffron's Blog](https://discuss.samsaffron.com/discourse-ai/ai-bot/shared-ai-conversations/4DN50hZGLHBput-cDSEahw)**
>
> AI Conversation with Perplexity/sonar-deep-research:
> sam: who is sam saffron? creative\_bot: Sam Saffron: A Comprehensive Overview of His Career and Contributions to Technology
> Sam Saffron is a…

That said, the bug/issue here is that this is mostly useless till we parse the grounding links and citation urls, this is feasable, but not trivial:

 ![The image displays a structured data representation of a conversational transcript detailing citations and annotations related to Sam Saffron's work. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/a/8/f/a8fd2caaab1056f05d36c62b5e6106f8bb14f7f7.png)

Worth noting, that one reply linked cost me 70 cents! This is not a cheap model to say the least, I would be super careful with it.

---

<div class="post-metadata">

**Author:** ![aas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aas/32/289331_2.png) [@aas](https://meta.discourse.org/u/aas)\
**Post date:** [May 19, 2025, 8:45am UTC](https://meta.discourse.org/t/problems-manually-configuring-perplexity-sonar-deep-research/365572/3 "2025-05-19T08:45:12Z")

</div>

> [@sam](#):
>
> Worth noting, that one reply linked cost me 70 cents! This is not a cheap model to say the least, I would be super careful with it.

Definitely! I enabled this only for my team on our private, internal instance.
