Gemini 3.8 Flash (gemini-3.8-flash) 是 Google 旗下最智能的 Flash
模型,专为长期软件工程、自主智能体和复杂的企业工作流而设计。
本指南介绍了 Gemini 3.8 Flash 的新增功能、API 变更、代码示例和迁移指南。
新建模型
| 模型 | 模型 ID | 默认思考等级 | 价格 | 说明 |
|---|---|---|---|---|
| Gemini 3.8 Flash | gemini-3.8-flash |
medium |
3.8 Flash 将以初次体验价提供至今年年底,即 $0.75/百万输入 token,$3.75/百万输出 token;如需了解详情,请参阅价格。 | Google 旗下最智能的 Flash 模型,专为长期软件工程、自主智能体和复杂的企业工作流而设计。 |
Gemini 3.8 Flash 支持 100 万个 token 的上下文窗口、最多 6.4 万个输出 token、可调的思考等级(low、medium、high)以及相同的内置工具套件。
如需了解完整规格,请参阅Gemini 3.8 Flash 模型页面。如需了解初次体验价详情,请参阅本页稍后的价格部分或价格页面。
快速入门
Python
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.8-flash",
contents="Write a three.js script that renders a realistic 3D black hole."
)
print(response.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
const response = await ai.models.generateContent({
model: "gemini-3.8-flash",
contents: "Write a three.js script that renders a realistic 3D black hole.",
});
console.log(response.text);
REST
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "Write a three.js script that renders a realistic 3D black hole."}]
}]
}'
Gemini 3.8 Flash 的新增功能
- 长期软件工程: 在实际编码基准、复杂的多文件重构和确定性工具执行方面表现出色。如需了解详情,请参阅评估方法。
- 自主智能体: 可让您构建弹性多步骤规划和工具编排工作流,大幅减少失败循环和错误。
- 复杂的企业工作流: 在要求苛刻的领域任务和大规模数据流水线中,可提供卓越的准确性、深入的推理能力和高度的事实严谨性。
- Managed Agents 的默认模型: Managed Agents 的默认智能体 Antigravity 智能体现在使用 Gemini 3.8 Flash。Antigravity SDK 也默认使用 Gemini 3.8 Flash。
- 初次体验价: Gemini 3.8 Flash 将以初次体验价提供至 2026 年 12 月 31 日,即 $0.75/百万输入 token,$3.75/百万输出 token。标准价格为 $1.50/百万输入 token,$7.50/百万输出 token,将于 2027 年 1 月 1 日生效。
Gemini 3.8 Flash 经过精心设计,可以在运行时间较长且复杂的任务中使用更多 token。为了在困难的多步骤目标上提供更高质量的结果,该模型会采取较小的推理步骤,以迭代方式调用工具,并在此过程中验证其工作。并非每个工作流都需要这种级别的验证。对于日常任务,您可以降低推理工作量,以减少 token 消耗。或者,Gemini 3.6 Flash 仍受支持。
了解推理等级
Gemini 3.8 Flash 可让您通过调整模型的思考等级,灵活控制延迟时间和智能程度:
- 低思考力度:缩短延迟时间敏感型任务的回答时间,例如突发事件响应流水线、实时聊天、撰写草稿和快速数据分析。
- 中等(默认): 适用于大多数任务的最佳质量。建议用于复杂的代码和智能体用例,可提供更高的首次准确率。
- 思考力度:最大限度地提高模型的推理和工具编排能力。最适合深度推理、数学和困难的多步骤任务。
以下示例将复杂代码分析请求的 thinking_level 设置为 medium:
Python
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.8-flash",
contents="Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(
thinking_level="medium" # Balanced reasoning effort for complex tasks
),
),
)
print(response.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
const response = await ai.models.generateContent({
model: "gemini-3.8-flash",
contents: "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
config: {
thinkingConfig: {
thinkingLevel: "medium", // Balanced reasoning effort for complex tasks
},
},
});
console.log(response.text);
REST
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely."}]
}],
"generationConfig": {
"thinkingConfig": {
"thinkingLevel": "medium"
}
}
}'
更新后的 Antigravity 智能体
迁移核对清单
`/gemini-api-dev migrate my app to Gemini 3.8 Flash`
迁移到 gemini-3.8-flash
- 更新模型 ID: 将目标模型字符串更改为
gemini-3.8-flash。 - 配置思考等级: 将
thinking_budget替换为字符串枚举thinking_level。请注意,Gemini 3.8 Flash 不支持minimal;请选择low、medium(默认)或high。 - 应用 Gemini 3 API 参数变更: 移除已废弃的采样参数(
temperature、top_p、top_k)、candidate_count(Gemini 3 及更高版本不支持)和预填模型轮次。请参阅 Gemini 3.6 API 变更和参数更新。 - 强制执行轮次验证规则: 移除预填模型轮次,并确保最终用户轮次包含非空文本。
- 审核函数调用:
- 将多模态素材资源放置在响应载荷内。
- 使用
\n\n设置内嵌说明的格式。 - 如果您看到与工具前文本相关的
Malformed_Function_Call错误,请参阅 工具前文本要求的变通方法。 - 仅在使用 generateContent API 时:确保所有
FunctionResponse对象都包含call_id和name。
- Gemini 3 基准要求: 如需了解 SDK 更新和思维签名保留,请参阅思维签名。
价格
在 2026 年 12 月 31 日之前,Gemini 3.8 Flash 和 Gemini 3.6 Flash 可在 Google AI Studio 和 Gemini Enterprise Agent Platform 中享受初次体验价。标准价格将于 2027 年 1 月 1 日生效。如需了解完整价格层级,请参阅价格页面。
其他模型
后续步骤
- 查看模型概览中的 API 规范。
- 在 Interactions API 概览 中探索多智能体编排。
- 在 Google AI Studio 中测试和优化提示。