Gemini 4 Argon 的新功能

Gemini 4 Argon (gemini-4-argon) 是我们最新、功能最强大的模型。它可以针对难题进行更长时间的推理,从而在复杂的编码、智能体、数学和科学任务中获得更好的结果。Gemini 4 Argon 可通过 Gemini API 和 Google AI Studio 使用。

Gemini 4 Argon 支持统一的 100 万个 token 上下文窗口、最多 100 万个 token 的长解码,以及可调的思考级别(low、medium、high)。

本指南介绍了 Gemini 4 Argon 的新功能、API 变更、代码示例和迁移指南。

新建模型

模型 模型 ID 默认思考级别 价格 说明
Gemini 4 Argon gemini-4-argon medium 在 2026 年 11 月 30 日之前,以初次体验价提供,即每 100 万个输入 token 收费 2 美元,每 100 万个输出 token 收费 10 美元(之后每 100 万个输入 token 收费 4 美元,每 100 万个输出 token 收费 20 美元)。如需了解详情,请参阅价格。 我们功能最强大的模型,旨在解决真实软件工程和知识工作任务中最棘手的问题,并提供深度和准确性。

如需了解完整详情,请参阅Gemini 4 Argon 模型页面。如需了解初次体验价详情,请参阅本页稍后的价格部分或价格页面。

快速入门

使用以下示例向 gemini-4-argon 发送请求,其中包含建议的默认 thinking_level (medium) 和 64K 输出 token 限制:

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-4-argon",
    input="Write a three.js script that renders a realistic 3D black hole with gravitational lensing."
)

print(interaction.output_text)

JavaScript

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

const client = new GoogleGenAI({});

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

console.log(interaction.output_text);

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-4-argon",
    "input": "Write a three.js script that renders a realistic 3D black hole with gravitational lensing."
  }'

Gemini 4 Argon 新功能

  • 统一的 100 万个输入-输出 token 限制: 输入、思考和输出共享一个 1,048,576 个 token 的窗口。
  • 长解码: 单个响应现在可以超过 64K 个 token,最多可达 100 万个 token 减去您的输入。请参阅长解码。
  • 智能体视频理解功能正式版: 智能体视频理解功能现已正式发布。
  • 受托管式智能体支持: Gemini 托管式智能体中的 Antigravity 智能体现在支持 Gemini 4 Argon。

如需了解完整规格,请参阅Gemini 4 Argon 模型页面。如需了解价格详情,请参阅价格页面。

更大的输出和长解码

Gemini 4 Argon 可以针对复杂的数学、科学和编码问题进行更长时间的思考。

  • 使用 thinking_level 控制推理深度: 思考级别决定了模型在回答之前进行推理的深度。max_output_tokens 是硬性限制:思考和输出总数达到此限制后,响应就会停止,因此请将其设置为足够高的值,以免答案被截断。
  • 通过后台执行生成最多 100 万个 token: 使用后台执行,并将 max_output_tokens 设置为大于 65,536,以便单个响应可以超过 64K 个 token,最多可达 100 万个 token。模型以最多 64K 个 token 的跳跃方式生成长响应,每个跳跃都从上一个跳跃停止的位置继续。通过后台执行,我们的服务器会为您运行这些连续跳跃。由于每个跳跃都会向 interaction.steps 添加一个 model_output 步骤,因此请在互动完成后将所有 model_output 步骤中的文本连接起来。

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-4-argon",
    input="Write a complete, rigorous proof of the prime number theorem.",
    background=True,
    generation_config={
        "max_output_tokens": 262144,
        "thinking_level": "high",
    },
)

while interaction.status in ("in_progress", "queued"):
    time.sleep(5)
    interaction = client.interactions.get(id=interaction.id)

# Each hop adds a model_output step, so join the text of all of them.
text = "".join(
    content.text
    for step in interaction.steps
    if step.type == "model_output"
    for content in step.content
    if content.type == "text"
)
print(text)
print("Status:", interaction.status)
print("Usage:", interaction.usage)

JavaScript

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

const client = new GoogleGenAI({});

let interaction = await client.interactions.create({
  model: "gemini-4-argon",
  input: "Write a complete, rigorous proof of the prime number theorem.",
  background: true,
  generation_config: {
    max_output_tokens: 262144,
    thinking_level: "high",
  },
});

while (interaction.status === "in_progress" || interaction.status === "queued") {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  interaction = await client.interactions.get(interaction.id);
}

// Each hop adds a model_output step, so join the text of all of them.
const text = interaction.steps
  .filter((step) => step.type === "model_output")
  .flatMap((step) => step.content ?? [])
  .filter((content) => content.type === "text")
  .map((content) => content.text)
  .join("");
console.log(text);
console.log("Status:", interaction.status);
console.log("Usage:", interaction.usage);

REST

ID=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-4-argon",
    "input": "Write a complete, rigorous proof of the prime number theorem.",
    "background": true,
    "generation_config": {
      "max_output_tokens": 262144,
      "thinking_level": "high"
    }
  }' | jq -r '.id')

