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 日之前,初次体验价为 $2/百万输入 token,$10/百万输出 token(之后为 $4/百万输入 token,$20/百万输出 token)。如需了解详情,请参阅价格。 我们最强大的模型,专为解决最棘手的问题而打造,可在实际软件工程和知识工作任务中提供深度和精准度。

如需了解完整详情,请参阅 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 的窗口。
  • 长解码:单次回答现在可以超过 6.4 万个 token,最多可达 100 万个 token 减去输入 token 数。请参阅解码时间过长。
  • 智能体视频理解功能已正式发布:智能体视频理解功能现已正式发布。
  • 在托管式智能体中受支持:Gemini 托管式智能体中的 Antigravity 智能体现在支持 Gemini 4 Argon。

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

输出更长,解码时间更长

Gemini 4 Argon 能够更深入地思考复杂的数学、科学和编码问题。

  • 使用 thinking_level 控制推理深度:思考等级决定了模型在回答之前进行推理的深度。max_output_tokens 是一个硬性限制:当思考和输出的总和达到该限制时,回答就会停止,因此请将其设置得足够高,以免回答被截断。
  • 通过后台执行生成多达 100 万个 token:使用后台执行,并将 max_output_tokens 设置为大于 65,536,让单个回答超过 6.4 万个 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 数量上限

max_output_tokens 用于设置回答的总思考和输出 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 Managed Agents 中的 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 进行多轮对话和函数调用对话。

价格

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

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

Gemini 4 Argon 不适用于免费层级。如需了解完整的价格层级,请参阅价格页面。

其他模型

后续步骤