# Structured output doesn't work for Anthropic in Agent API

**URL:** <https://community.perplexity.ai/t/structured-output-doesnt-work-for-anthropic-in-agent-api/5945>\
**Category:** Bug Reports\
**Tags:** agent-api, api\
**Created:** [August 28, 2026, 1:03pm UTC](https://community.perplexity.ai/t/structured-output-doesnt-work-for-anthropic-in-agent-api/5945 "2026-08-28T13:03:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maksim\_Bliumental](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/maksim_bliumental/32/3504_2.png) [@Maksim\_Bliumental](https://community.perplexity.ai/u/Maksim_Bliumental)\
**Post date:** [August 28, 2026, 1:03pm UTC](https://community.perplexity.ai/t/structured-output-doesnt-work-for-anthropic-in-agent-api/5945/1 "2026-08-28T13:03:26Z")

</div>

## Minimal reproduction

```python
import asyncio
import os

from perplexity import AsyncPerplexity
from pydantic import BaseModel

PERPLEXITY_API_KEY = os.environ["PERPLEXITY_API_KEY"]
MODEL = "anthropic/claude-opus-5"

class BrandEquality(BaseModel):
    aliases: bool
    explanation: str

async def main() -> None:
    client = AsyncPerplexity(api_key=PERPLEXITY_API_KEY)
    try:
        response = await client.responses.create(
            model=MODEL,
            input=[
                {
                    "type": "message",
                    "role": "user",
                    "content": (
                        "In the context of tax advisory services in Denmark, are "
                        "'Grant Thornton' and 'Grant Thornton Danmark' aliases for "
                        "the same brand?"
                    ),
                }
            ],
            instructions=(
                "Determine whether the two names uniquely identify the same brand "
                "in the supplied context."
            ),
            tools=[{"type": "web_search", "search_context_size": "low"}],
            reasoning={"effort": "high"},
            max_output_tokens=128_000,
            response_format={
                "type": "json_schema",
                "json_schema": {
                    "name": "BrandEquality",
                    "schema": BrandEquality.model_json_schema(),
                },
            },
        )
    finally:
        await client.close()

    print(response.output)
    print(response.output_text)

if __name__ == " __main__":
    asyncio.run(main())

```

## Response or error

```bash
perplexity.BadRequestError: Error code: 400 - {'error': {'message': 'invalid request', 'type': 'invalid_request', 'code': 400}}

```

## Additional context

- Models from other vendors work fine: OpenAI, xAI, Gemini.
- If you run it many-many times, you may see 1-2 of successful requests.

---

<div class="post-metadata">

**Author:** ![andrewmadson-pplx](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/andrewmadson-pplx/32/3428_2.png) [@andrewmadson-pplx](https://community.perplexity.ai/u/andrewmadson-pplx)\
**Post date:** [September 3, 2026, 11:25pm UTC](https://community.perplexity.ai/t/structured-output-doesnt-work-for-anthropic-in-agent-api/5945/2 "2026-09-03T23:25:30Z")

</div>

Hello @Maksim_Bliumental ,

Thank you for your report. I was able to replicate the bug on Opus-5 and Sonnet-5 with structured output. I have notified the team for review.

I appreciate you bringing it to my attention.

Andrew
