[BUG] - Streaming Broken with Sonar Reasoning Pro

Description

The new sonar-reasoning-pro model returns an internal server error when attempting to use streaming. Below is an example API call:

import os
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("PPLX_API_KEY"), base_url="https://api.perplexity.ai")

stream = client.chat.completions.create(
    model="sonar-reasoning-pro",
    messages=[
        {
            "role": "user",
            "content": "What is the most recent version of Python?"
        }
    ],
    stream=True
)

for part in stream:
    print(part)

This code results in the following error:

Traceback (most recent call last):
  File "...\test_ppxl_api_stream.py", line 25, in <module>
    for part in stream:
  File "...\site-packages\openai\_streaming.py", line 46, in __iter__
    for item in self._iterator:
  File "...\site-packages\openai\_streaming.py", line 72, in __stream__
    raise APIError(
openai.APIError: An internal server error has occurred.

This exact call works with sonar, sonar-reasoning, and sonar-pro.


If I turn off streaming, there is no error with sonar-reasoning-pro, and it returns the response properly:

ChatCompletion(id='83723a14-4cc2-452d-833c-6a54c60834e7', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='<think>\nOkay, let\'s tackle this query: "What is the most recent version of Python?" First, I need to check the search results provided to find the latest version.\n\nLooking at source [1], there\'s a table with Python releases. The top entry is 3.13, released 3 months and 3 weeks ago on October 7, 2024, with the latest version being 3.13.1 as of December 3, 2024. Source [2] mentions that the main branch is for Python 3.14, which is a future release, so that\'s not out yet. Source [3] lists active releases and under "Active Python Releases," the first entry is 3.13 with a bugfix status and the latest release note for 3.13.1 on December 3, 2024.\n\nAll sources agree that 3.13 is the latest stable version, with 3.13.1 being the most recent minor version as of December 2024. The next version, 3.14, is still in pre-release and planned for October 2025. So the answer should clearly state that Python 3.13.1 is the current latest version.\n</think>\n\nThe most recent stable version of Python is **Python 3.13.1**, released on December 3, 2024[1][2][3]. This is the latest bugfix release for Python 3.13, which initially launched on October 7, 2024[1][2]. \n\nFor context:\n- Python versions follow a structured release cycle with **2 years of active support** (bug fixes) and **3 years of security maintenance** after initial release[1][2].\n- The next planned version is **Python 3.14**, currently in pre-release development with a target launch date of October 2025[2][3].\n- Older supported versions still receiving security updates include Python 3.12 (until October 2028) and Python 3.11 (until October 2027)[1].\n\nTo check your installed version:\n```bash\npython --version\n# or \npython3 --version\n```', refusal=None, role='assistant', audio=None, function_call=None, tool_calls=None), delta={'role': 'assistant', 'content': ''})], created=1738690299, model='sonar-reasoning-pro', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=450, prompt_tokens=9, total_tokens=459, completion_tokens_details=None, prompt_tokens_details=None, citation_tokens=5734, num_search_queries=1), citations=['https://endoflife.date/python', 'https://devguide.python.org/versions/', 'https://www.python.org/downloads/', 'https://discuss.python.org/t/python-latest-stable-version/24563', 'https://www.python.org/downloads/source/', 'https://www.python.org/doc/versions/', 'https://docs.python.org/es/3/whatsnew/'])

This looks like it was temporary right after the deployment, so I’m closing this for now.

Hey! I was not able to reproduce the error that you got. Are you still experiencing it?