Model seri Gemini 3 dan 2.5 menggunakan "proses berpikir" yang secara signifikan meningkatkan kemampuan penalaran dan perencanaan multi-langkahnya, sehingga sangat efektif untuk tugas-tugas kompleks seperti coding, matematika tingkat lanjut, dan analisis data.
Saat Anda menggunakan model yang berbasis penalaran, Gemini akan melakukan penalaran secara internal sebelum memberikan respons. Interactions API menampilkan alasan ini melalui langkah-langkah thought, langkah-langkah khusus yang muncul secara kronologis bersama panggilan fungsi, input pengguna, atau output model dalam array steps.
Setiap langkah pemikiran berisi dua kolom:
| Kolom | Wajib | Deskripsi |
|---|---|---|
signature |
✅ Ya | Representasi terenkripsi dari status penalaran internal model. Selalu ada, bahkan saat model melakukan penalaran minimal. |
summary |
❌ Tidak | Serangkaian konten (teks dan/atau gambar) yang merangkum penalaran. Mungkin kosong, bergantung pada konfigurasi thinking_summaries, apakah model melakukan penalaran yang cukup, atau jenis konten (misalnya, latensi gambar mungkin tidak memiliki ringkasan teks). |
Interaksi dengan pemikiran
Memulai interaksi dengan model yang berbasis penalaran serupa dengan permintaan interaksi lainnya. Tentukan salah satu model dengan dukungan berpikir di kolom model:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.6-flash",
input="Explain the concept of Occam's Razor and provide a simple, everyday example."
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: "gemini-3.6-flash",
input: "Explain the concept of Occam's Razor and provide a simple, everyday example."
});
console.log(interaction.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.6-flash",
"input": "Explain the concept of Occam'\''s Razor and provide a simple example."
}'
Ringkasan penalaran
Ringkasan pemikiran memberikan insight tentang proses penalaran internal model.
Secara default, hanya output akhir yang ditampilkan. Anda dapat mengaktifkan ringkasan pemikiran
dengan thinking_summaries:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.6-flash",
input="What is the sum of the first 50 prime numbers?",
generation_config={
"thinking_summaries": "auto"
}
)
for step in interaction.steps:
if step.type == "thought":
print("Thought summary:")
if step.summary:
for content_block in step.summary:
if content_block.type == "text":
print(content_block.text)
print()
elif step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print("Answer:")
print(content_block.text)
print()
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: "gemini-3.6-flash",
input: "What is the sum of the first 50 prime numbers?",
generation_config: {
thinking_summaries: "auto"
}
});
for (const step of interaction.steps) {
if (step.type === "thought") {
console.log("Thought summary:");
if (step.summary) {
for (const contentBlock of step.summary) {
if (contentBlock.type === "text") console.log(contentBlock.text);
}
}
} else if (step.type === "model_output") {
for (const contentBlock of step.content) {
if (contentBlock.type === "text") {
console.log("Answer:");
console.log(contentBlock.text);
}
}
}
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.6-flash",
"input": "What is the sum of the first 50 prime numbers?",
"generation_config": {
"thinking_summaries": "auto"
}
}'
Blok pemikiran dapat berisi hanya tanda tangan tanpa ringkasan dalam kasus berikut:
- Permintaan sederhana, di mana model tidak cukup bernalar untuk membuat ringkasan
thinking_summaries: "none", tempat ringkasan dinonaktifkan secara eksplisit- Jenis konten pemikiran tertentu, seperti gambar, mungkin tidak memiliki ringkasan teks
Kode Anda harus selalu menangani blok pemikiran saat summary kosong atau tidak ada.
Streaming dengan penalaran
Gunakan streaming untuk menerima ringkasan pemikiran inkremental selama pembuatan. Blok pemikiran dikirimkan menggunakan Peristiwa yang Dikirim Server (SSE) dengan dua jenis delta yang berbeda:
| Jenis delta | Berisi | Waktu dikirim |
|---|---|---|
thought_summary |
Konten ringkasan teks atau gambar | Satu atau beberapa delta dengan ringkasan inkremental |
thought_signature |
Tanda tangan kriptografi | delta terakhir sebelum step.stop |
Python
from google import genai
client = genai.Client()
prompt = """
Alice, Bob, and Carol each live in a different house on the same street: red, green, and blue.
Alice does not live in the red house.
Bob does not live in the green house.
Carol does not live in the red or green house.
Which house does each person live in?
"""
thoughts = ""
answer = ""
stream = client.interactions.create(
model="gemini-3.6-flash",
input=prompt,
generation_config={
"thinking_summaries": "auto"
},
stream=True
)
for event in stream:
if event.event_type == "step.delta":
if event.delta.type == "thought_summary":
if not thoughts:
print("Thinking...")
summary_text = event.delta.content.text
print(f"[Thought] {summary_text}", end="")
thoughts += summary_text
elif event.delta.type == "text" and event.delta.text:
if not answer:
print("\nAnswer:")
print(event.delta.text, end="")
answer += event.delta.text
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const prompt = `Alice, Bob, and Carol each live in a different house on the same
street: red, green, and blue. Alice does not live in the red house.
Bob does not live in the green house.
Carol does not live in the red or green house.
Which house does each person live in?`;
let thoughts = "";
let answer = "";
const stream = await client.interactions.create({
model: "gemini-3.6-flash",
input: prompt,
generation_config: {
thinking_summaries: "auto"
},
stream: true
});
for await (const event of stream) {
if (event.event_type === "step.delta") {
if (event.delta.type === "thought_summary") {
if (!thoughts) console.log("Thinking...");
const text = event.delta.content?.text || "";
process.stdout.write(`[Thought] ${text}`);
thoughts += text;
} else if (event.delta.type === "text" && event.delta.text) {
if (!answer) console.log("\nAnswer:");
process.stdout.write(event.delta.text);
answer += event.delta.text;
}
}
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
--no-buffer \
-d '{
"model": "gemini-3.6-flash",
"input": "Alice, Bob, and Carol each live in a different house on the same street: red, green, and blue. Alice does not live in the red house. Bob does not live in the green house. Carol does not live in the red or green house. Which house does each person live in?",
"generation_config": {
"thinking_summaries": "auto"
},
"stream": true
}'
Respons streaming menggunakan Server-Sent Events (SSE) dan terdiri dari langkah-langkah dan peristiwa, misalnya:
event: interaction.created
data: {"interaction":{"id":"v1_xxx","status":"in_progress","object":"interaction","model":"gemini-3.6-flash"},"event_type":"interaction.created"}
event: step.start
data: {"index":0,"step":{"signature":"","summary":[{"text":"**Evaluating the clues**\n\nI'm considering...","type":"text"}],"type":"thought"},"event_type":"step.start"}
event: step.delta
data: {"index":0,"delta":{"signature":"EpoGCpcGAXLI2nx/...","type":"thought_signature"},"event_type":"step.delta"}
event: step.stop
data: {"index":0,"event_type":"step.stop"}
event: step.start
data: {"index":1,"step":{"content":[{"text":"Based on the clues provided, here","type":"text"}],"type":"model_output"},"event_type":"step.start"}
event: step.delta
data: {"index":1,"delta":{"text":" is the answer to your question...","type":"text"},"event_type":"step.delta"}
event: step.stop
data: {"index":1,"event_type":"step.stop"}
event: interaction.completed
data: {"interaction":{"id":"v1_xxx","status":"completed","usage":{"total_tokens":530,"total_input_tokens":62,"total_output_tokens":171,"total_thought_tokens":297}},"event_type":"interaction.completed"}
event: done
data: [DONE]
Mengontrol pemikiran
Model Gemini terlibat dalam pemikiran dinamis secara default, dengan otomatis menyesuaikan
jumlah upaya penalaran berdasarkan kompleksitas permintaan. Anda dapat mengontrol perilaku ini menggunakan parameter thinking_level.
| Model | Pemikiran Default | Level yang Didukung |
|---|---|---|
| gemini-3.6-flash | Aktif (sedang) | minimal, rendah, sedang, tinggi |
| gemini-3.5-flash-lite | Aktif (minimal) | minimal, rendah, sedang, tinggi |
| gemini-3.1-pro-preview | Aktif (tinggi) | rendah, sedang, tinggi |
| gemini-3.1-flash-lite-image | Aktif (minimal) | minimal, tinggi |
| gemini-3-flash-preview | Aktif (tinggi) | minimal, rendah, sedang, tinggi |
| gemini-3-pro-preview | Aktif (tinggi) | rendah, tinggi |
| gemini-3.5-flash | Aktif (sedang) | minimal, rendah, sedang, tinggi |
| gemini-2.5-pro | Aktif | rendah, sedang, tinggi |
| gemini-2.5-flash | Aktif | rendah, sedang, tinggi |
| gemini-2.5-flash-lite | Nonaktif | rendah, sedang, tinggi |
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.6-flash",
input="Provide a list of 3 famous physicists and their key contributions",
generation_config={
"thinking_level": "low"
}
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: