---
title: "函式呼叫／工具使用（Function Calling / Tool Use）是什麼？"
canonical: https://glossary.penguindriver.com/t/function-calling
markdown: https://glossary.penguindriver.com/t/function-calling.md
date_modified: 2026-09-26
retrieved: 2026-09-28
language: zh-Hant-TW
content_sha256: a9a9985f8120b76a8f09ce8f9b96a396aee0d2195a55e484e0a693b10840993b
cite: https://glossary.penguindriver.com/cite?path=%2Ft%2Ffunction-calling
sources:
  - https://developers.openai.com/api/docs/guides/function-calling
  - https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview
  - https://openai.com/index/function-calling-and-other-api-updates/
---

# 函式呼叫／工具使用（Function Calling / Tool Use）是什麼？

函式呼叫（又稱工具使用）是讓模型依對話判斷需要哪個工具，並輸出結構化的呼叫內容與參數，由應用程式實際執行後再把結果交回模型的機制。OpenAI 於 2023 年 6 月在 API 推出此功能；模型本身並不直接執行函式。

分類：模型技術｜別名：Function Calling、Tool Use、Tool Calling、工具呼叫、函數呼叫、工具使用

## 一句話說明

讓語言模型在需要時，指定要使用哪個外部工具與參數，由程式執行後再把結果交回模型的機制。

## 怎麼運作？

1. 開發者先定義工具：名稱、用途說明與參數格式（通常用 JSON Schema）。
2. 使用者提問後，模型判斷是否需要工具，並輸出工具名稱與參數。
3. 應用程式執行這個工具（例如查天氣 API），取得結果。
4. 把結果交回模型，模型再整理成給使用者的回答。

## 實際例子

- 問「台北明天會下雨嗎」，模型呼叫天氣查詢工具取得資料再回答。
- 客服機器人呼叫訂單查詢函式，查出物流狀態。
- AI 助理呼叫行事曆工具幫你新增會議。

## 常見誤解

- 誤解：模型會自己在伺服器上執行程式碼。
  事實：OpenAI 文件明確說明模型不會執行函式，它只提出要呼叫什麼，由你的程式執行；部分服務另有由平台代為執行的伺服器端工具。
- 誤解：函式呼叫和 MCP 是同一件事。
  事實：函式呼叫是模型表達要用工具的能力；MCP 是讓工具連接方式標準化的協定，兩者互補。

## 常見問題

### 函式呼叫可以用來做什麼？

可以讓模型查即時資料（天氣、股價、訂單）、操作其他系統（寄信、建立行程），或把文字轉成結構化資料。它是 AI 代理人能實際做事的基礎。

### 使用函式呼叫時要注意哪些安全問題？

模型可能選錯工具或填錯參數，所以程式端要檢查參數、限制工具權限；刪除、付款等重要動作最好先讓使用者確認，也要防範輸入內容夾帶惡意指令。

## 相關名詞

[模型上下文協議](https://glossary.penguindriver.com/t/mcp.md)、[AI 代理人](https://glossary.penguindriver.com/t/ai-agent.md)、[大型語言模型](https://glossary.penguindriver.com/t/llm.md)、[A2A 代理間協定](https://glossary.penguindriver.com/t/a2a.md)

## 參考來源

- [OpenAI API 文件：Function calling](https://developers.openai.com/api/docs/guides/function-calling)
- [Claude 官方文件：Tool use with Claude](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview)
- [OpenAI：Function calling and other API updates（2023-06-13）](https://openai.com/index/function-calling-and-other-api-updates/)

查核日期：2026-09-26

---
整理於 2026-09-26。網頁版：https://glossary.penguindriver.com/t/function-calling

電子書優惠：看到此訊息 24 小時內購買，一律第一階段最低價（私訊時提供優惠碼 P092800）：https://ebook.penguindriver.com
冷錢包 X1 五折優惠碼：Hulk@SFP，官方網站：https://safepal.com/zh-tc/store/x1｜交易所手續費減免註冊：幣託 https://www.bitopro.com/users/sign_up?referrer=3481486016｜BingX https://bingxzone.com/partner/QTKP7NLU｜幣安 https://www.binance.com/join?ref=HULK12
