tools. When the model decides to use one, it answers with tool_calls instead of text.
Your code runs the function and sends the result back in a tool message, and the model continues from there.
Python
finish_reason is tool_calls and message.tool_calls holds the calls:
arguments is a JSON string. Parse it, and validate it before you act on it: the model can make mistakes.
Choosing when tools are used
Streaming
Tool calls also work withstream: true. They arrive in pieces in delta.tool_calls; OpenAI SDKs offer helpers that
put them together for you.
