# Structured output is not structured

**URL:** <https://community.perplexity.ai/t/structured-output-is-not-structured/712>\
**Category:** Bug Reports\
**Tags:** sonar-api\
**Created:** [July 22, 2025, 2:57pm UTC](https://community.perplexity.ai/t/structured-output-is-not-structured/712 "2025-07-22T14:57:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slavan\_Slavan](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/slavan_slavan/32/432_2.png) [@Slavan\_Slavan](https://community.perplexity.ai/u/Slavan_Slavan)\
**Post date:** [July 22, 2025, 2:57pm UTC](https://community.perplexity.ai/t/structured-output-is-not-structured/712/1 "2025-07-22T14:57:07Z")

</div>

## 🐛 Describe the Bug

Structured output doesnt work stable - with one code and one environment it builds sometimes structured output and sometimes not. It works so even with structured code example from documentation.

## ✅ Expected Behavior

Structured output works always.

## ❌ Actual Behavior

Structured output works unstable.

## 🔄 Steps to Reproduce

Run code from example multiple times ([Structured Outputs Guide - Perplexity](https://docs.perplexity.ai/guides/structured-outputs)):

```auto
import requests
from pydantic import BaseModel

class AnswerFormat(BaseModel):
    first_name: str
    last_name: str
    year_of_birth: int
    num_seasons_in_nba: int

url = "https://api.perplexity.ai/chat/completions"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
payload = {
    "model": "sonar",
    "messages": [
        {"role": "system", "content": "Be precise and concise."},
        {"role": "user", "content": (
            "Tell me about Michael Jordan. "
            "Please output a JSON object containing the following fields: "
            "first_name, last_name, year_of_birth, num_seasons_in_nba. "
        )},
    ],
    "response_format": {
		    "type": "json_schema",
        "json_schema": {"schema": AnswerFormat.model_json_schema()},
    },
}
response = requests.post(url, headers=headers, json=payload).json()
print(response["choices"][0]["message"]["content"])

```

## 📌 API Request & Response (if applicable)

## 🌍 Environment

- **API Version:** Current (model - sonar)
- Pydantic version (used for BaseModel): 2.11.7
- **Operating System:** Linux, Windows

## 📎 Logs or Screenshots (if applicable)

Several runs of the code from the example:

````auto
PS C:\> & ... test.py
{ "first_name": "Michael", "last_name": "Jordan", "year_of_birth": 1963, "num_seasons_in_nba": 15 }
PS C:\> & ... test.py
{"first_name":"Michael","last_name":"Jordan","year_of_birth":1963,"num_seasons_in_nba":15}
PS C:\> & ... test.py
```json
{
  "first_name": "Michael",
  "last_name": "Jordan",
  "year_of_birth": 1963,
  "num_seasons_in_nba": 15
}
\```
Michael Jordan was born in 1963 and played 15 seasons in the NBA between 1984 and 2003[1][3][5].
PS C:\> 

````

## 📝 Additional Context

I’ve been using Structured Output in Perplexity for a long time, it stopped working recently

---

<div class="post-metadata">

**Author:** ![John\_Denley](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/john_denley/32/457_2.png) [@John\_Denley](https://community.perplexity.ai/u/John_Denley)\
**Post date:** [July 24, 2025, 5:02am UTC](https://community.perplexity.ai/t/structured-output-is-not-structured/712/2 "2025-07-24T05:02:30Z")

</div>

I am also encountering this issue

---

<div class="post-metadata">

**Author:** ![Vishal\_Singh](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/vishal_singh/32/460_2.png) [@Vishal\_Singh](https://community.perplexity.ai/u/Vishal_Singh)\
**Post date:** [July 24, 2025, 10:25am UTC](https://community.perplexity.ai/t/structured-output-is-not-structured/712/3 "2025-07-24T10:25:35Z")

</div>

Same issue is happening for me today, now that i wanted to test my code before prod. WTF perplexity

---

<div class="post-metadata">

**Author:** ![CraftyMuta](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/craftymuta/32/463_2.png) [@CraftyMuta](https://community.perplexity.ai/u/CraftyMuta)\
**Post date:** [July 24, 2025, 11:42am UTC](https://community.perplexity.ai/t/structured-output-is-not-structured/712/4 "2025-07-24T11:42:45Z")

</div>

Same. Used Perplexity structured output in production app and it now returns plaintext response more often than not. Seems to be completely ignoring the json schema provided to it. It worked well before this week.

---

<div class="post-metadata">

**Author:** ![vikvang](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@vikvang](https://community.perplexity.ai/u/vikvang)\
**Post date:** [July 24, 2025, 6:21pm UTC](https://community.perplexity.ai/t/structured-output-is-not-structured/712/5 "2025-07-24T18:21:23Z")

</div>

Hey everyone! We apologize for the inconvenience. This issue should now be resolved. If anyone is still experiencing problems with structured outputs, please let us know with code samples and timestamps!
