Gemini की सोच-समझकर जवाब देने की क्षमता
Gemini 3 और 2.5 सीरीज़ के मॉडल, "सोच-समझकर जवाब देने की प्रोसेस" का इस्तेमाल करते हैं. इससे, उनकी रीज़निंग और मल्टी-स्टेप प्लानिंग की क्षमताओं में काफ़ी सुधार होता है. इस वजह से, ये मॉडल कोडिंग, ऐडवांस गणित, और डेटा ऐनलिसिस जैसे मुश्किल कामों के लिए काफ़ी कारगर साबित होते हैं.
सोच-समझकर जवाब देने वाले मॉडल का इस्तेमाल करने पर, Gemini जवाब देने से पहले इंटरनल तौर पर रीज़निंग करता है. Interactions API, thought स्टेप के ज़रिए इस रीज़निंग को दिखाता है. ये खास स्टेप, steps कलेक्शन में फ़ंक्शन कॉल, उपयोगकर्ता के इनपुट या मॉडल के आउटपुट के साथ क्रम से दिखते हैं.
हर थॉट स्टेप में दो फ़ील्ड होते हैं:
| फ़ील्ड | ज़रूरी है | ब्यौरा |
|---|---|---|
signature |
✅ हां | मॉडल की इंटरनल रीज़निंग की स्थिति का एन्क्रिप्ट किया गया वर्शन. यह हमेशा मौजूद होता है. भले ही, मॉडल कम से कम रीज़निंग करता हो. |
summary |
❌ नहीं | रीज़निंग की खास जानकारी देने वाला कॉन्टेंट (टेक्स्ट और/या इमेज) का कलेक्शन. thinking_summaries कॉन्फ़िगरेशन, मॉडल ने ज़रूरत के मुताबिक रीज़निंग की है या नहीं, या कॉन्टेंट के टाइप के आधार पर, यह खाली हो सकता है. उदाहरण के लिए, इमेज लेटेंट में टेक्स्ट की खास जानकारी मौजूद नहीं हो सकती है. |
सोच-समझकर जवाब देने की सुविधा के साथ इंटरैक्शन
सोच-समझकर जवाब देने वाले मॉडल के साथ इंटरैक्शन शुरू करने का तरीका, किसी अन्य इंटरैक्शन के अनुरोध जैसा ही होता है. `model` फ़ील्ड में, सोच-समझकर जवाब देने की सुविधा वाले किसी `मॉडल` के बारे में बताएं:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
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-flash-preview",
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 "Api-Revision: 2026-05-20" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": "Explain the concept of Occam'\''s Razor and provide a simple example."
}'
सोच-समझकर जवाब देने की प्रोसेस की खास जानकारी
सोच-समझकर जवाब देने की प्रोसेस की खास जानकारी से, मॉडल की इंटरनल रीज़निंग प्रोसेस के बारे में अहम जानकारी मिलती है.
डिफ़ॉल्ट रूप से, सिर्फ़ फ़ाइनल आउटपुट दिखता है. thinking_summaries की मदद से, सोच-समझकर जवाब देने की प्रोसेस की खास जानकारी को चालू किया जा सकता है:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
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-flash-preview",
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 "Api-Revision: 2026-05-20" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": "What is the sum of the first 50 prime numbers?",
"generation_config": {
"thinking_summaries": "auto"
}
}'
इन मामलों में, थॉट ब्लॉक में सिर्फ़ सिग्नेचर हो सकता है. इसमें खास जानकारी नहीं होती:
- सामान्य अनुरोधों के लिए, मॉडल ने खास जानकारी जनरेट करने के लिए ज़रूरत के मुताबिक रीज़निंग नहीं की
thinking_summaries: "none"के लिए, खास जानकारी को साफ़ तौर पर बंद किया गया है- कुछ खास तरह के थॉट कॉन्टेंट, जैसे कि इमेज के लिए, टेक्स्ट की खास जानकारी मौजूद नहीं हो सकती है
आपके कोड को हमेशा ऐसे थॉट ब्लॉक को हैंडल करना चाहिए जिनमें summary खाली हो या मौजूद न हो.
सोच-समझकर जवाब देने की सुविधा के साथ स्ट्रीमिंग
जनरेट करने के दौरान, सोच-समझकर जवाब देने की प्रोसेस की खास जानकारी पाने के लिए, स्ट्रीमिंग का इस्तेमाल करें. थॉट ब्लॉक, Server-Sent Events (SSE) का इस्तेमाल करके डिलीवर किए जाते हैं. इनमें दो अलग-अलग डेल्टा टाइप होते हैं:
| डेल्टा टाइप | इसमें शामिल है | यह डेटा कब भेजा जाता है |
|---|---|---|
thought_summary |
टेक्स्ट या इमेज की खास जानकारी वाला कॉन्टेंट | खास जानकारी के साथ एक या उससे ज़्यादा डेल्टा |
thought_signature |
क्रिप्टोग्राफ़िक सिग्नेचर | 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-flash-preview",
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-flash-preview",
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 "Api-Revision: 2026-05-20" \
-H 'Content-Type: application/json' \
--no-buffer \
-d '{
"model": "gemini-3-flash-preview",
"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
}'
स्ट्रीमिंग रिस्पॉन्स, Server-Sent Events (SSE) का इस्तेमाल करता है. इसमें स्टेप और इवेंट शामिल होते हैं. उदाहरण के लिए:
event: interaction.created
data: {"interaction":{"id":"v1_xxx","status":"in_progress","object":"interaction","model":"gemini-3-flash-preview"},"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]
सोच-समझकर जवाब देने की सुविधा को कंट्रोल करना
Gemini के मॉडल, डिफ़ॉल्ट रूप से डाइनैमिक थिंकिंग में शामिल होते हैं. ये अनुरोध की जटिलता के आधार पर, रीज़निंग की कोशिश को अपने-आप कम या ज़्यादा करते हैं. thinking_level पैरामीटर का इस्तेमाल करके, इस व्यवहार को कंट्रोल किया जा सकता है.
| मॉडल | डिफ़ॉल्ट थिंकिंग | इस्तेमाल किए जा सकने वाले लेवल |
|---|---|---|
| gemini-3.1-pro-preview | चालू (ज़्यादा) | कम, सामान्य, ज़्यादा |
| gemini-3-flash-preview | चालू (ज़्यादा) | कम से कम, कम, सामान्य, ज़्यादा |
| gemini-3-pro-preview | चालू (ज़्यादा) | कम, ज़्यादा |
| gemini-2.5-pro | चालू | कम, सामान्य, ज़्यादा |
| gemini-2.5-flash | चालू | कम, सामान्य, ज़्यादा |
| gemini-2.5-flash-lite | बंद है | कम, सामान्य, ज़्यादा |
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
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: "gemini-3-flash-preview",
input: "Provide a list of 3 famous physicists and their key contributions",
generation_config: {
thinking_level: "low"
}
});
console.log(interaction.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": "Provide a list of 3 famous physicists and their key contributions",
"generation_config": {
"thinking_level": "low"
}
}'
सोच-समझकर जवाब देने की प्रोसेस के सिग्नेचर
सोच-समझकर जवाब देने की प्रोसेस के सिग्नेचर, मॉडल की इंटरनल रीज़निंग के एन्क्रिप्ट किए गए वर्शन होते हैं. मल्टी-टर्न इंटरैक्शन के दौरान, रीज़निंग की प्रोसेस को जारी रखने के लिए इनकी ज़रूरत होती है.
Interactions API की मदद से, सोच-समझकर जवाब देने की प्रोसेस के सिग्नेचर को generateContent API के मुकाबले ज़्यादा आसानी से हैंडल किया जा सकता है.
स्टेटफ़ुल मोड (सुझाया गया)
डिफ़ॉल्ट रूप से, स्टेटफ़ुल मोड में Interactions API का इस्तेमाल करने पर (यानी, store: true सेट करने और बाद के टर्न में previous_interaction_id पास करने पर), सर्वर बातचीत की स्थिति को अपने-आप मैनेज करता है. इसमें, सोच-समझकर जवाब देने की प्रोसेस के सभी ब्लॉक और सिग्नेचर शामिल होते हैं. इस मोड में, आपको सिग्नेचर के बारे में कुछ भी करने की ज़रूरत नहीं होती. इन्हें पूरी तरह से सर्वर साइड पर हैंडल किया जाता है.
स्टेटलेस मोड
अगर बातचीत की स्थिति को खुद मैनेज किया जा रहा है (स्टेटलेस मोड) और हर अनुरोध में इनपुट और आउटपुट का पूरा इतिहास पास किया जा रहा है, तो:
- आपको हमेशा सभी
thoughtब्लॉक को ठीक उसी तरह से फिर से भेजना होगा जिस तरह से वे मॉडल से मिले थे. - आपको इतिहास से सोच-समझकर जवाब देने की प्रोसेस के ब्लॉक नहीं हटाने या उनमें बदलाव नहीं करना चाहिए, क्योंकि इनमें वे सिग्नेचर शामिल होते हैं जिनकी मदद से मॉडल अपनी रीज़निंग जारी रख सकता है.
- किसी सेशन में मॉडल स्विच करते समय, आपको पिछले मॉडल के सोच-समझकर जवाब देने की प्रोसेस के ब्लॉक फिर से भेजने चाहिए. बैकएंड, कंपैटिबिलिटी को मैनेज करता है.
कीमत
सोच-समझकर जवाब देने की सुविधा चालू होने पर, रिस्पॉन्स की कीमत, आउटपुट टोकन और सोच-समझकर जवाब देने की प्रोसेस के टोकन के योग के बराबर होती है. total_thought_tokens फ़ील्ड से, जनरेट किए गए सोच-समझकर जवाब देने की प्रोसेस के टोकन की कुल संख्या पाई जा सकती है.
Python
print("Thoughts tokens:", interaction.usage.total_thought_tokens)
print("Output tokens:", interaction.usage.total_output_tokens)
JavaScript
console.log(`Thoughts tokens: ${interaction.usage.total_thought_tokens}`);
console.log(`Output tokens: ${interaction.usage.total_output_tokens}`);
सोच-समझकर जवाब देने वाले मॉडल, फ़ाइनल रिस्पॉन्स की क्वालिटी को बेहतर बनाने के लिए, पूरी तरह से सोच-समझकर जवाब देते हैं. इसके बाद, सोच-समझकर जवाब देने की प्रोसेस की खास जानकारी देते हैं, ताकि इस प्रोसेस के बारे में अहम जानकारी मिल सके. कीमत, मॉडल को जनरेट करने के लिए ज़रूरी सोच-समझकर जवाब देने की प्रोसेस के टोकन के आधार पर तय की जाती है. भले ही, एपीआई से सिर्फ़ खास जानकारी का आउटपुट मिलता हो.
टोकन के बारे में ज़्यादा जानने के लिए, टोकन की गिनती करने से जुड़ी गाइड पढ़ें.
सबसे सही तरीके
इन दिशा-निर्देशों का पालन करके, सोच-समझकर जवाब देने वाले मॉडल का बेहतर तरीके से इस्तेमाल करें.
- रीज़निंग की समीक्षा करना: गड़बड़ियों को समझने और प्रॉम्प्ट को बेहतर बनाने के लिए, सोच-समझकर जवाब देने की प्रोसेस की खास जानकारी का विश्लेषण करें.
- सोच-समझकर जवाब देने की प्रोसेस के बजट को कंट्रोल करना: टोकन बचाने के लिए, मॉडल को लंबे आउटपुट के लिए कम सोचने के लिए प्रॉम्प्ट करें.
- सामान्य टास्क: फ़ैक्ट पाने या कैटगरी में बांटने के लिए, कम से कम सोच-समझकर जवाब देने की सुविधा का इस्तेमाल करें. जैसे, "DeepMind की स्थापना कहां हुई थी?".
- मॉडरेट टास्क: कॉन्सेप्ट की तुलना करने या क्रिएटिव रीज़निंग के लिए, डिफ़ॉल्ट सोच-समझकर जवाब देने की सुविधा का इस्तेमाल करें. जैसे, इलेक्ट्रिक और हाइब्रिड कारों की तुलना करें.
- मुश्किल टास्क: ऐडवांस कोडिंग, गणित या मल्टी-स्टेप प्लानिंग के लिए, ज़्यादा से ज़्यादा सोच-समझकर जवाब देने की सुविधा का इस्तेमाल करें. जैसे, AIME के गणित के सवाल हल करें.
आगे क्या करना है
- टेक्स्ट जनरेट करने की सुविधा: टेक्स्ट में सामान्य जवाब
- फ़ंक्शन कॉल करने की सुविधा: टूल से कनेक्ट करना
- Gemini 3 की गाइड: मॉडल के हिसाब से सुविधाएं