# Gemini 3.8 Flash 新特性

Gemini 3.8 Flash (`gemini-3.8-flash`）是我们最智能的 Flash 模型，专为长期软件工程、自主智能体和复杂的企业工作流程而设计。

本指南介绍了 Gemini 3.8 Flash、API 更改、代码示例和迁移指南中的新增内容。

## 新型号  {% #new-model %}

| 模型               | 型号编号               | 默认思维水平   | 价格                                                                                         | 说明                                           |
| ---------------- | ------------------ | -------- | ------------------------------------------------------------------------------------------ | -------------------------------------------- |
| Gemini 3.8 Flash | `gemini-3.8-flash` | `medium` | 3.8 Flash 将于年底上市，促销价为 $0.75/1M 输入 token 和 $3.75/1M 输出 token；看到 [定价](/docs/pricing) 了解更多详情。 | 我们最智能的 Flash 模型，专为长期软件工程、自主智能体和复杂的企业工作流程而设计。 |

Gemini 3.8 Flash 支持 1M token 上下文窗口，最大 64k 输出 token，可调思维级别（`low`, `medium`, `high`），以及相同的内置工具套件。

有关完整规格，请参阅 [Gemini 3.8 Flash 型号页面](/docs/models/gemini-3.8-flash)。有关介绍性定价的详细信息，请参阅 [定价部分](/docs/whats-new-gemini-3.8#pricing) 稍后在本页或 [定价页面](/docs/pricing#gemini-3.8-flash).

## 快速入门  {% #quickstart %}

{% tabs %}
{% tab label="Python" %}
```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)
```
{% /tab %}

{% tab label="JavaScript" %}
```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);
```
{% /tab %}

{% tab label="Java" %}
```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(""));
```
{% /tab %}

{% tab label="Go" %}
```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)
    }
}
```
{% /tab %}

{% tab label="REST" %}
```bash
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."
  }'
```
{% /tab %}
{% /tabs %}

## Gemini 3.8 Flash 新特性  {% #whats-new-gemini-3-8-flash %}

* **远景软件工程：** 在现实世界的编码基准、复杂的多文件重构和确定性工具执行方面提供了出色的结果。请参阅 [评估方法](https://deepmind.google/models/evals-methodology/gemini-3-8-flash/) 了解详情。
* **自主智能体：** 允许您构建弹性的多步骤规划和工具编排工作流程，从而大大减少失败的循环和错误。
* **复杂的企业工作流程：** 在要求严格的领域任务和大规模数据管道中提供卓越的准确性、深度推理和高度的事实严谨性。
* **托管智能体的默认型号：** 默认智能体为托管智能体： [Antigravity 智能体](/docs/antigravity-agent)，现在使用 Gemini 3.8 Flash。的 [Antigravity SDK](https://antigravity.google/docs/sdk/overview/) 默认情况下也使用 Gemini 3.8 Flash。
* **介绍性定价：** Gemini 3.8 Flash 的介绍价格为 $0.75/1M 输入 token 和 $3.75/1M 输出 token 至 12 月 31, 2026. 标准定价$1.50/1M 输入 token 和 $7.50/1M 输出 token 生效 1 月 1, 2027.

根据设计，Gemini 3.8 Flash 可以在运行时间较长和复杂的任务上使用更多的 token。为了在困难的多步骤目标上提供更高质量的结果，该模型采用更小的推理步骤，迭代调用工具，并在此过程中验证其工作。并非每个工作流程都需要这种级别的验证。对于日常任务，您可以降低 [推理](/docs/whats-new-gemini-3.8#understanding-reasoning-levels) 努力减少token消耗。或者，Gemini 3.6 Flash 仍受支持。

## 了解推理水平  {% #understanding-reasoning-levels %}

Gemini 3.8 Flash通过调整模型的思维水平，让您对延迟和智能进行灵活的控制：

* **低思考力**：缩短事件响应管道、实时聊天、撰写草稿和快速数据分析等延迟关键型任务的响应时间。
* **中（默认）：** 大多数任务的最佳质量。推荐用于复杂代码和智能体用例，提供更高的首次通过精度。
* **高思维努力**：最大化模型的推理和工具编排能力。最适合深度推理、数学和困难的多步骤任务。

注意： `minimal` Gemini 3.8 Flash 不支持思维级别，将返回错误。

下面的例子设置 `thinking_level` 到 `medium` 对于复杂的代码分析请求：

{% tabs %}
{% tab label="Python" %}
```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)
```
{% /tab %}

{% tab label="JavaScript" %}
```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);
```
{% /tab %}

{% tab label="Java" %}
```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(""));
```
{% /tab %}

{% tab label="Go" %}
```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)
    }
}
```
{% /tab %}

{% tab label="REST" %}
```bash
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"
    }
  }'
```
{% /tab %}
{% /tabs %}

## 更新了 Antigravity 智能体  {% #updated-antigravity-agent %}

由于其改进的性能和推理能力， [Antigravity 智能体](/docs/antigravity-agent) 在Gemini中，托管智能体现在默认使用Gemini 3.8 Flash构建。

{% tabs %}
{% tab label="Python" %}
```python
from google import genai

client = genai.Client(http_options={"api_version": "v1beta"})

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)
```
{% /tab %}

{% tab label="JavaScript" %}
```javascript
import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({ httpOptions: { apiVersion: "v1beta" } });

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);
```
{% /tab %}

{% tab label="Java" %}
```java
import com.google.genai.Client;
import com.google.genai.types.HttpOptions;
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 = Client.builder().httpOptions(HttpOptions.builder().apiVersion("v1beta").build()).build();

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(""));
```
{% /tab %}

{% tab label="Go" %}
```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, &genai.ClientConfig{HTTPOptions: genai.HTTPOptions{APIVersion: "v1beta"}})
    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)
    }
}
```
{% /tab %}

{% tab label="REST" %}
```shell
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"
}'
```
{% /tab %}
{% /tabs %}

底层 Gemini 模型 [可以配置](/docs/antigravity-agent#model-selection) 使用 `agent_config`.

## 迁移清单  {% #migration-checklist %}

{% callout type="note" %}
**使用编码智能体自动执行此迁移。** 如果您使用支持技能的编码智能体（如 Antigravity），请安装 [gemini-api-dev技能](/docs/coding-agents#gemini-api-dev) 并运行：

`/gemini-api-dev migrate my app to Gemini 3.8 Flash`
{% /callout %}

### 迁移到 gemini-3.8-flash  {% #migrate-to-gemini-3-8-flash %}

* **更新型号 ID：** Change your target model string to `gemini-3.8-flash`.

* **配置思维层次：** 更换 `thinking_budget` 与字符串枚举 `thinking_level`。请注意 `minimal` Gemini 3.8 Flash 不支持；选择 `low`, `medium` （默认），或 `high`.

* **应用 Gemini 3 API 参数更改：** 删除已弃用的采样参数（`temperature`, `top_p`, `top_k`), `candidate_count` （Gemini 3 及更高版本中不支持）和预填充模型转弯。参见 [Gemini 3.6 API 变更及参数更新](/docs/whats-new-gemini-3.6#api-changes-and-parameter-updates).

* **强制执行回合验证规则：** 在服务器端标准化多轮对话 `previous_interaction_id` 并移除预填充的模型匝。

* **审核函数调用：**  * 将多模态资产放入响应负载中。

  * 使用格式化内联指令 `\n\n`.
  * 如果你看到 `Malformed_Function_Call` 与工具前文本相关的错误，请参阅 [工具前文本要求的解决方法](/docs/function-calling#workarounds-for-pre-tool-text-requirements).
  * 仅当使用generateContent API时：确保所有 `FunctionResponse` 对象包括 `call_id` 和 `name`.

* **基线 Gemini 3 要求：** 有关 SDK 更新和思想签名保存，请参阅 [思考签名](/docs/thinking#signatures).

## 价格  {% #pricing %}

充分利用 Google AI Studio 和 Gemini Enterprise Agent Platform 的介绍性定价，直至 12 月 31, 2026、Gemini 3.8 Flash 和 Gemini 3.6 Flash。标准定价生效一月 1, 2027. 有关完整的定价等级，请参阅 [定价页面](/docs/pricing#gemini-3.8-flash).

## 其他型号  {% #other-models %}

* [最新 Gemini 模型](/docs/latest-model)
* [Gemini 4 Hydrogen](/docs/whats-new-gemini-4-hydrogen)
* [Gemini 4 Carbon](/docs/whats-new-gemini-4-carbon)
* [Gemini 4 Argon](/docs/whats-new-gemini-4-argon)
* [Gemini 3.6 Flash 和 3.5 Flash-Lite](/docs/whats-new-gemini-3.6)
* [查看所有型号](/docs/models)

## 后续步骤  {% #whats-next %}

* 查看 API 规格 [型号概览](/docs/models).
* 探索多智能体编排 [Interactions API概述](/docs/interactions-overview).
* 测试并完善提示 [Google AI Studio](https://aistudio.google.com/prompts/new_chat?model=gemini-3.8-flash).
