Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You have to explicitly opt into it by passing strict=True https://platform.openai.com/docs/guides/structured-outputs/s...




Are you able to use `strict=True` when using pydantic models? It doesn't seem to be valid for me. I think that only works for json schemas.

class FooBar(BaseModel): foo: list[str] bar: list[int]

prompt = """#Task Your job is to reply with Foo Bar, a json object with foo, a list of strings, and bar, a list of ints """

response = openai_client.chat.completions.parse( model="gpt-5-nano-2025-08-07", messages=[{"role": "system", "content": FooBar}], max_completion_tokens=4096, seed=123, response_format=CommentAnalysis, strict=True )

> TypeError: Completions.parse() got an unexpected keyword argument 'strict'




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: