很多開發者看到 gemini-3.1-pro-preview-customtools 這個模型名時會困惑: customtools 是什麼意思? 它和標準的 gemini-3.1-pro-preview 有什麼不同? 本文用 5 分鐘幫你徹底搞清楚。
核心價值: 讀完本文,你將明白什麼時候該用標準版、什麼時候該用 customtools 版,以及如何在 Agent 開發中正確選擇。

什麼是 Gemini 3.1 Pro Customtools
一句話解釋
gemini-3.1-pro-preview-customtools 是谷歌在 2026 年 2 月 19 日與標準版 Gemini 3.1 Pro 同步發佈的專用變體模型。它和標準版的核心區別只有一個: 優先使用你註冊的自定義工具,而不是默認跑 bash 命令。
谷歌官方 Changelog 的原話是:
Launched a separate endpoint
gemini-3.1-pro-preview-customtools, which is better at prioritizing custom tools, for users building with a mix of bash and tools.
爲什麼需要這個變體
在 Agent 開發中,開發者通常會同時給模型註冊兩類能力:
- Bash/代碼執行: 讓模型直接運行 shell 命令
- 自定義工具 (Custom Tools): 開發者定義的結構化函數,如
view_file、search_code、create_pr等
問題出在哪裏? 標準版 Gemini 3.1 Pro 有時會「偷懶」,跳過你精心設計的自定義工具,直接用 bash 命令完成任務。比如你註冊了 view_file 工具,但模型可能直接執行 cat filename.py,繞過了你的工具。
這在某些場景下是有問題的:
- 自定義工具可能有權限控制和日誌記錄
- 自定義工具的返回格式是結構化的,便於後續處理
- 自定義工具可能連接了外部系統 (數據庫、API 等)
customtools 變體就是爲了解決這個問題: 讓模型優先選擇你註冊的工具。
Gemini 3.1 Pro 標準版 vs Customtools 版核心區別
| 對比維度 | 標準版 | Customtools 版 |
|---|---|---|
| 模型 ID | gemini-3.1-pro-preview |
gemini-3.1-pro-preview-customtools |
| 發佈日期 | 2026.2.19 | 2026.2.19 (同步發佈) |
| 推理能力 | ARC-AGI-2 77.1% | 相同 |
| 編碼能力 | SWE-Bench 80.6% | 相同 |
| 上下文窗口 | 1,048,576 tokens | 相同 |
| 最大輸出 | 65,536 tokens | 相同 |
| 輸入價格 | $2.00 / 1M tokens | 相同 |
| 輸出價格 | $12.00 / 1M tokens | 相同 |
| 工具調用行爲 | 可能優先使用 bash | 優先使用自定義工具 |
| 適用場景 | 通用推理、編碼、分析 | Agent 開發、工具編排 |
| 質量說明 | 所有場景均衡 | 不涉及工具的場景可能有微小質量波動 |
🎯 關鍵理解: 兩個模型的「智力水平」完全相同。區別只在於面對「該用 bash 還是該用你註冊的工具」這個選擇時,customtools 版會更傾向於選擇你的自定義工具。
什麼場景需要用 Gemini 3.1 Pro Customtools
需要用 customtools 的場景
| 場景 | 爲什麼需要 | 具體例子 |
|---|---|---|
| AI 編碼助手 | 需要用結構化的 view_file、edit_file 等工具 | Claude Code、Cursor 類產品 |
| DevOps Agent | 需要通過工具調用 CI/CD 系統而非直接 bash | 自動化部署、代碼審查機器人 |
| MCP 工作流 | 註冊了 MCP 工具協議的 Agent | 多步驟工作流編排 |
| 有權限控制的 Agent | 自定義工具內置了權限檢查 | 企業級 Agent 應用 |
| 需要結構化日誌的 Agent | 工具調用便於記錄和審計 | 合規要求高的場景 |
不需要用 customtools 的場景
| 場景 | 用標準版即可 | 原因 |
|---|---|---|
| 普通對話/問答 | gemini-3.1-pro-preview |
不涉及工具調用 |
| 文本分析/翻譯 | gemini-3.1-pro-preview |
純文本輸入輸出 |
| 代碼生成 (無工具) | gemini-3.1-pro-preview |
只需要模型直接寫代碼 |
| 簡單 bash 腳本執行 | gemini-3.1-pro-preview |
就是想用 bash |
谷歌的官方建議
谷歌在 Gemini 3 開發者指南的 FAQ 中明確說:
If you are using
gemini-3.1-pro-previewand the model ignores your custom tools in favor of bash commands, try thegemini-3.1-pro-preview-customtoolsmodel instead.
翻譯: 如果你發現標準版忽略了你的自定義工具而直接用 bash,換成 customtools 版試試。
Gemini 3.1 Pro Customtools API 調用方法
基本調用: 和標準版完全一樣
import openai
client = openai.OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.apiyi.com/v1" # API易 統一接口
)
# 只需要換 model 名稱,其他代碼完全不變
response = client.chat.completions.create(
model="gemini-3.1-pro-preview-customtools",
messages=[
{"role": "user", "content": "幫我查看項目中的 main.py 文件內容"}
]
)
print(response.choices[0].message.content)
帶自定義工具的 Agent 調用
customtools 版的真正威力在於搭配 function calling:
import openai
import json
client = openai.OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.apiyi.com/v1" # API易 統一接口
)
# 定義自定義工具
tools = [
{
"type": "function",
"function": {
"name": "view_file",
"description": "查看指定文件的內容",
"parameters": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "文件路徑"
}
},
"required": ["file_path"]
}
}
},
{
"type": "function",
"function": {
"name": "search_code",
"description": "在代碼庫中搜索關鍵詞",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "搜索關鍵詞"
},
"file_pattern": {
"type": "string",
"description": "文件匹配模式,如 *.py"
}
},
"required": ["query"]
}
}
}
]
# customtools 版會優先使用上面定義的工具
response = client.chat.completions.create(
model="gemini-3.1-pro-preview-customtools",
messages=[
{"role": "user", "content": "幫我在項目中找到所有包含 TODO 的 Python 文件"}
],
tools=tools
)
# 模型會調用 search_code 工具而不是直接 grep
tool_call = response.choices[0].message.tool_calls[0]
print(f"工具: {tool_call.function.name}")
print(f"參數: {tool_call.function.arguments}")
查看完整的 Agent 循環代碼
import openai
import json
client = openai.OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.apiyi.com/v1"
)
tools = [
{
"type": "function",
"function": {
"name": "view_file",
"description": "查看指定文件的內容",
"parameters": {
"type": "object",
"properties": {
"file_path": {"type": "string", "description": "文件路徑"}
},
"required": ["file_path"]
}
}
},
{
"type": "function",
"function": {
"name": "search_code",
"description": "在代碼庫中搜索關鍵詞",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "搜索關鍵詞"},
"file_pattern": {"type": "string", "description": "文件匹配模式"}
},
"required": ["query"]
}
}
},
{
"type": "function",
"function": {
"name": "edit_file",
"description": "編輯文件中的指定內容",
"parameters": {
"type": "object",
"properties": {
"file_path": {"type": "string", "description": "文件路徑"},
"old_content": {"type": "string", "description": "要替換的舊內容"},
"new_content": {"type": "string", "description": "新內容"}
},
"required": ["file_path", "old_content", "new_content"]
}
}
}
]
# 模擬工具執行
def execute_tool(name, args):
"""實際項目中替換爲真實的工具實現"""
if name == "view_file":
return f"文件內容: {args['file_path']} (模擬)"
elif name == "search_code":
return f"搜索 '{args['query']}' 的結果: 找到 3 處匹配 (模擬)"
elif name == "edit_file":
return f"已將 {args['file_path']} 中的內容替換 (模擬)"
return "未知工具"
# Agent 主循環
messages = [{"role": "user", "content": "找到項目中所有 TODO 註釋並修復它們"}]
max_turns = 5
for turn in range(max_turns):
response = client.chat.completions.create(
model="gemini-3.1-pro-preview-customtools",
messages=messages,
tools=tools
)
msg = response.choices[0].message
messages.append(msg)
if msg.tool_calls:
for tc in msg.tool_calls:
args = json.loads(tc.function.arguments)
result = execute_tool(tc.function.name, args)
messages.append({
"role": "tool",
"tool_call_id": tc.id,
"content": result
})
print(f"[Turn {turn+1}] 調用: {tc.function.name}({args})")
else:
print(f"[完成] {msg.content[:200]}")
break
🚀 快速開始: 通過 API易 apiyi.com 平臺,標準版和 customtools 版使用同一個 API Key。只需修改 model 參數即可切換,非常適合 A/B 測試哪個版本更適合你的 Agent。
Gemini 3.1 Pro Customtools 和 Agent 框架的關係

