OAI-SE Structured Outputs & Strict JSON Schemas EASY
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 in required and give it a type of string or null

Strict function schemas require every property to appear in required, so an optional field is expressed by adding null as a type option and letting the model return null when there is no note. Dropping the field from required or opening additionalProperties violates strict mode, and disabling strict gives up guaranteed schema adherence.
Free

Keep practicing OAI-SE

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

Start free practice set → Timed, explained, free