Gemini 3.5 Flash 最新消息

Gemini 3.5 Flash 已正式發布,穩定性高,可大規模用於實際工作環境。這是 Google 最聰明的 Flash 模型,可持續提供頂尖效能,大規模執行代理型工作、程式設計和長期任務。

本指南概略說明 Gemini 3.5 Flash 的改良項目、API 異動和遷移指引。

新增模型

型號 模型 ID 說明
Gemini 3.5 Flash gemini-3.5-flash Google 最聰明的模型,在代理和程式設計工作方面,可持續提供頂尖效能。

Gemini 3.5 Flash 支援 100 萬個詞元的脈絡窗口、最多 65,000 個輸出詞元、思考型功能,以及與 Gemini 3 Flash 相同的工具和平台功能。目前不支援「電腦使用」

如需完整規格,請參閱型號總覽。 如需定價資訊,請參閱定價頁面

快速入門導覽課程

本指南中的所有範例都使用 GenerateContent API。系統也支援 Interactions API,適用相同的設定選項和建議。

Python

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3.5-flash",
    contents="Explain how parallel agentic execution works in three sentences.",
)
print(response.text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-3.5-flash",
    contents: "Explain how parallel agentic execution works in three sentences.",
  });
  console.log(response.text);
}

main();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "Explain how parallel agentic execution works in three sentences."}]
    }]
  }'

最新資訊

  • 持續提供頂尖效能:Google 最聰明的 Flash 模型,可大規模執行代理和程式設計工作。
  • 代理執行:大規模部署子代理、解決問題,以及快速代理迴圈。
  • 程式設計:反覆進行程式設計週期、快速探索及設計原型,測試替代路徑並動態探索解決方案。
  • 長期:大規模使用多步驟工作流程和工具。
  • 保留想法:模型會在多輪對話中自動保留中間的推理過程,不需要變更 API。
  • 新的預設努力程度:預設思考努力程度已從 high 變更為 medium。詳情請參閱「新的預設投入程度」。
  • 提升low思考能力: low 現在可大幅提升程式碼和代理程式工作效能,減少步驟,以更低的延遲時間和成本提供高品質服務。
  • 正式發行版本:穩定模型,適合大規模用於實際工作環境。

行為變更

新的預設努力程度:medium

Gemini 3 Flash 預先發布版的預設思考量已從 high 變更為 mediummedium 在各種工作上都能產生非常好的結果,而且速度更快、成本效益更高。對於複雜問題,high 可鼓勵模型深入思考。

工作量 使用時機
minimal 以回應速度為優先考量。類似聊天的用途、快速的事實性答案、較簡單的工具呼叫。
low 需要較低延遲和較少步驟的程式碼和代理式工作。也適合用於需要思考的分析和寫作工作。
medium (預設) 適合大多數工作,可提供最佳品質。建議用於複雜程式碼和代理式用途。
high 盡量提升模型思考和使用工具的能力。最適合處理複雜的推論、困難的數學,以及最難的程式碼或代理程式工作。可進行延伸思考和函式呼叫。

如要覆寫預設值,請在設定中設定 thinking_level

Python

from google import genai
from google.genai import types

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3.5-flash",
    contents="Prove that the square root of 2 is irrational.",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(thinking_level="high")
    ),
)

print(response.text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-3.5-flash",
    contents: "Prove that the square root of 2 is irrational.",
    config: {
      thinkingConfig: {
        thinkingLevel: "HIGH",
      },
    },
  });
  console.log(response.text);
}

main();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "Prove that the square root of 2 is irrational."}]
    }],
    "generationConfig": {
      "thinkingConfig": {
        "thinkingLevel": "HIGH"
      }
    }
  }'

保留想法

模型會在多輪對話中自動保留中間推論結果,如果對話記錄中包含推論脈絡,系統會沿用這些脈絡,進而提升複雜多步驟工作的效能,例如反覆偵錯和程式碼重構。不必變更 API:

  • Interactions API:系統會自動保留想法。行為沒有改變。
  • GenerateContent API:從 Gemini 3.5 Flash 開始,如果對話記錄中包含思維簽章,模型就會使用先前所有輪次的推論脈絡。如要啟用這項功能,請在 contents 中傳遞完整且未經修改的對話記錄 (包括想法簽章)。SDK 會自動處理這項作業。

Gemini 3.x 中的參數更新和最佳做法

