How it works
1
Define tools
Describe your functions with a JSON Schema for their parameters and pass them in
tools.2
Model requests a call
If the model decides a tool is needed, the response contains
tool_calls with the function name and JSON arguments, and finish_reason is tool_calls.3
You run the function
Execute the function in your own code with the supplied arguments.
4
Return the result
Append a
tool message with the output and call the API again. The model uses it to produce a final answer.Example
Controlling tool use
Usetool_choice to steer the model:
Set
parallel_tool_calls to false if you want at most one tool call per turn.
Next steps
Structured outputs
Force responses that match a JSON schema.
Reasoning
Use models that think before they answer.