主流 Agent 框架的適配情況
customtools 版對以下 Agent 開發場景特別有價值:
| Agent 框架/場景 | 適配建議 | 理由 |
|---|---|---|
| Claude Code 類編碼助手 | 推薦 customtools | 需要 view_file、edit_file 等結構化工具 |
| Cursor / GitHub Copilot | 推薦 customtools | IDE 工具集需要被優先調用 |
| MCP 協議 Agent | 推薦 customtools | MCP 註冊的工具需要優先級保障 |
| LangChain / LlamaIndex | 推薦 customtools | 框架註冊的 tools 需要被正確調用 |
| 純 Chat 應用 | 用標準版 | 不涉及工具調用 |
| RAG 檢索增強 | 視情況而定 | 如果檢索是通過 function calling 實現的,用 customtools |
Gemini 3.1 Pro Customtools 與標準版的行爲對比
爲了更直觀地理解區別,看一個具體的例子:
同一個請求,兩個模型的不同反應
用戶請求: 「幫我查看 src/main.py 文件的內容」
已註冊工具: view_file(file_path: string)
| 模型版本 | 模型行爲 | 說明 |
|---|---|---|
| 標準版 | 可能直接執行 cat src/main.py |
用 bash 完成任務,跳過了你的工具 |
| Customtools 版 | 調用 view_file("src/main.py") |
優先使用你註冊的自定義工具 |
兩種方式都能獲取文件內容,但通過自定義工具調用有以下優勢:
- 權限控制: 你的
view_file工具可以檢查路徑是否在白名單內 - 格式化輸出: 工具可以返回結構化的 JSON 而非原始文本
- 日誌審計: 工具調用會被框架自動記錄
- 錯誤處理: 工具可以提供友好的錯誤信息而非 bash 報錯