以下適用於所有 Gemini 3.x 模型,包括 Gemini 3.5 Flash。

  • temperaturetop_ptop_k:強烈建議不要變更預設值。Gemini 3 的推論能力已針對預設設定完成最佳化。
  • 使用 thinking_level,而不要使用 thinking_budget
  • 函式呼叫回應比對idname 和回應計數必須與先前的呼叫相符。
  • 多模態函式回應:在函式回應中加入多模態內容,而非在函式回應外。
  • 函式回應中的內嵌指令:附加至函式回應文字,而非獨立部分。
  • 減少不必要的工具呼叫:使用較低的思考層級或實驗系統指令,減少代理工作流程中的工具呼叫次數。

如要瞭解如何更新程式碼,請參閱下方各節。

取樣參數 (不再建議使用)

temperaturetop_ptop_k 不再適用於所有 Gemini 3.x 模型。Gemini 3 的推論能力已針對預設設定完成最佳化。從所有要求中移除這些參數。

# ⚠️ Remove these parameters (not recommended)
config = types.GenerateContentConfig(
    temperature=0.7,
    top_p=0.9,
    top_k=40
)

為確保確定性,建議您定義系統指令,並為特定用途設定明確規則。

thinking_budget (不建議使用)

在所有 Gemini 3.x 模型中,我們不再建議使用原始數值 thinking_budget 參數。請改用 thinking_level 字串列舉。

# ⚠️ Before (not recommended)
config = types.GenerateContentConfig(
    thinking_config=types.ThinkingConfig(thinking_budget=7500)
)

# ✅ After
config = types.GenerateContentConfig(
    thinking_config=types.ThinkingConfig(thinking_level="medium")
)

可用值:minimallowmedium (預設值) 和 high

函式呼叫:嚴格比對回應

如果函式回應不符,Interactions API 就會發生錯誤。GenerateContent API 目前不會傳回錯誤,但如果回覆不符,模型大多會傳回含有 finish_reason: STOP 的空白回覆。請一律遵循下列慣例:

規定 詳細資料
包含 id的訂金 每個 FunctionResponse 都必須包含對應 FunctionCallid
name 回應中的 name 必須與呼叫中的 name 相符
相符項目數 針對收到的每個 FunctionCall,傳回正好一個 FunctionResponse

Python

# ✅ Include matching id and name in the function response
final_response = client.models.generate_content(
    model="gemini-3.5-flash",
    config=config,
    contents=[
        *previous_contents,
        response.candidates[0].content,
        types.Content(role="user", parts=[
            types.Part.from_function_response(
                name=tool_call.name,
                response={"result": result},
                id=tool_call.id,
            )
        ]),
    ],
)

JavaScript

// ✅ Include matching id and name in the function response
const functionResponsePart = {
  functionResponse: {
    name: toolCall.name,
    response: { result: result },
    id: toolCall.id,
  },
};

const finalResponse = await ai.models.generateContent({
  model: "gemini-3.5-flash",
  contents: [
    ...previousContents,
    { role: "model", parts: [{ functionCall: toolCall }] },
    { role: "user", parts: [functionResponsePart] },
  ],
  config: config,
});

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "..."}]},
      {"role": "model", "parts": [{"functionCall": {"name": "my_function", "args": {...}}}]},
      {"role": "user", "parts": [{"functionResponse": {"name": "my_function", "id": "call_id", "response": {"result": "..."}}}]}
    ]
  }'

多模態函式回應

我們經常看到客戶在函式回應以外提供圖片。這可能會導致模型出現非預期的行為 (例如洩漏想法),並產生品質較低的輸出內容。請改為按照多模態函式回應 API 文件中的建議操作,並在傳送至模型的回覆部分中加入多模態內容。模型可以在下一個回合處理這類多模態內容,進而生成更實用的回覆。

Python

# ✅ Include multimodal content in the function response
final_response = client.models.generate_content(
    model="gemini-3.5-flash",
    config=config,
    contents=[
        *previous_contents,
        response.candidates[0].content,
        types.Content(role="user", parts=[
            types.Part.from_function_response(
                name=tool_call.name,
                response={
                    "result": "instrument.jpg",
                    "image": base64_image_data,
                },
                id=tool_call.id,
            )
        ]),
    ],
)

JavaScript

// ✅ Include multimodal content in the function response
const finalResponse = await ai.models.generateContent({
  model: "gemini-3.5-flash",
  contents: [
    ...previousContents,
    { role: "model", parts: [{ functionCall: toolCall }] },
    {
      role: "user",
      parts: [{
        functionResponse: {
          name: toolCall.name,
          id: toolCall.id,
          response: {
            result: "instrument.jpg",
            image: base64ImageData,
          },
        },
      }],
    },
  ],
  config: config,
});

