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 将以初次体验价提供至今年年底,即 $0.75/百万输入 token,$3.75/百万输出 token;如需了解详情,请参阅价格 Google 旗下最智能的 Flash 模型,专为长期软件工程、自主智能体和复杂的企业工作流而设计。

Gemini 3.8 Flash 支持 100 万个 token 的上下文窗口、6.4 万个 token 的最大输出量、可调的思考水平(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 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 的促销价格为每百万输入 token 0.75 美元,每百万输出 token 3.75 美元。标准价格为 1.50 美元/百万输入 token 和 7.50 美元/百万输出 token,将于 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.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
  • 移除了已废弃的抽样参数
    • 从生成配置中剥离 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 日之前,Gemini 3.8 Flash、Gemini 3.7 Flash 和 Gemini 3.6 Flash 在 Google AI Studio 和 Gemini Enterprise Agent Platform 上均可享受优惠价。标准价格将于 2027 年 1 月 1 日生效。如需了解完整的价格层级,请参阅价格页面

后续步骤