Gemini 3.8 Flash (gemini-3.8-flash) 已正式發布,可供正式環境使用。這是我們最聰明的 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 個輸出詞元、可調整的思考層級 (low、medium、high),以及同樣全面的內建工具套件。
如需完整規格,請參閱 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 params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(
InteractionsInput.of(
"Write a three.js script that renders a realistic 3D black hole."))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("Write a three.js script that renders a realistic 3D black hole."),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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 美元。自 2027 年 1 月 1 日起,標準定價為每 100 萬個輸入權杖 $1.50 美元,每 100 萬個輸出權杖 $7.50 美元。
根據設計,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.GenerationConfig;
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.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(
InteractionsInput.of(
"Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely."))
.generationConfig(
GenerationConfig.builder()
.thinkingLevel(ThinkingLevel.MEDIUM) // Balanced reasoning effort for complex tasks
.build())
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely."),
GenerationConfig: &interactions.GenerationConfig{
ThinkingLevel: interactions.ThinkingLevelMedium.ToPointer(), // Balanced reasoning effort for complex tasks
},
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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-09-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-09-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.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(
InteractionsInput.of(
"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(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput(
"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: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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-09-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。 - 移除已淘汰的取樣參數:
- 從生成設定中移除
temperature、top_p和top_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_id和name。
- 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 規格。
- 請參閱「Interactions API 總覽」,瞭解多代理自動化調度管理功能。
- 在 Google AI Studio 測試及調整提示。