2026 年 8 月 13 日,Google 釋出 Gemini 3.7 Flash——距 3.6 Flash 僅三週,官方稱其為「面向編碼與 Agent 的最強 workhorse 模型」。如果你已經在用 Gemini API 做結構化 JSON 或 Tool Calling,這篇把模型定位、限時價格、接入方式、JSON 輸出與 Function Calling一次講清,並接上本系列前幾篇的資料流上下文。
上一篇《Gemini API 如何生成結構化 JSON》講的是 responseMimeType 與 Schema;更早的《Tool Calling → MCP 資料流》講的是工具引數 JSON。3.7 Flash 的升級重點正是這兩類 JSON 場景:更穩的多步規劃、更準的工具呼叫、更低的 Intro 單價。
Gemini 3.7 Flash 是什麼
Gemini 3.7 Flash 屬於 Google Flash 系列——高吞吐、低延遲、面向生產 Agent 與編碼的中間檔模型,不是 Pro/Ultra 那種「無限思考」旗艦,但在軟體工程、知識工作和 Web 開發上,Google 宣稱其智慧已明顯超過 3.6 Flash。
官方強調的三條主線:
- 編碼:除錯、Issue 修復、首遍程式碼準確率提升(FrontierCode 1.1 Main 43.6% vs 3.6 的 34.4%)。
- Agent:多步規劃、工具呼叫更「較真」,DeepSWE v1.1 65.3% vs 49.0%,AutomationBench 30.4% vs 17.0%。
- 知識工作:金融、法律、生物等長檔案推理(GDP.pdf 34.0% vs 22.0%)。
對個人使用者,Google AI Pro/Ultra 訂閱的 Spark 個人 Agent 也已切換到 3.7 Flash。對企業,同一模型在 Gemini Enterprise Agent Platform 與 Vertex AI 上提供。開發者最常見入口仍是 Gemini API(AI Studio 金鑰)。
規格與多模態能力
| 項 | Gemini 3.7 Flash |
|---|---|
| 模型 ID(API) | gemini-3.7-flash |
| 輸入模態 | 文字、圖片、影片、音訊、PDF |
| 上下文視窗 | 最高約 100 萬 token 輸入 |
| 最大輸出 | 約 64k token(含 reasoning 輸出計費) |
| Structured Output | 支援 responseMimeType + Schema |
| Function Calling | 支援,與 3.x 系列工具宣告格式一致 |
| Context Caching | 支援,Intro 期快取讀取約 $0.075 / 1M token |
多模態輸入 + 長上下文,適合「整份年報 PDF + 結構化抽取 JSON」或「截圖 UI + 生成程式碼」一類任務。Schema 約束的是輸出形狀,不限制你能喂什麼進 contents。
最新價格與計費要點
3.7 Flash 上線時帶限時 Intro 價:約為 3.6 Flash 正式價的一半。Google 已公佈 2027 年起恢復「標準價」,預算要按兩檔分別估算。
| 檔位 | 有效期 | 輸入 / 1M token | 輸出 / 1M token |
|---|---|---|---|
| Intro 價 | 2026-08-13 ~ 2026-12-31 | $0.75 | $3.75 |
| 標準價 | 2027-01-01 起 | $1.50 | $7.50 |
補充計費細節(Gemini API / AI Studio 口徑,Vertex AI 有獨立 SKU,部署前請核對官方價目):
- 輸出含 reasoning:帶思考鏈的輸出 token 與最終答覆 token 一併計入 output 單價。
- Context Caching:Intro 期快取讀取約 $0.075 / 1M;2027 年起約 $0.15 / 1M。適合 Agent 固定 System Prompt + 工具 Schema 反覆傳送的場景。
- Batch:大批次離線任務通常有折扣,與實時
generateContent分開計價。 - 免費層:AI Studio 仍可能有速率受限的免費額度,具體上限以控制檯為準。
Agent 賬單往往「輸出 token > 輸入 token」——3.7 Flash 在 Intro 期 $3.75 / 1M 輸出,比 3.6 Flash 正式 $7.50 便宜一半,適合 Q4 2026 做 Agent 壓測與灰度。
API 接入與模型 ID
推薦官方新 SDK google-genai(pip install google-genai),環境變數 GEMINI_API_KEY 來自 AI Studio。模型名固定為 gemini-3.7-flash——不要寫成 gemini-3.7-flash-001 除非檔案明確要求帶字尾。
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.7-flash",
contents="用三句話解釋 MCP 和 Function Calling 的區別。",
)
print(response.text)
REST 入口與 2.5 / 3.6 相同,只是 path 裡的 model 換成 gemini-3.7-flash:
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.7-flash:generateContent
Header: x-goog-api-key: YOUR_KEY
{
"contents": [{ "role": "user", "parts": [{ "text": "Hello" }] }]
}
Vertex AI 上欄位名與 Structured Output / Tool 設定一致,endpoint 與 GCP 鑑權不同。Android Studio、Google Antigravity 也可選同一模型做 Agent 原型。金鑰只放服務端,不要寫進前端靜態站或 MCP Server 日誌。
JSON 結構化輸出
3.7 Flash 完整支援 Gemini Structured Outputs(結構化輸出):在 generationConfig / SDK config 裡設 response_mime_type: application/json,再配 response_schema(Pydantic)或 response_json_schema(JSON Schema 字典)。原理與 2.5 / 3.6 相同——約束解碼在生成階段就避開非法 JSON 路徑。
from google import genai
from pydantic import BaseModel, Field
class Task(BaseModel):
title: str
priority: str = Field(description="low | medium | high")
due_date: str | None = None
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.7-flash",
contents="從會議紀要擷取待辦:下週五前完成預算評審,高優先順序。",
config={
"response_mime_type": "application/json",
"response_schema": Task,
},
)
task = response.parsed
print(task.priority)
與 Function Calling 的分工不變:Structured Output 管給使用者/下游程式的最終 JSON;Tool Calling 管工具引數 JSON。詳見《從 Prompt 到 Structured Output》與《Gemini JSON 教程》。3.7 Flash 在複雜 Schema(巢狀物件、enum、陣列)上的穩定性是選型的主要理由之一。
落地仍建議兩道閘:json.loads + 同一份 JSON Schema 再校驗;業務不變數(如金額合計)自己寫程式碼驗。樣例可丟進 JSON 工具箱本機 Diff,不上傳伺服器。
Function Calling / Tool Calling
Google 檔案裡的 Function Calling 與 OpenAI Tool Calling 同構:你在請求裡宣告 tools(名稱、描述、parameters JSON Schema),模型返回 functionCall / tool 訊息,宿主執行後再把結果塞回對話。3.7 Flash 的賣點之一是「更 diligently 地思考多步規劃與 tool calls」——更少無效重試,Agent 總 token 可能反而下降。
from google import genai
from google.genai import types
get_weather = types.FunctionDeclaration(
name="get_weather",
description="返回指定城市的當前天氣",
parameters={
"type": "object",
"properties": {
"city": {"type": "string", "description": "城市名,如 Shanghai"}
},
"required": ["city"],
},
)
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.7-flash",
contents="上海現在適合跑步嗎?",
config=types.GenerateContentConfig(
tools=[types.Tool(function_declarations=[get_weather])],
),
)
for part in response.candidates[0].content.parts:
if part.function_call:
print(part.function_call.name, part.function_call.args)
典型 Agent 鏈路:Tool Calling 查資料 → Structured Output 彙總成固定 JSON → MCP 暴露給 Cursor / Claude Desktop。工具 Schema 與 MCP inputSchema 應對齊,否則模型填參透過、Server 端卻拒收。系列文章《JSON Schema、Function Calling 與 MCP 演進》有完整時間線。
| Structured Output | Function Calling | |
|---|---|---|
| JSON 用途 | 最終答覆 / 抽取結果 | 工具引數 |
| 誰執行 | 無副作用,直接 parse | 你的程式碼 / MCP Server |
| 3.7 Flash 優勢 | 長 Schema、巢狀欄位更穩 | 多步 tool 計劃更連貫 |
與 3.6 Flash 及競品怎麼選
| 場景 | 建議 |
|---|---|
| 新 Agent / 編碼專案(2026 Q3–Q4) | 預設 gemini-3.7-flash,吃 Intro 價 |
| 已穩定跑在 3.6 Flash、無 tool/JSON 痛點 | 可暫緩遷移,但 2027 年兩者標準價對齊 |
| 超長推理、最低幻覺 | 考慮 Gemini Pro / 帶 thinking 的型號,單價更高 |
| Structured Output 為主、少工具 | 3.7 Flash + 本機 Schema 校驗足夠 |
| 大量 MCP 工具、多輪 tool loop | 3.7 Flash + Context Caching 固定工具 Schema |
第三方 benchmark 常列 Claude Sonnet、GPT 系列對照;Google 稱 3.7 Flash Intro 價低於多家同檔 API。選型時除標價外,應看你的任務上 Structured Output 透過率與 tool 重試次數——3.7 的改進主要體現在減少後者。
落地建議
- 模型字串全域性替換:設定中心把 default model 改為
gemini-3.7-flash,保留 3.6 作 fallback 一週對比錯誤率。 - JSON 雙軌測試:同一批 Prompt,分別測 Structured Output 與 Tool Calling,用 JSON 校驗器對照 Schema。
- 快取 System + tools:Agent 系統提示與
tools列表走 Context Caching,降 input 成本。 - 按 2027 標準價做預算:Intro 結束 output 翻倍,避免 Q1 2027 賬單驚 surprise。
- 金鑰與 Schema 分離:Schema 可開源;API Key 只在服務端,MCP 走 OAuth 或短期 token。
常見問題 FAQ
Gemini 3.7 Flash 的 API 模型 ID 是什麼?
在 Gemini API 與 google-genai SDK 中使用 gemini-3.7-flash。REST 路徑為 models/gemini-3.7-flash:generateContent。Vertex AI 控制檯可能顯示帶區域或版本字尾,以當前專案檔案為準。
Intro 價什麼時候結束?之後多少錢?
Intro 價 $0.75 輸入 / $3.75 輸出(每百萬 token)有效至 2026 年 12 月 31 日。2027 年 1 月 1 日起標準價為 $1.50 / $7.50,Context Caching 讀取價也相應翻倍。
3.7 Flash 支援 JSON Schema 結構化輸出嗎?
支援。與 2.5 / 3.6 相同,使用 response_mime_type=application/json 配合 response_schema 或 response_json_schema。複雜抽取與 Agent 間載荷建議始終帶 Schema,不要只靠提示詞「請輸出 JSON」。
Function Calling 和 Structured Output 能只開一個嗎?
可以,但職責不同。只開 Structured Output 適合分類、填表、抽取;只開 Function Calling 適合查庫、發郵件、調 MCP。生產 Agent 經常一輪對話裡兩者都用:工具拿事實,Structured Output 給下游固定形狀。
從 gemini-3.6-flash 遷移要改程式碼嗎?
通常只需改 model 字串與迴歸測試。tools、responseJsonSchema、多模態 parts 格式與 3.6 相容。若你依賴特定 thinking 或溫度行為,建議在 staging 對比同一套 JSON 樣例再切流量。
如何本機驗證模型吐出的 JSON?
把 responseJsonSchema 與模型輸出存成 JSON 檔案,用 JSON 工具箱在瀏覽器本機做語法校驗與結構 Diff,資料不上傳。這與上線前測 REST 契約是同一思路。
總結
Gemini 3.7 Flash 是 2026 年面向編碼與 Agent 的主力 Flash:模型 ID gemini-3.7-flash,Intro 價至 2026 年底為 $0.75 / $3.75(每百萬 input / output token),2027 年起翻倍。API 層與舊 Flash 一致,升級點在於多步 tool 呼叫與 Structured Output 的實戰穩定性。
建議你今天做兩件事:把 staging 預設模型改成 3.7 Flash 跑一輪 JSON + Tool 迴歸;用 JSON 工具箱對照 Schema 與樣例輸出。Structured Output 與 Function Calling 的設定細節仍見系列專題,不要混成一種 API。