while true; do
  RESP=$(curl -s "https://generativelanguage.googleapis.com/v1beta/interactions/$ID" \
    -H "x-goog-api-key: $GEMINI_API_KEY")
  STATUS=$(echo "$RESP" | jq -r '.status')
  if [[ "$STATUS" != "in_progress" && "$STATUS" != "queued" ]]; then
    echo "$RESP" | jq -r '[.steps[]? | select(.type == "model_output") | .content[]? | select(.type == "text") | .text] | join("")'
    break
  fi
  sleep 5
done

后台执行是运行长解码的最简单方法。它会在服务器端运行连续循环,直到模型完成或达到 max_output_tokens。如果您需要对重试、退避和错误处理进行更精细的控制(或者不希望存储互动),可以在 GenerateContent API 中使用客户端连续。客户端连续也即将推出到 Interactions API。如需了解流式传输、重新连接、token 计数以及何时使用长解码,请参阅长解码指南。

设置输出 token 限制

max_output_tokens 设置了响应的总思考和输出 token。请将其设置为足够高的值,以免思考截断答案;并将其设置为足够低的值,以便在硬提示使用所有 token 时限制支出。

请使用以下值作为起点:

  • 标准任务: 保留默认值 65,536,或不设置任何值。
  • 现有应用,限制低于 32K: 将 max_output_tokens 至少提高到 32,768。与之前的模型相比,Gemini 4 Argon 可以将更多限制用于思考。如需使用更少的 token,请改为降低思考级别。
  • 复杂推理和编码: 设置 background: true,并将 max_output_tokens 设置为 131,072 或 262,144,最多可达 1,048,576 减去您的输入 token。

了解思考级别

思考级别是您在 Gemini 4 Argon 中控制质量、延迟时间和 token 使用情况的主要方式:

思考级别 token 使用情况 适用情形
low 最少的 token,最低的延迟时间 更简单的任务和对成本敏感的工作。也适用于需要轻度思考的分析和写作任务。在困难的任务中,质量可能会下降。
medium(默认) 平衡 建议用于大多数任务,包括复杂的代码和智能体用例。
high 最多的 token,最慢的首 token 复杂推理、复杂的数学和科学,以及最困难的代码或智能体任务。非常适合与长解码搭配使用,以实现长输出。

在所有三个级别运行评估,然后选择满足质量要求的最低级别。如需了解详情,请参阅思考指南。

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-4-argon",
    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-4-argon",
  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
  },
});

console.log(interaction.output_text);

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-4-argon",
    "input": "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
    "generation_config": {
      "thinking_level": "medium"
    }
  }'

托管式智能体中的 Gemini 4 Argon

Gemini 托管式智能体中的 Antigravity 智能体 支持 Gemini 4 Argon。如需使用它,请在 agent_config 中设置模型:

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",
    agent_config={
        "type": "antigravity",
        "model": "gemini-4-argon",
    },
)

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",
  agent_config: {
    type: "antigravity",
    model: "gemini-4-argon",
  },
}, { timeout: 300000 });

console.log(interaction.output_text);

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": {
      "type": "antigravity",
      "model": "gemini-4-argon"
    }
  }'

如需了解更多选项,请参阅 Antigravity 智能体指南中的模型选择。

迁移核对清单

  `/gemini-api-dev migrate my app to Gemini 4 Argon`

迁移到 gemini-4-argon

  • 更新模型 ID: 将目标模型字符串更改为 gemini-4-argon。
  • 查看 max_output_tokens: 如果您今天明确设置了该值,请考虑提高它。我们建议至少设置为 32,768,因为 Gemini 4 Argon 可以将更多限制用于思考。
  • 配置思考级别: 选择 low、medium(默认)或 high,并在所有三个级别测试工作负载。
  • 停用显式上下文缓存: Gemini 4 Argon 不支持显式缓存(cachedContents / caches.create)。从请求中移除创建或引用 cached_content 的调用。隐式缓存对于至少 4,096 个 token 的提示,默认启用,并且在缓存命中时,缓存的输入 token 可享受 95% 的折扣。
  • 移除抽样参数: 从请求中移除 temperature、top_p 和 top_k。如果提供这些参数,系统会忽略它们。
  • 使用后台执行实现长输出: 对于需要超过 64K 个 token 的任务,请将 background 设置为 true,并将 max_output_tokens 设置为大于 65,536。
  • 增加客户端超时时间: 硬提示可能需要几分钟时间。请使用后台执行,或将 HTTP 客户端超时时间设置为至少 15 分钟。
  • 在服务器上保留对话状态: 对于多轮对话和函数调用对话,请使用 previous_interaction_id。

价格

在 2026 年 11 月 30 日之前,Gemini 4 Argon 以初次体验价提供:

  • 输入 token: 每 100 万个 token 收费 2.00 美元(自 2026 年 12 月 1 日起,每 100 万个 token 收费 4.00 美元)
    • 缓存的输入 token: 隐式缓存可为缓存的输入 token 提供 95% 的折扣,即每 100 万个 token 收费 0.10 美元(自 2026 年 12 月 1 日起,每 100 万个 token 收费 0.20 美元)。
  • 输出 token,包括思考 token: 每 100 万个 token 收费 10.00 美元(自 2026 年 12 月 1 日起,每 100 万个 token 收费 20.00 美元)

Gemini 4 Argon 不适用于免费层级或 Google AI Pro 方案。如需了解完整价格层级,请参阅价格页面。

其他模型

后续步骤