Gemini 4 Argon (gemini-4-argon) 是 Google 最新、最強大的模型,對於困難問題,這個模型會花較長時間推論,因此在複雜的程式設計、代理功能、數學和科學任務中,能產生更優異的結果。Gemini 4 Argon 可透過 Gemini API 和 Google AI Studio 使用。
Gemini 4 Argon 支援統一的 100 萬個詞元脈絡窗口、最多 100 萬個詞元的長解碼,以及可調整的思考程度 (low、medium、high)。
前往 AI Studio 試用
使用 Gemini 4 Argon 和 AI Studio,從零開始建構應用程式。
應用程式庫
使用 Gemini 4 Argon 建構的應用程式,並加以改造。
開始使用
使用啟動提示詞,開始體驗 Gemini 4 Argon。
本指南說明 Gemini 4 Argon 的新功能、API 異動、程式碼範例和遷移指南。
新增模型
| 模型 | 模型 ID | 預設思考程度 | 定價 | 說明 |
|---|---|---|---|---|
| Gemini 4 Argon | gemini-4-argon |
medium |
2026 年 11 月 30 日前,可享新用戶優惠價:每 100 萬個輸入詞元 $2 美元,每 100 萬個輸出詞元 $10 美元 (之後為每 100 萬個輸入詞元 $4 美元,每 100 萬個輸出詞元 $20 美元)。詳情請參閱定價。 | Google 最強大的模型,專為解決最困難的問題而生,能深入精準地處理實際的軟體工程和知識工作。 |
如需完整詳細資料,請參閱 Gemini 4 Argon 模型頁面。如要瞭解新用戶優惠詳情,請參閱本頁下方的價格部分或定價頁面。
快速入門導覽課程
請參考下列範例,使用建議的預設 thinking_level (medium) 和 64K 輸出詞元限制,向 gemini-4-argon 傳送要求:
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 萬個輸入/輸出詞元限制:輸入、思考和輸出共用一個 1,048,576 個詞元的窗口。
- 解碼時間較長:單一回覆現在可超過 64, 000 個權杖,最多可達 100 萬個權杖 (扣除輸入內容)。請參閱「長時間解碼」。
- 代理式影片解讀功能正式發布: 代理式影片解讀功能現已正式發布。
- 受管理代理支援:Gemini 受管理代理中的 Antigravity 代理程式現在支援 Gemini 4 Argon。
如需完整規格,請參閱 Gemini 4 Argon 模型頁面。如需定價詳細資料,請參閱定價頁面。
輸出內容較大且解碼時間較長
Gemini 4 Argon 可以花更多時間思考困難的數學、科學和程式設計問題。
- 使用
thinking_level控制推論深度:思考程度決定模型在回答前推論的深度。max_output_tokens是硬性限制:思考和輸出內容達到這個限制時,就會停止回覆,因此請設定足夠的值,以免答案遭到截斷。 透過背景執行產生最多 100 萬個權杖:使用
max_output_tokens大於 65,536 的背景執行,讓單一回應超過 64, 000 個權杖,最多可達 100 萬個權杖。模型會以最多 64K 個詞元的跳躍方式生成長回覆,每次跳躍都會從上次停止的位置繼續。有了背景執行功能,我們的伺服器會為您執行這些接續跳轉。因為每個躍點都會在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 也即將支援用戶端接續功能。如要瞭解串流、重新連線、詞元計數,以及何時使用長解碼,請參閱長解碼指南。
設定輸出詞元限制
max_output_tokens 則設定回覆的思考和輸出權杖總數。設定時,請確保上限夠高,不會讓思考過程縮短回覆內容,同時也要夠低,避免複雜的提示詞耗盡所有預算。
請使用下列值做為起點:
- 標準工作:保留預設值 65,536,或不設定任何值。
- 現有應用程式的限制低於 32K:將
max_output_tokens提高至至少 32,768。Gemini 4 Argon 的思考用量上限高於早期模型。如要減少詞元用量,請降低思考等級。 - 複雜的推理和編碼:將
background: true設為,並將max_output_tokens設為 131,072 或 262,144,最多可設為 1,048,576 減去輸入的權杖數。
瞭解思考程度
思考層級是控制 Gemini 4 Argon 品質、延遲和權杖用量的主要方式:
| 思考程度 | 詞元用量 | 使用時機 |
|---|---|---|
low |
詞元最少,延遲時間最短 | 簡單的工作和預算有限的工作。也適合用於需要稍微動腦的分析和寫作工作。處理困難工作時,品質可能會下降。 |
medium (預設) |
平衡 | 建議用於大多數工作,包括複雜的程式碼和代理用途。 |
high |
詞元最多,第一個詞元生成速度最慢 | 複雜的推理、困難的數學和科學,以及最困難的程式碼或代理程式工作。如果輸出內容較長,建議搭配長解碼使用。 |
請在三個層級都執行評估,然後選擇符合品質標準的最低層級。詳情請參閱思考指南。
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"
}
}'
Managed Agents 中的 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 個詞元,系統預設會啟用隱含快取,並在快取命中時,將快取輸入詞元的費用折扣 95%。 - 移除取樣參數:從要求中移除
temperature、top_p和top_k。如果提供,系統會忽略這些值。 - 使用背景執行功能處理長輸出內容:如果工作需要超過 64, 000 個權杖,請將
background設為 true,並將max_output_tokens設為大於 65,536。 - 延長用戶端逾時時間:硬提示可能需要幾分鐘才能完成。請在背景執行,或將 HTTP 用戶端逾時時間設為至少 15 分鐘。
- 在伺服器上保留對話狀態:使用
previous_interaction_id進行多輪對話和函式呼叫對話。
定價
2026 年 11 月 30 日前,Gemini 4 Argon 均以新用戶優惠提供:
- 輸入詞元:每 100 萬個詞元 $2.00 美元 (2026 年 12 月 1 日起為 $4.00 美元)
- 快取輸入權杖:隱含快取會將快取輸入內容的費用折扣 95%,因此每 100 萬個權杖的費用為 $0.10 美元 (2026 年 12 月 1 日起為 $0.20 美元)。
- 輸出詞元,包括思考詞元:每 100 萬個詞元 $10.00 (2026 年 12 月 1 日起為 $20.00)
Gemini 4 Argon 不適用於免費方案或 Google AI Pro 方案。如要查看完整的定價級別,請參閱定價頁面。
其他模型
後續步驟
- 請參閱長解碼指南,瞭解串流、重新連線和詞元計數。
- 如要瞭解思考層級和思考摘要的運作方式,請參閱思考指南。
- 如要瞭解長時間執行的工作,請參閱背景執行指南。
- 在 Google AI Studio 測試及調整提示。