谷歌 Gemini 工具調用模型的演進
customtools 是谷歌首次爲工具調用提供專用模型變體。以下是谷歌 Gemini 工具相關模型的完整圖譜:
| 模型 | 發佈時間 | 工具類型 | 說明 |
|---|---|---|---|
| Gemini 2.5 Flash | 2025 | 基礎 function calling | 通用工具調用 |
| Gemini 3 Pro Preview | 2025 末 | function calling | 改進的工具調用 |
| Gemini 3.1 Pro Preview | 2026.2.19 | function calling + 並行工具 | 標準版,可能傾向 bash |
| Gemini 3.1 Pro Customtools | 2026.2.19 | function calling 優先 | Agent 專用,優先自定義工具 |
| Computer Use Preview | 2025 | GUI 操作 | 計算機使用 (實驗性) |
| Deep Research Preview | 2025 末 | 搜索 + 分析 | 深度研究 Agent |
這表明谷歌正在將模型按使用場景細分,而不是用一個通用模型覆蓋所有場景。未來可能會出現更多專用變體。
常見問題
Q1: customtools 版會更貴嗎?
不會。customtools 版和標準版的價格完全相同: 輸入 $2.00 / 1M tokens,輸出 $12.00 / 1M tokens。通過 API易 apiyi.com 平臺調用,兩個版本使用同一個 API Key,沒有額外費用。
Q2: customtools 版的推理能力會變弱嗎?
幾乎不會。谷歌提到在「不涉及工具的場景中可能有微小質量波動」,但核心推理能力 (ARC-AGI-2 77.1%、SWE-Bench 80.6%) 保持不變。如果你的 Agent 主要使用工具,customtools 版的整體表現會更好。
Q3: 什麼時候應該從標準版切換到 customtools 版?
當你發現模型在有自定義工具可用的情況下,仍然頻繁使用 bash 命令來完成任務時,就應該切換。比如你註冊了 view_file 但模型總是用 cat,註冊了 search_code 但模型總是用 grep。通過 API易 apiyi.com 可以快速 A/B 測試兩個版本。
Q4: 如果我沒有註冊任何自定義工具,用 customtools 版有意義嗎?
沒有意義。如果不註冊自定義工具,兩個版本的行爲完全相同。customtools 版的優化只在「模型需要在 bash 和自定義工具之間做選擇」時纔會體現。
總結: Gemini 3.1 Pro Customtools 速查
| 問題 | 答案 |
|---|---|
| customtools 是什麼? | 優先使用自定義工具的 Gemini 3.1 Pro 變體 |
| 和標準版有什麼區別? | 僅工具調用優先級不同,推理能力和價格相同 |
| 什麼時候用? | 開發 Agent、使用 MCP、註冊了 function calling 工具時 |
| 什麼時候不用? | 純對話、純推理、不涉及工具調用時 |
| 兩個版本能切換嗎? | 能,改一個 model 參數就行 |
| 價格一樣嗎? | 完全相同: 輸入 $2 / 輸出 $12 per MTok |
一句話總結: gemini-3.1-pro-preview-customtools 就是 Gemini 3.1 Pro 的「Agent 專用模式」— 讓模型更聽話地使用你註冊的工具而非直接跑 bash。價格不變、智力不變,只是工具選擇策略更適合 Agent 開發。
推薦通過 API易 apiyi.com 平臺同時接入兩個版本,在實際項目中 A/B 測試後選擇最適合的。對於 Agent 開發者來說,customtools 版幾乎總是更好的選擇。
參考資料
-
Google AI 文檔: Gemini 3.1 Pro Preview 模型頁
- 鏈接:
ai.google.dev/gemini-api/docs/models/gemini-3.1-pro-preview - 說明: 包含標準版和 customtools 版的對比說明
- 鏈接:
-
Gemini API Changelog: 2026 年 2 月 19 日更新
- 鏈接:
ai.google.dev/gemini-api/docs/changelog - 說明: customtools 變體的首次發佈記錄
- 鏈接:
-
Gemini 3 開發者指南: FAQ 中的工具選擇建議
- 鏈接:
ai.google.dev/gemini-api/docs/gemini-3 - 說明: 何時從標準版切換到 customtools 版
- 鏈接:
-
Google AI 文檔: Function Calling 指南
- 鏈接:
ai.google.dev/gemini-api/docs/function-calling - 說明: Gemini 模型的函數調用 API 詳解
- 鏈接:
📝 作者: APIYI Team | 技術交流請訪問 API易 apiyi.com
📅 更新時間: 2026 年 2 月 20 日
🏷️ 關鍵詞: gemini-3.1-pro-preview-customtools, 自定義工具, Agent 開發, function calling, 工具調用, API 調用
