帮助中心 / 模型 API / 工具调用

工具调用

内容版本 v2026.10.22 · 所属 模型 API / 工具与检索

格式

与 OpenAI function calling 完全一致。

请求
{
  "model": "glm-5.3",
  "messages": [{"role":"user","content":"北京天气怎么样"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "查询城市天气",
      "parameters": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"]
      }
    }
  }]
}

流程

  1. 带 tools 发请求,模型返回 tool_calls
  2. 你执行本地函数,把结果作为 role: tool 的消息发回去
  3. 模型基于结果生成最终回答

哪些模型支持

模型广场里带「工具」标签的才支持。不支持的就用提示词约束输出 JSON。

如你还有其他疑问,可以 提交工单 或 回到帮助中心。
这篇文档对你有帮助吗?