structuredOutput fails if schemas use `.optional()` or `.nullish()`, should be `.nullable()`.
MaxLeiter opened this issue · comments
Max Leiter commented
Just a heads up for others, if you're getting errors like this with `structuredOutputs`, replace `.optional()` or `.nullish()` in your schema with `.nullable()`.
AI_APICallError: Invalid schema for response_format 'response': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing 'foo'
Originally posted by @brc-dd in #2573 (comment)
Lars Grammel commented
This is a limitation of the OpenAI implementation. Other providers will not have this. Therefore I don't want to put in any magic, it's imo on the user / OpenAI to solve this.
Potential solutions:
a) clear error messages
b) docs around this, e.g. tips & troubleshooting
Lars Grammel commented