The OpenAI tool shape
OpenAI tool definitions live in the tools array of your chat completions request. Each entry is a wrapper around a function spec, which itself contains a JSON Schema for the parameters. Adding strict: true activates structured outputs, which forces the model to emit arguments that parse and conform to your schema.
FAQ
- What does <code>strict: true</code> do?
- It tells OpenAI to enforce the schema on the model's output, guaranteeing that
tool_call.function.argumentsparses as valid JSON conforming to your schema. Strict mode requires every property to be inrequiredandadditionalProperties: falseat every object level. - Why does strict mode reject some schemas?
- OpenAI's structured-outputs implementation supports a subset of JSON Schema. It rejects
oneOf/not,$ref, recursive schemas, integers larger than i64, and a few other edge cases. The error message points to the offending node. - Is the wrapping <code>{"type": "function", "function": ...}</code> still required?
- For the Chat Completions API, yes. The Responses API uses a flatter shape. The OpenAI SDK abstracts this — most folks paste the wrapped form into
tools. - Where do parameter descriptions go?
- Inside each property (
"description": "..."). The model uses these heavily when deciding which tool to call and how to fill arguments. Don't skip them.
Common pitfalls
- Forgetting
additionalProperties: falseat every object level when using strict mode. - Putting
required: ["foo", "bar"]at the top level but only listing one of them inproperties. - Using
$refor recursive types — strict mode rejects them. - Skipping per-property
description; the model picks tools based on these and quality drops without them.