函式回應中的內嵌指令

我們經常看到客戶在函數回應中提供額外指令,做為後續的 Parts。這可能會導致模型出現非預期的行為 (例如洩漏思考過程),並降低輸出內容的品質。請改為在函式回應文字結尾附加任何額外指示,並以兩個換行符號分隔。

Python

# ✅ Append inline instructions to the end of the function response separated by two newlines
result_text = f"{json.dumps(result)}\n\n<your inline instructions>"

final_response = client.models.generate_content(
    model="gemini-3.5-flash",
    config=config,
    contents=[
        *previous_contents,
        response.candidates[0].content,
        types.Content(role="user", parts=[
            types.Part.from_function_response(
                name=tool_call.name,
                response={"result": result_text},
                id=tool_call.id,
            )
        ]),
    ],
)

JavaScript

// ✅ Append inline instructions to the end of the function response separated by two newlines
const resultText = `${JSON.stringify(result)}\n\n<your inline instructions>`;

const finalResponse = await ai.models.generateContent({
  model: "gemini-3.5-flash",
  contents: [
    ...previousContents,
    { role: "model", parts: [{ functionCall: toolCall }] },
    {
      role: "user",
      parts: [{
        functionResponse: {
          name: toolCall.name,
          id: toolCall.id,
          response: { result: resultText },
        },
      }],
    },
  ],
  config: config,
});

減少不必要的工具呼叫

如果工具呼叫次數過多,可以採取以下兩種方法盡量減少:

  1. 首先,請降低思考層級 (mediumlowminimal): 思考層級越高,模型就越會使用工具探索及驗證,因此降低層級可減少工具呼叫次數。

  2. 新增系統指令:如果調整思考程度後仍有過度使用情形,請考慮使用限制工具用量的提示。例如:

    You have a limited action budget of <n> tool calls. Use them efficiently.
    

遷移檢查清單

從 Gemini 3 Flash 預先發布版遷移

  • 更新模型名稱:gemini-3-flash-previewgemini-3.5-flash
  • 查看定價。Gemini 3.5 Flash 的價格高於 Gemini 3 Flash 預先發布版。詳情請參閱定價頁面
  • 從設定中移除 temperaturetop_ptop_k (不再建議使用)。
  • thinking_budget 替換為 thinking_level
  • 在所有 FunctionResponse 部分中新增 id 和相符的 name
  • 測試提示。預設工作量已從 highmedium 變更;請確認品質、速度和費用。
  • 系統現在預設會保留想法。推論內容會在回合之間延續,這有助於提升效能,但可能會增加詞元用量。
  • 減少不必要的工具呼叫:首先,降低思考層級 (mediumlowminimal);如果工具使用過度,請新增系統指令來限制工具使用。
  • Gemini 3.5 Flash 目前不支援「電腦使用」。如要處理電腦使用工作負載,請繼續使用 Gemini 3 Flash 搶先版。

從 Gemini 2.5 遷移

上述所有功能,外加:

  • 簡化提示。如果您使用思維鏈提示工程來強制推論,請改用 thinking_level: "medium""high",並搭配較簡單的提示。
  • 測試 PDF 和媒體工作負載。如果您依賴特定行為來剖析密集文件,請測試 media_resolution_high 設定,確保準確度不受影響。遷移至 Gemini 3 預設值可能會增加 PDF 的權杖用量,但會減少影片的權杖用量;如果要求超出脈絡窗口,請明確減少 media_resolution。詳情請參閱媒體解析度文件。
  • 搭配使用多種工具。 您可以在同一項要求中使用 Google 搜尋、網址環境、程式碼執行和自訂函式。
  • 如果使用多模態函式回覆,請將多模態內容移至函式回覆部分內,而非與其並列。
  • 如果使用內嵌指令搭配函式回應,請以兩個換行符號分隔,將指令附加至函式回應文字,而非做為獨立部分。
  • Gemini 3.x 不支援影像分割功能。如要處理區隔工作負載,請繼續使用 Gemini 2.5 Flash (關閉思考模式) 或 Gemini Robotics-ER 1.6

Gemini 3 系列功能

Gemini 3.5 Flash 承襲了 Gemini 3 系列的所有功能,但「電腦使用」除外。 Gemini 3 推出並沿用至今的功能:

後續步驟