Minimal reproduction
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
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.