Gemini ভাবছে

Gemini 3 ও 2.5 সিরিজের মডেল একটি "চিন্তন প্রক্রিয়া" ব্যবহার করে যা তাদের রিজনিং ও মাল্টি-স্টেপ প্ল্যানিং ক্ষমতাকে উল্লেখযোগ্যভাবে উন্নত করে। এর ফলে, কোডিং, উন্নত গণিত ও ডেটা বিশ্লেষণের মতো জটিল টাস্কের জন্য এগুলি অত্যন্ত কার্যকর হয়ে ওঠে।

আপনি কোনও থিঙ্কিং মডেল ব্যবহার করলে, উত্তর দেওয়ার আগে Gemini ইন্টার্নালি যুক্তি দেয়। Interaction API, thought ধাপের মাধ্যমে এই যুক্তি দেখায়, steps অ্যারেতে ফাংশন কল, ব্যবহারকারীর ইনপুট বা মডেল আউটপুটের পাশাপাশি কালানুক্রমিকভাবে দেখানো ডেডিকেটেড ধাপ।

প্রতিটি চিন্তার ধাপে দুটি ফিল্ড থাকে:

ফিল্ড প্রয়োজনীয় বিবরণ
signature ✅ হ্যাঁ মডেলের ইন্টার্নাল যুক্তিযুক্ত অবস্থার এনক্রিপ্ট করা উপস্থাপনা। মডেল ন্যূনতম যুক্তি প্রয়োগ করলেও সবসময় উপস্থিত থাকে।
summary ❌ না যুক্তিকে সংক্ষিপ্তসার করে এমন কন্টেন্টের (টেক্সট এবং/অথবা ছবি) একটি অ্যারে। thinking_summaries কনফিগারেশনের উপর নির্ভর করে খালি থাকতে পারে, মডেলটি পর্যাপ্ত যুক্তি প্রদান করেছে কিনা বা কন্টেন্টের ধরন (যেমন, ইমেজ ল্যাটেন্টে টেক্সট সারসংক্ষেপ নাও থাকতে পারে)।

Thinking-এর সাথে ইন্টার‍্যাকশন

থিংকিং মডেলের সাথে ইন্টার‍্যাকশন শুরু করা, অন্য যেকোনও ইন্টার‍্যাকশন অনুরোধের মতোই। 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)

জাভাস্ক্রিপ্ট

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.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
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, everyday example."))
        .build();

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

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

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-pro"),
            Input: interactions.NewInteractionsInput("Explain the concept of Occam's Razor and provide a simple, everyday example."),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.Interaction.OutputText != nil {
        fmt.Println(*res.Interaction.OutputText)
    }
}

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()

জাভাস্ক্রিপ্ট

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.Content;
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.ModelOutputStep;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.interactions.ThoughtStep;
import com.google.genai.gaos.models.interactions.ThoughtSummaryContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Collections;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of("What is the sum of the first 50 prime numbers?"))
        .generationConfig(
            GenerationConfig.builder().thinkingSummaries(ThinkingSummaries.AUTO).build())
        .build();

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

for (Step step : interaction.steps().orElse(Collections.emptyList())) {
  if (step instanceof ThoughtStep thoughtStep) {
    System.out.println("Thought summary:");
    for (ThoughtSummaryContent contentBlock : thoughtStep.summary().orElse(Collections.emptyList())) {
      if (contentBlock instanceof TextContent textContent) {
        System.out.println(textContent.text().orElse(""));
      }
    }
    System.out.println();
  } else if (step instanceof ModelOutputStep outputStep) {
    for (Content contentBlock : outputStep.content().orElse(Collections.emptyList())) {
      if (contentBlock instanceof TextContent textContent) {
        System.out.println("Answer:");
        System.out.println(textContent.text().orElse(""));
        System.out.println();
      }
    }
  }
}

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-flash"),
            Input: interactions.NewInteractionsInput("Provide a list of 3 famous physicists and their key contributions"),
            GenerationConfig: &interactions.GenerationConfig{
                ThinkingLevel: interactions.ThinkingLevelLow.ToPointer(),
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.Interaction.OutputText != nil {
        fmt.Println(*res.Interaction.OutputText)
    }
}

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

জাভাস্ক্রিপ্ট

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.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.StepDelta;
import com.google.genai.gaos.models.interactions.StepDeltaData;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.TextDelta;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.interactions.ThoughtSummaryDelta;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.utils.EventStream;

Client client = new Client();

