Before you begin
- Choose a catalog model that supports function calling.
- Give the key model access and access to the tools you will execute.
- Inspect each tool’s actual input schema.
- Persist a distinct operation key for every intended model and tool submission.
Define a function
Includetools on the model request. A definition uses this shape:
tool_choice accepts auto, none, required, or a named function selection.
parallel_tool_calls is optional. These options require tools; a named
selection must refer to one of the supplied definitions.
Complete the conversation
- Read
run.message.tool_callswhen the model requests functions. - Preserve the complete assistant message, including
reasoning_detailsif present. A tool-only assistant message can have null content. - Validate each function name and parsed arguments against your allowed bindings.
- Execute authorized operations and append a
role: "tool"message for each returned call ID. - Submit the next model request with the accumulated messages and the same tool definitions, using a new saved model-operation key.