How Should I Represent Optional Fields in OpenAI Structured Outputs?

Asked yesterday 27 views

0

I’m building an API response with OpenAI’s strict structured outputs. Some source records don’t have a value for fields such as middle_name, but I still need the rest of the response to match the schema reliably.

In strict mode, should a field that may be missing be included as nullable and listed as required, or is there another schema pattern I should use? I’d be interested in approaches that have held up across real API requests, rather than relying on prompt wording alone.

0 Answers


Write Your Answer