String prompt =
    "Alice, Bob, and Carol each live in a different house on the same street: red, green, and blue.\n"
        + "Alice does not live in the red house.\n"
        + "Bob does not live in the green house.\n"
        + "Carol does not live in the red or green house.\n"
        + "Which house does each person live in?";

StringBuilder thoughts = new StringBuilder();
StringBuilder answer = new StringBuilder();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.of(prompt))
        .generationConfig(
            GenerationConfig.builder().thinkingSummaries(ThinkingSummaries.AUTO).build())
        .stream(true)
        .build();

CreateInteractionResponse response =
    client.interactions.create(CreateInteractionRequestBody.of(params));

try (EventStream<InteractionSSEStreamEvent> stream = response.events()) {
  for (InteractionSSEStreamEvent streamEvent : stream) {
    InteractionSSEEvent event = streamEvent.data().orElse(null);
    if (event instanceof StepDelta stepDelta) {
      StepDeltaData delta = stepDelta.delta().orElse(null);
      if (delta instanceof ThoughtSummaryDelta thoughtDelta) {
        Content content = thoughtDelta.content().orElse(null);
        if (content instanceof TextContent textContent) {
          if (thoughts.length() == 0) {
            System.out.println("Thinking...");
          }
          String summaryText = textContent.text().orElse("");
          System.out.print("[Thought] " + summaryText);
          thoughts.append(summaryText);
        }
      } else if (delta instanceof TextDelta textDelta) {
        String text = textDelta.text().orElse("");
        if (!text.isEmpty()) {
          if (answer.length() == 0) {
            System.out.println("\nAnswer:");
          }
          System.out.print(text);
          answer.append(text);
        }
      }
    }
  }
}

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-flash"),
            Input: interactions.NewInteractionsInput("What is the sum of the first 50 prime numbers?"),
            GenerationConfig: &interactions.GenerationConfig{
                ThinkingLevel:     interactions.ThinkingLevelHigh.ToPointer(),
                ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, step := range res.Interaction.Steps {
        if thought := step.ThoughtStep; thought != nil {
            for _, part := range thought.Summary {
                if part.TextContent != nil {
                    fmt.Printf("Thought summary:\n%s\n\n", part.TextContent.Text)
                }
            }
        }
    }

    if res.Interaction.OutputText != nil {
        fmt.Printf("Answer:\n%s\n", *res.Interaction.OutputText)
    }
}

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.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-2.5-pro চালু আছে কম, মাঝারি, বেশি
gemini-2.5-flash চালু আছে কম, মাঝারি, বেশি
gemini-2.5-flash-lite বন্ধ আছে কম, মাঝারি, বেশি
gemini-robotics-er-2-preview চালু আছে (হাই) ন্যূনতম, কম, মাঝারি, বেশি

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)

জাভাস্ক্রিপ্ট

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(
                "Provide a list of 3 famous physicists and their key contributions"))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.LOW).build())
        .build();

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

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

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-pro"),
            Input: interactions.NewInteractionsInput("What is the sum of the first 50 prime numbers?"),
            GenerationConfig: &interactions.GenerationConfig{
                ThinkingLevel:     interactions.ThinkingLevelHigh.ToPointer(),
                ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
            },
            Stream: genai.Ptr(true),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }
    stream := res.InteractionSSEStreamEvent
    defer stream.Close()

    for stream.Next() {
        event := stream.Value()
        if stepDelta := event.GetDataStepDelta(); stepDelta != nil {
            if thoughtDelta := stepDelta.GetDeltaThoughtSummary(); thoughtDelta != nil {
                if textContent := thoughtDelta.GetContentText(); textContent != nil {
                    fmt.Printf("[Thought Summary] %s\n", textContent.Text)
                }
            }
            if textDelta := stepDelta.GetDeltaText(); textDelta != nil {
                fmt.Print(textDelta.GetText())
            }
        }
    }
    if err := stream.Err(); err != nil {
        log.Fatal(err)
    }
}

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"
    }
  }'

টোকেন সীমা ও max_output_tokens

max_output_tokens জেনারেশন প্যারামিটার, কোনও উত্তর সর্বাধিক কতগুলি টোকেন জেনারেট করতে পারবে তা সেট করে, এর মধ্যে থট টোকেনও অন্তর্ভুক্ত।

সেট করা হলে, এই প্যারামিটারটি ইনফ্রাস্ট্রাকচার দ্বারা প্রয়োগ করা একটি হার্ড কাটঅফ হিসেবে কাজ করে মডেলটি কীভাবে তার থিঙ্কিং বাজেট বরাদ্দ করে তা পরিবর্তন না করেই (thinking_level)।

