Gemini 3.8 Flash 的新功能

查看所有型號

Gemini 3.8 Flash (gemini-3.8-flash) 已正式發布 (GA),可供正式版使用。這是我們最聰明的 Flash 模型,專為長期軟體工程、自主代理和複雜的企業工作流程而設計。

本指南說明 Gemini 3.8 Flash 的新功能、API 異動、程式碼範例和遷移指南。

新增模型

模型 模型 ID 預設思考程度 定價 說明
Gemini 3.8 Flash gemini-3.8-flash medium 3.8 Flash 的新用戶優惠價為每 100 萬個輸入權杖 $0.75 美元,每 100 萬個輸出權杖 $3.75 美元,優惠期至年底為止。詳情請參閱定價 這是我們最聰明的 Flash 模型,專為長期軟體工程、自主代理和複雜的企業工作流程而設計。

Gemini 3.8 Flash 支援 100 萬個詞元的脈絡窗口、最多 64,000 個輸出詞元、可調整的思考層級 (lowmediumhigh),以及同樣全面的內建工具套件。

如需完整規格,請參閱 Gemini 3.8 Flash 模型頁面。如需詳細的優惠價格資訊,請參閱下方的定價部分定價頁面

快速入門導覽課程

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Write a three.js script that renders a realistic 3D black hole."
)

print(interaction.output_text)

JavaScript

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

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
  model: "gemini-3.8-flash",
  input: "Write a three.js script that renders a realistic 3D black hole.",
});

console.log(interaction.output_text);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();
CreateModelInteraction req = CreateModelInteraction.builder()
    .model(Model.of("gemini-3.8-flash"))
    .input(InteractionsInput.of("Hello world"))
    .build();
Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(req)).interaction().get();
System.out.println(interaction.outputText().orElse(""));

REST

curl "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "model": "gemini-3.8-flash",
    "input": "Write a three.js script that renders a realistic 3D black hole."
  }'

Gemini 3.8 Flash 最新消息

  • 長期軟體工程:在實際程式碼基準測試、複雜的多檔案重構和確定性工具執行方面,都能提供出色的結果。詳情請參閱評估方法
  • 自主代理:可建構彈性的多步驟規劃和工具調度管理工作流程,大幅減少失敗的迴圈和錯誤。
  • 複雜的企業工作流程:在要求嚴苛的領域工作和大規模資料管道中,提供卓越的準確度、深入的推論能力和嚴謹的事實。
  • 受管理代理的預設模型:受管理代理的預設代理「Antigravity 代理」現在使用 Gemini 3.8 Flash。Antigravity SDK 預設也會使用 Gemini 3.8 Flash。
  • 優惠價格:2026 年 12 月 31 日前,Gemini 3.8 Flash 的優惠價格為每 100 萬個輸入詞元 $0.75 美元,每 100 萬個輸出詞元 $3.75 美元。標準定價為每 100 萬個輸入權杖 $1.50 美元,每 100 萬個輸出權杖 $7.50 美元,將於 2027 年 1 月 1 日生效。

根據設計,Gemini 3.8 Flash 可在長時間執行的複雜工作中使用更多權杖。為達成困難的多步驟目標,模型會採取較小的推論步驟、反覆呼叫工具,並在過程中驗證工作。並非所有工作流程都需要這種程度的驗證。如要執行日常工作,可以降低推論工作量,減少詞元消耗量。或者,Gemini 3.7 Flash 仍完全支援。

瞭解推理等級

Gemini 3.8 Flash 可調整模型的思考程度,讓您彈性控管延遲時間和智慧程度:

  • 降低思考深度:減少延遲時間,加快處理事件應變管道、即時通訊、草擬內容和快速資料分析等延遲時間至關重要的工作。
  • 中 (預設):適合大多數工作,可提供最佳品質。建議用於複雜程式碼和代理式用途,可提供更高的初步準確度。
  • 思考深度:盡可能發揮模型的推論和工具自動化調度管理能力。最適合用於深入推論、數學和困難的多步驟工作。

以下範例會將複雜的程式碼分析要求 thinking_level 設為 medium

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
    generation_config={
        "thinking_level": "medium"  # Balanced reasoning effort for complex tasks
    }
)

