OAI-SE Structured Outputs & Strict JSON Schemas MEDIUM
PRODUCTION SCENARIO
Ferrocarril Logistics defines a create_shipment function tool with a gift_note parameter that most orders leave blank. With strict set to true, the API rejects the schema whenever gift_note is left out of the required array.

How should the team model the optional parameter?

Answering here is anonymous. Nothing is saved unless you sign in.

Show answer and explanation

Answer: Keep gift_note inside the required array and give it a type of either string or null

Strict function schemas require every field in properties to be listed in required, so an optional parameter stays in required and gains null as a type option; the model returns null when there is no note. additionalProperties governs undeclared keys and must stay false under strict mode, a JSON Schema default does not make a field optional, and two near-identical tools push the choice onto the model for no gain.
Free

Keep practicing OAI-SE

24 original OAI-SE practice questions, each with an explanation and a source link. No account needed.

Start free practice set → Timed, explained, free