যুক্তি দেওয়ার সময় মডেল এই সীমায় পৌঁছে গেলে, এটি "incomplete" স্ট্যাটাস সহ জেনারেশন বন্ধ করে দেয় এবং ছোট করে দেওয়া বা খালি আউটপুট রিটার্ন করে (তবে এখনও তৈরি করা যেকোনও থিঙ্কিং টোকেনের জন্য বিল করা হয়)। উত্তর ছোট না করে খরচ বা লেটেন্সি কমাতে, ছোট max_output_tokens সেট করার পরিবর্তে thinking_level (low বা medium) কমান।

চিন্তা সংক্রান্ত স্বাক্ষর

থট সিগনেচার হল মডেলের ইন্টার্নাল যুক্তির এনক্রিপ্টেড উপস্থাপনা। একাধিকবার কথোপকথন চলাকালীন তাদের যুক্তি যেন একই থাকে, তা নিশ্চিত করতে হবে।

Interaction 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)

জাভাস্ক্রিপ্ট

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.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.Usage;
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."))
        .build();

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

if (interaction.usage().isPresent()) {
  Usage usage = interaction.usage().get();
  System.out.println("Thoughts tokens: " + usage.totalThoughtTokens().orElse(0));
  System.out.println("Output tokens: " + usage.totalOutputTokens().orElse(0));
}

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    // Turn 1: Execute a reasoning + tool use interaction
    turn1, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-pro"),
            Input: interactions.NewInteractionsInput("Compare the GDP growth of Japan and Germany in 2025."),
            Tools: []interactions.Tool{
                interactions.NewTool(interactions.GoogleSearch{}),
            },
            GenerationConfig: &interactions.GenerationConfig{
                ThinkingLevel: interactions.ThinkingLevelHigh.ToPointer(),
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    // Turn 2: Pass PreviousInteractionID so thought signatures are automatically preserved
    turn2, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model:                 interactions.Model("gemini-3.8-pro"),
            PreviousInteractionID: turn1.Interaction.ID,
            Input:                 interactions.NewInteractionsInput("Now summarize that comparison in a 3-row markdown table."),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    if turn2.Interaction.OutputText != nil {
        fmt.Println(*turn2.Interaction.OutputText)
    }
}

চূড়ান্ত উত্তরের কোয়ালিটি উন্নত করতে থিঙ্কিং মডেল সম্পূর্ণ চিন্তাভাবনা জেনারেট করে এবং তারপর চিন্তাভাবনা প্রক্রিয়া সম্পর্কে ইনসাইট প্রদান করতে সারসংক্ষেপ আউটপুট করে। API থেকে শুধুমাত্র সারসংক্ষেপ আউটপুট করা হলেও, মডেলকে যতগুলি সম্পূর্ণ থট টোকেন জেনারেট করতে হয় তার উপর ভিত্তি করে মূল্য নির্ধারণ করা হয়।

টোকেন গণনা গাইড থেকে টোকেন সম্পর্কে আরও জানতে পারবেন।

পেশাদার পদ্ধতি

এইসব নির্দেশিকা অনুসরণ করে চিন্তন মডেলকে দক্ষতার সাথে ব্যবহার করুন।

  • যুক্তি পর্যালোচনা করা: ব্যর্থতা বুঝতে ও প্রম্পট উন্নত করতে চিন্তাভাবনার সারসংক্ষেপ বিশ্লেষণ করুন।
  • চিন্তাভাবনার বাজেট নিয়ন্ত্রণ করা: টোকেন সেভ করার জন্য, মডেলকে দীর্ঘ আউটপুটের ক্ষেত্রে কম চিন্তা করতে প্রম্পট করুন।
  • সহজ টাস্ক: ফ্যাক্ট সংগ্রহ বা শ্রেণীবিন্যাসের জন্য ন্যূনতম বা কম চিন্তাভাবনা ব্যবহার করুন (যেমন, "DeepMind কোথায় প্রতিষ্ঠিত হয়েছিল?")।
  • মাঝারি টাস্ক: ধারণা তুলনা করা বা ক্রিয়েটিভ রিজনিংয়ের (যেমন, ইলেকট্রিক ও হাইব্রিড গাড়ির তুলনা করা) জন্য ডিফল্ট থিঙ্কিং ব্যবহার করো।
  • জটিল টাস্ক: উন্নত কোডিং, অঙ্ক বা একাধিক ধাপের প্ল্যানিংয়ের (যেমন, AIME অঙ্কের সমস্যার সমাধান করা) জন্য সর্বাধিক থিঙ্কিং ব্যবহার করুন।

এর পরে কী করতে হবে