print(interaction.output_text)

JavaScript

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

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
  model: "gemini-3.8-flash",
  input: "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
  generation_config: {
    thinking_level: "medium"
  }
});

console.log(interaction.output_text);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();
CreateModelInteraction req = CreateModelInteraction.builder()
    .model(Model.of("gemini-3.8-flash"))
    .input(InteractionsInput.of("Hello world"))
    .build();
Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(req)).interaction().get();
System.out.println(interaction.outputText().orElse(""));

REST

curl "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "model": "gemini-3.8-flash",
    "input": "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
    "generation_config": {
      "thinking_level": "medium"
    }
  }'

更新 Antigravity 代理程式

由於效能和推理能力有所提升,Gemini Managed Agents 中的 Antigravity 代理現在預設採用 Gemini 3.8 Flash 建構。

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input=(
        "Audit https://web.dev for performance, Core Web Vitals, and SEO. "
        "Query Google's PageSpeed Insights API for both Mobile and Desktop strategies. "
        "Check search indexing with Google Search for site:web.dev. "
        "Format the output as a side-by-side scorecard table with prioritized fixes."
    ),
    environment="remote",
)

print(interaction.output_text)

JavaScript

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

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
  agent: "antigravity-preview-05-2026",
  input: "Audit https://web.dev for performance, Core Web Vitals, and SEO. Query Google's PageSpeed Insights API for both Mobile and Desktop strategies. Check search indexing with Google Search for site:web.dev. Format the output as a side-by-side scorecard table with prioritized fixes.",
  environment: "remote",
}, { timeout: 300000 });

console.log(interaction.output_text);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();
CreateModelInteraction req = CreateModelInteraction.builder()
    .model(Model.of("gemini-3.8-flash"))
    .input(InteractionsInput.of("Hello world"))
    .build();
Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(req)).interaction().get();
System.out.println(interaction.outputText().orElse(""));

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "agent": "antigravity-preview-05-2026",
    "input": "Audit https://web.dev for performance, Core Web Vitals, and SEO. Query Google'\''s PageSpeed Insights API for both Mobile and Desktop strategies. Check search indexing with Google Search for site:web.dev. Format the output as a side-by-side scorecard table with prioritized fixes.",
    "environment": "remote"
}'

您可以使用 agent_config 設定基礎 Gemini 模型。

遷移檢查清單

  `/gemini-api-dev migrate my app to Gemini 3.8 Flash`

遷移至 gemini-3.8-flash

  • 更新模型 ID:將目標模型字串變更為 gemini-3.8-flash
  • 移除已淘汰的取樣參數:
    • 從生成設定中移除 temperaturetop_ptop_k
    • thinking_budget 替換為字串列舉 thinking_level。請注意,3.8 版 Flash 不支援 minimal
    • 移除 candidate_count (Gemini 3 以上版本不支援)。
  • 強制執行回合驗證規則:
    • 在伺服器端 previous_interaction_id 標準化多輪對話。
    • 移除預先填入的模型回合。
  • 稽核函式呼叫:
    • 將多模態素材資源放在回應酬載中。
    • 使用 \n\n 格式設定內嵌指令。
    • 如果看到與前置工具文字相關的 Malformed_Function_Call 錯誤,請參閱「前置工具文字規定因應措施」。
    • 僅在使用 generateContent API 時:請確認所有 FunctionResponse 物件都包含 call_idname
  • Gemini 3 基準需求:如需 SDK 更新和思維簽章保留作業,請參閱 Gemini 3.5 遷移檢查清單

定價

在 2026 年 12 月 31 日前,透過 Google AI Studio 和 Gemini Enterprise Agent Platform 試用 Gemini 3.8 Flash、Gemini 3.7 Flash 和 Gemini 3.6 Flash,即可享有優惠價格。標準價格將於 2027 年 1 月 1 日生效。如需完整定價層級,請參閱定價頁面

後續步驟

  • 在「模型總覽」中查看 API 規格。
  • 請參閱「互動 API 總覽」一文,瞭解多代理自動化調度管理功能。
  • Google AI Studio 測試及調整提示。