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.8-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.8-flash",
    input: "Explain the concept of Occam's Razor and provide a simple, everyday example."
});
console.log(interaction.output_text);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of("Explain the concept of Occam's Razor and provide a simple example."))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.HIGH).build())
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

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.8-flash",
    "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.8-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.8-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);
            }
        }
    }
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of("Explain the concept of Occam's Razor and provide a simple example."))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.HIGH).build())
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

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.8-flash",
    "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.8-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.8-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;
        }
    }
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of("Explain the concept of Occam's Razor and provide a simple example."))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.HIGH).build())
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

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.8-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
  }'

स्ट्रीमिंग के जवाब में, Server-Sent Events (SSE) का इस्तेमाल किया जाता है. इसमें चरण और इवेंट शामिल होते हैं. उदाहरण के लिए:

event: interaction.created
data: {"interaction":{"id":"v1_xxx","status":"in_progress","object":"interaction","model":"gemini-3.8-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]

रीज़निंग को कंट्रोल करना

Gemini मॉडल, डिफ़ॉल्ट रूप से डाइनैमिक रीज़निंग करते हैं. ये अनुरोध की मुश्किल के हिसाब से, रीज़निंग की कोशिश को अपने-आप कम या ज़्यादा करते हैं. thinking_level पैरामीटर का इस्तेमाल करके, इस व्यवहार को कंट्रोल किया जा सकता है.

मॉडल डिफ़ॉल्ट रीज़निंग सपोर्ट करने वाले लेवल
gemini-3.8-flash चालू (मीडियम) लो, मीडियम, हाई
gemini-3.7-flash चालू (मीडियम) लो, मीडियम, हाई
gemini-3.6-flash चालू (मीडियम) मिनिमल, लो, मीडियम, हाई
gemini-3.5-flash-lite चालू (मिनिमल) मिनिमल, लो, मीडियम, हाई
gemini-3.1-pro-preview चालू (हाई) लो, मीडियम, हाई
gemini-3.1-flash-lite-image चालू (मिनिमल) मिनिमल, हाई
gemini-3-flash-preview चालू (हाई) मिनिमल, लो, मीडियम, हाई
gemini-3-pro-preview चालू (हाई) लो, हाई
gemini-3.5-flash चालू (मीडियम) मिनिमल, लो, मीडियम, हाई
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.8-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: "gemini-3.8-flash",
    input: "Provide a list of 3 famous physicists and their key contributions",
    generation_config: {
        thinking_level: "low"
    }
});
console.log(interaction.output_text);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of("Explain the concept of Occam's Razor and provide a simple example."))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.HIGH).build())
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

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.8-flash",
    "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}`);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of("Explain the concept of Occam's Razor and provide a simple example."))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.HIGH).build())
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

रीज़निंग मॉडल, फ़ाइनल जवाब की क्वालिटी को बेहतर बनाने के लिए, पूरी रीज़निंग करते हैं. इसके बाद, रीज़निंग की प्रोसेस के बारे में अहम जानकारी देने के लिए, खास जानकारी के तौर पर आउटपुट देते हैं. कीमत, मॉडल को जनरेट करने के लिए ज़रूरी रीज़निंग टोकन के आधार पर तय की जाती है. भले ही, एपीआई से सिर्फ़ खास जानकारी का आउटपुट मिलता हो.

टोकन की गिनती करने के बारे में ज़्यादा जानने के लिए, टोकन की गिनती करने से जुड़ी गाइड पढ़ें.

सबसे सही तरीके

इन दिशा-निर्देशों का पालन करके, रीज़निंग मॉडल का बेहतर तरीके से इस्तेमाल करें.

  • रीज़निंग की समीक्षा करना: गड़बड़ियों को समझने और प्रॉम्प्ट को बेहतर बनाने के लिए, रीज़निंग की खास जानकारी का विश्लेषण करें.
  • रीज़निंग के बजट को कंट्रोल करना: टोकन बचाने के लिए, मॉडल को लंबे आउटपुट के लिए कम रीज़निंग करने के लिए प्रॉम्प्ट करें.
  • सामान्य टास्क: फ़ैक्ट की जानकारी पाने या कैटगरी में बांटने के लिए, कम या सामान्य रीज़निंग का इस्तेमाल करें. जैसे, "DeepMind की स्थापना कहां हुई थी?".
  • मीडियम टास्क: कॉन्सेप्ट की तुलना करने या क्रिएटिव रीज़निंग के लिए, डिफ़ॉल्ट रीज़निंग का इस्तेमाल करें. जैसे, इलेक्ट्रिक और हाइब्रिड कारों की तुलना करें.
  • मुश्किल टास्क: ऐडवांस कोडिंग, गणित या कई चरणों वाली प्लानिंग के लिए, ज़्यादा से ज़्यादा रीज़निंग का इस्तेमाल करें. जैसे, AIME के गणित के सवाल हल करें.

आगे क्या करना है