Tool Calling
This page summarizes common objects used in chat, tool calling, and usage statistics.
Tool Definition
A tool definition usually includes type and function. The function object includes name, description, and parameters. After the model returns a tool call, the application needs to execute the tool and continue sending the result as a tool message.
json
{
"type": "function",
"function": {
"name": "get_weather",
"description": "查询城市天气",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}The application must validate the function name and parameters returned by the model itself and must not directly execute unvalidated parameters. The execution result should include the corresponding tool_call_id and then be sent back to the model as a tool message.
