Skip to main content
Some models can call functions to extend their capabilities. Filter the model catalog by Function Calling to find them. Send the function name, description, and expected arguments along with the user’s question. If the question matches the function and the required arguments are available, the model returns a function call with a name, arguments, and a call ID. If arguments are missing, it asks the user for them. Run the named function on the client, then send the result and call ID back to the model so it can answer the original question. This example uses a function that looks up the local weather:
curl
Include tools to specify the function name, description, and parameters. Use tool_choice to control whether the model can select a function automatically based on the user’s intent. The request above returns the following message fields:
The tool_calls field contains the call ID and arguments. Use them to call the local get_current_weather function, then send the result and call ID back to the model:
curl
The model uses the function result and the conversation context to answer the original question: Answer based on a function call