Parameter types for tool use (function calling)
Parameter types for tool use (function calling)
Parameter types for tool use (function calling)
The Structured Outputs feature guarantees that an LLM’s response will strictly follow a schema specified by the user.
While this feature is supported in two scenarios (JSON and tools), this page will focus on the tools scenario.
When you use the Chat API with tools, setting the strict_tools parameter to True will guarantee that every generated tool call follows the specified tool schema.
Concretely, this means:
required parameter is included in the tool callWith strict_tools enabled, the API will ensure that the tool names and tool parameters are generated according to the tool definitions. This eliminates tool name and parameter hallucinations, ensures that each parameter matches the specified data type, and that all required parameters are included in the model response.
Additionally, this results in faster development. You don’t need to spend a lot of time prompt engineering the model to avoid hallucinations.
When the strict_tools parameter is set to True, you can define a maximum of 200 fields across all tools being passed to an API call.
When using strict_tools, the following notes apply:
required parameter. Tools with only optional parameters are not supported in this mode.Structured Outputs supports a subset of the JSON Schema specification. Refer to the Structured Outputs documentation for the list of supported and unsupported parameters.
This section provides usage examples of the JSON Schema parameters that are supported in Structured Outputs (Tools).
The examples on this page each provide a tool schema and a message (the user message). To get an output, pass those values to a Chat endpoint call, as shown in the helper code below.
Example response:
Example response:
Example response:
Example response:
Example response:
Example response:
Example response:
Example response:
Example response:
Example response:
Example response:
Example response: