Gemini 3 হল এখনও পর্যন্ত আমাদের সবচেয়ে বুদ্ধিদীপ্ত মডেল ফ্যামিলি, যা অত্যাধুনিক যুক্তি প্রয়োগের ভিত্তিতে তৈরি করা হয়েছে। এজেন্টিক ওয়ার্কফ্লো, অটোনোমাস কোডিং ও জটিল মাল্টিমোডাল টাস্ক মাস্টার করার মাধ্যমে যেকোনও আইডিয়াকে বাস্তবে রূপ দেওয়ার জন্য এটি ডিজাইন করা হয়েছে। এই নির্দেশিকায় Gemini 3 মডেল ফ্যামিলির মূল ফিচার এবং কীভাবে এর থেকে সর্বাধিক সুবিধা পাওয়া যায় সেই বিষয়ে বলা হয়েছে।
মডেলটি কীভাবে উন্নত রিজনিং, অটোনোমাস কোডিং এবং জটিল মাল্টিমোডাল টাস্ক ম্যানেজ করে তা দেখতে, আমাদের Gemini 3 অ্যাপের সংগ্রহ এক্সপ্লোর করুন।
কোডের কয়েকটি লাইন লিখে শুরু করুন:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.1-pro-preview",
input="Find the race condition in this multi-threaded C++ snippet: [code here]",
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
async function run() {
const interaction = await client.interactions.create({
model: "gemini-3.1-pro-preview",
input: "Find the race condition in this multi-threaded C++ snippet: [code here]",
});
console.log(interaction.output_text);
}
run();
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 request =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.1-pro-preview"))
.input(
InteractionsInput.of(
"Find the race condition in this multi-threaded C++ snippet: [code here]"))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(request)).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.1-pro-preview"),
Input: interactions.NewInteractionsInput("Find the race condition in this multi-threaded C++ snippet: [code here]"),
}),
})
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.1-pro-preview",
"input": "Find the race condition in this multi-threaded C++ snippet: [code here]"
}'
Gemini 3 সিরিজের সাথে পরিচিত হন
Gemini 3.1 Pro জটিল টাস্কের জন্য সবচেয়ে উপযুক্ত, যেগুলির জন্য বিভিন্ন মোডালিটি জুড়ে বিশ্ব সম্পর্কে ব্যাপক জ্ঞান ও উন্নত রিজনিং প্রয়োজন।
Gemini 3 Flash হল আমাদের লেটেস্ট ৩-সিরিজ মডেল, যা Flash-এর স্পিড ও মূল্যে Pro-লেভেলের ইন্টেলিজেন্স প্রদান করে।
Nano Banana Pro (Gemini 3 Pro Image নামেও পরিচিত) হল আমাদের সবচেয়ে ভালো কোয়ালিটির ইমেজ জেনারেশন মডেল এবং Nano Banana 2 (Gemini 3.1 Flash Image নামেও পরিচিত) হল তুলনামূলক কম খরচে বেশি ভলিউম, বেশি এফিসিয়েন্সি প্রদানকারী মডেল।
Gemini 3.1 Flash-Lite হল আমাদের ওয়ার্কহর্স মডেল যা কম খরচে মডেল তৈরি করা এবং হাই-ভলিউম টাস্কের জন্য তৈরি করা হয়েছে।
Gemini 3-এর সব মডেল বর্তমানে প্রিভিউতে আছে।
| মডেল আইডি | কন্টেক্সট উইন্ডো (ইন / আউট) | নলেজ কাটঅফ | দাম (ইনপুট / আউটপুট)* |
|---|---|---|---|
| gemini-3.1-flash-lite | 1M / 64k | জানুয়ারি ২০২৫ | $০.২৫ (টেক্সট, ছবি, ভিডিও), $০.৫০ (অডিও) / $১.৫০ |
| gemini-3.1-flash-image-preview | ১২৮ হাজার / ৩২ হাজার | জানুয়ারি ২০২৫ | $০.২৫ (টেক্সট ইনপুট) / $০.০৬৭ (ছবি আউটপুট)** |
| gemini-3.1-pro-preview | 1M / 64k | জানুয়ারি ২০২৫ | $২ / $১২ (<২০০ হাজার টোকেন) $৪ / $১৮ (>২০০ হাজার টোকেন) |
| gemini-3-flash-preview | 1M / 64k | জানুয়ারি ২০২৫ | $০.৫০ / $৩ |
| gemini-3-pro-image-preview | ৬৫ হাজার / ৩২ হাজার | জানুয়ারি ২০২৫ | $২ (টেক্সট ইনপুট) / $০.১৩৪ (ছবি আউটপুট)** |
* অন্য কিছু উল্লেখ না করা থাকলে, দাম ১ মিলিয়ন টোকেন পিছু। ** রেজোলিউশন অনুযায়ী ছবির দাম আলাদা হয়। আরও বিবরণের জন্য মূল্য পৃষ্ঠা দেখুন।
বিস্তারিত সীমা, দাম এবং অতিরিক্ত তথ্যের জন্য, মডেল পৃষ্ঠা দেখুন।
Gemini 3-তে নতুন API ফিচার
Gemini 3-তে নতুন প্যারামিটার যোগ করা হয়েছে যা লেটেন্সি, খরচ ও মাল্টিমোডাল ফিডেলিটির উপর ডেভেলপারদের আরও বেশি কন্ট্রোল দেওয়ার জন্য ডিজাইন করা হয়েছে।
চিন্তার লেভেল
Gemini 3 সিরিজের মডেলগুলি ডিফল্ট হিসেবে প্রম্পটের মাধ্যমে রিজনিংয়ের জন্য ডায়নামিক থিঙ্কিং ব্যবহার করে।
আপনি thinking_level প্যারামিটার ব্যবহার করতে পারেন, যা কোনও
উত্তর তৈরি করার আগে মডেলের ইন্টার্নাল রিজনিং প্রসেসের
সর্বাধিক গভীরতা নিয়ন্ত্রণ করে। Gemini 3 এই লেভেলগুলিকে কঠোর টোকেন গ্যারান্টি না দিয়ে,
চিন্তাভাবনার জন্য আপেক্ষিক ছাড় হিসেবে বিবেচনা করে।
thinking_level উল্লেখ করা না থাকলে, Gemini 3 ডিফল্ট হিসেবে high ব্যবহার করবে। কমপ্লেক্স রিজনিংয়ের প্রয়োজন না হলে, আরও
দ্রুত ও কম লেটেন্সি সহ উত্তর পেতে, আপনি মডেলের চিন্তাভাবনার লেভেলকে low-এ
সীমাবদ্ধ করতে পারেন।
| থিঙ্কিং লেভেল | Gemini 3.1 Pro | Gemini 3.1 Flash-Lite | Gemini 3 Flash | বিবরণ |
|---|---|---|---|---|
minimal |
কাজ করে না | কাজ করে (ডিফল্ট) | কাজ করে | বেশিরভাগ কোয়েরির জন্য "কোনও চিন্তাভাবনা নেই" সেটিংয়ের সাথে ম্যাচ করে। জটিল কোডিং টাস্কের ক্ষেত্রে মডেল খুব কম চিন্তা করতে পারে। চ্যাট বা হাই থ্রুপুট অ্যাপ্লিকেশনের জন্য লেটেন্সি কমায়। মনে রাখবেন, minimal থেকে এই নিশ্চয়তা পাওয়া যায় না যে থিঙ্কিং বন্ধ হয়ে গেছে। |
low |
কাজ করে | কাজ করে | কাজ করে | লেটেন্সি ও খরচ কমায়। সহজ নির্দেশাবলী অনুসরণ করা, চ্যাট করা বা হাই-থ্রুপুট অ্যাপ্লিকেশনের জন্য সবচেয়ে ভাল। |
medium |
কাজ করে | কাজ করে | কাজ করে | বেশিরভাগ টাস্কের জন্য ব্যালেন্সড থিঙ্কিং। |
high |
কাজ করে (ডিফল্ট, ডায়নামিক) | কাজ করে (ডায়নামিক) | কাজ করে (ডিফল্ট, ডায়নামিক) | রিজনিংয়ের গভীরতা সর্বাধিক করে। মডেলটি প্রথম (কোনও চিন্তাভাবনা না করে) আউটপুট টোকেন পেতে অনেক বেশি সময় নিতে পারে, তবে আউটপুটটি আরও যত্ন সহকারে যুক্তিযুক্ত হবে। |
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.1-pro-preview",
input="How does AI work?",
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.1-pro-preview",
input: "How does AI work?",
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 request =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.1-pro-preview"))
.input(InteractionsInput.of("How does AI work?"))
.generationConfig(
GenerationConfig.builder()
.thinkingLevel(ThinkingLevel.LOW)
.build())
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(request)).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.1-pro-preview"),
Input: interactions.NewInteractionsInput("How does AI work?"),
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.1-pro-preview",
"input": "How does AI work?",
"generation_config": {
"thinking_level": "low"
}
}'
তাপমাত্রা
সব Gemini 3 মডেলের ক্ষেত্রে, আমরা তাপমাত্রা প্যারামিটারকে
এর ডিফল্ট ভ্যালু 1.0-তে রাখার জন্য বিশেষভাবে সাজেস্ট করি।
আগের মডেলগুলিতে ক্রিয়েটিভিটি বনাম ডিটারমিনিজম কন্ট্রোল করার জন্য টেম্পারেচার টিউনিং করা হলে ভাল ফল পাওয়া যেত, তবে Gemini 3-এর রিজনিং ক্ষমতা ডিফল্ট সেটিংয়ের জন্য অপ্টিমাইজ করা হয়েছে। তাপমাত্রা পরিবর্তন করলে (১.০-এর নিচে সেট করলে) তা লুপিং বা পারফর্ম্যান্সের অবনতির মতো অপ্রত্যাশিত আচরণ করতে পারে। বিশেষ করে জটিল গাণিতিক বা যুক্তিভিত্তিক টাস্কের ক্ষেত্রে এটি হতে পারে।
চিন্তা সংক্রান্ত স্বাক্ষর
Gemini 3 মডেল, API কল জুড়ে যুক্তিপূর্ণ প্রসঙ্গ বজায় রাখতে থট সিগনেচার ব্যবহার করে। এইসব সিগনেচার হল মডেলের ইন্টার্নাল চিন্তাভাবনার এনক্রিপ্ট করা উপস্থাপনা।
- স্টেটফুল মোড (সাজেস্ট করা): স্টেটফুল মোডে (
previous_interaction_idপ্রদান করে) Interactions API ব্যবহার করার সময়, সার্ভার অটোমেটিক কথোপকথনের ইতিহাস ও থট সিগনেচার ম্যানেজ করে। - স্টেটলেস মোড: আপনি যদি ম্যানুয়ালি কথোপকথনের ইতিহাস ম্যানেজ করেন, তাহলে সত্যতা যাচাই করার জন্য পরবর্তী অনুরোধে আপনাকে অবশ্যই সিগনেচার সহ থট ব্লক অন্তর্ভুক্ত করতে হবে।
বিস্তারিত তথ্যের জন্য, Thought Signatures পৃষ্ঠা দেখুন।`
টুল সহ স্ট্রাকচার্ড আউটপুট
Gemini 3 মডেল আপনাকে বিল্ট-ইন টুলের সাথে স্ট্রাকচার্ড আউটপুট একত্রিত করতে দেয়, যার মধ্যে রয়েছে Google Search-এর মাধ্যমে গ্রাউন্ডিং, URL কন্টেক্সট, কোড এক্সিকিউশন এবং ফাংশন কলিং।
Python
from google import genai
from pydantic import BaseModel, Field
from typing import List
class MatchResult(BaseModel):
winner: str = Field(description="The name of the winner.")
final_match_score: str = Field(description="The final match score.")
scorers: List[str] = Field(description="The name of the scorer.")
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.1-pro-preview",
input="Search for all details for the latest Euro.",
tools=[
{"type": "google_search"},
{"type": "url_context"}
],
response_format={
"type": "text",
"mime_type": "application/json",
"schema": MatchResult.model_json_schema()
},
)
result = MatchResult.model_validate_json(interaction.output_text)
print(result)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as z from "zod";
const matchJsonSchema = {
type: "object",
properties: {
winner: { type: "string", description: "The name of the winner." },
final_match_score: { type: "string", description: "The final score." },
scorers: {
type: "array",
items: { type: "string" },
description: "The name of the scorer."
}
},
required: ["winner", "final_match_score", "scorers"]
};
const matchSchema = z.fromJSONSchema(matchJsonSchema);
const client = new GoogleGenAI({});
async function run() {
const interaction = await client.interactions.create({
model: "gemini-3.1-pro-preview",
input: "Search for all details for the latest Euro.",
tools: [
{ type: "google_search" },
{ type: "url_context" }
],
response_format: {
type: "text",
mime_type: "application/json",
schema: matchJsonSchema
},
});
const match = matchSchema.parse(JSON.parse(interaction.output_text));
console.log(match);
}
run();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
import com.google.genai.gaos.models.interactions.GoogleSearch;
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.ResponseFormat;
import com.google.genai.gaos.models.interactions.TextResponseFormat;
import com.google.genai.gaos.models.interactions.TextResponseFormatMimeType;
import com.google.genai.gaos.models.interactions.URLContext;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
Client client = new Client();
Map<String, Object> properties = new HashMap<>();
properties.put("winner", Map.of("type", "string", "description", "The name of the winner."));
properties.put(
"final_match_score", Map.of("type", "string", "description", "The final match score."));
properties.put(
"scorers",
Map.of(
"type", "array",
"items", Map.of("type", "string"),
"description", "The name of the scorer."));
Map<String, Object> schema = new HashMap<>();
schema.put("type", "object");
schema.put("properties", properties);
schema.put("required", Arrays.asList("winner", "final_match_score", "scorers"));
CreateModelInteraction request =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.1-pro-preview"))
.input(InteractionsInput.of("Search for all details for the latest Euro."))
.tools(Arrays.asList(GoogleSearch.builder().build(), URLContext.builder().build()))
.responseFormat(
CreateModelInteractionResponseFormat.of(
ResponseFormat.of(
TextResponseFormat.builder()
.mimeType(TextResponseFormatMimeType.APPLICATION_JSON)
.schema(schema)
.build())))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(request)).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)
}
schema := map[string]any{
"type": "object",
"properties": map[string]any{
"winner": map[string]any{
"type": "string",
"description": "The name of the winner.",
},
"final_match_score": map[string]any{
"type": "string",
"description": "The final match score.",
},
"scorers": map[string]any{
"type": "array",
"items": map[string]any{"type": "string"},
"description": "The name of the scorer.",
},
},
"required": []string{"winner", "final_match_score", "scorers"},
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.1-pro-preview"),
Input: interactions.NewInteractionsInput("Search for all details for the latest Euro."),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleSearch{}),
interactions.NewTool(interactions.URLContext{}),
},
ResponseFormat: genai.Ptr(interactions.NewCreateModelInteractionResponseFormat(
interactions.NewResponseFormat(interactions.TextResponseFormat{
MimeType: interactions.TextResponseFormatMimeType("application/json").ToPointer(),
Schema: schema,
}),
)),
}),
})
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.1-pro-preview",
"input": "Search for all details for the latest Euro.",
"tools": [
{"type": "google_search"},
{"type": "url_context"}
],
"response_format": {
"type": "text",
"mime_type": "application/json",
"schema": {
"type": "object",
"properties": {
"winner": {"type": "string", "description": "The name of the winner."},
"final_match_score": {"type": "string", "description": "The final score."},
"scorers": {
"type": "array",
"items": {"type": "string"},
"description": "The name of the scorer."
}
},
"required": ["winner", "final_match_score", "scorers"]
}
}
}'
ইমেজ জেনারেশন
Gemini 3.1 Flash Image ও Gemini 3 Pro Image আপনাকে টেক্সট প্রম্পট থেকে ছবি জেনারেট ও এডিট করতে দেয়। এটি কোনও প্রম্পটের মাধ্যমে "চিন্তা" করার জন্য যুক্তি ব্যবহার করে এবং Google Search গ্রাউন্ডিং ব্যবহার করার আগে—যেমন আবহাওয়ার পূর্বাভাস বা স্টক চার্ট—রিয়েল-টাইম ডেটা সংগ্রহ করতে পারে। এর পরে হাই-ফিডেলিটি ছবি তৈরি করে।
নতুন ও উন্নত ক্ষমতা:
- 4K ও টেক্সট রেন্ডারিং: 2K ও 4K রেজোলিউশন পর্যন্ত ঝকঝকে, পাঠযোগ্য টেক্সট ও ডায়াগ্রাম তৈরি করুন।
- গ্রাউন্ডেড জেনারেশন:
google_searchটুল ব্যবহার করে তথ্য যাচাই করুন এবং বাস্তব জগতের তথ্যের উপর ভিত্তি করে ছবি তৈরি করুন। Google-এর সাথে গ্রাউন্ডিং ছবি Gemini 3.1 Flash ছবির জন্য উপলভ্য সার্চ। - কথোপকথনের মাধ্যমে এডিটিং: পরিবর্তনের জন্য (যেমন, "ব্যাকগ্রাউন্ডে সূর্যাস্তের ছবি দাও") শুধু জিজ্ঞাসা করেই মাল্টি-টার্ন ইমেজ এডিটিং। এই ওয়ার্কফ্লো, টার্নগুলির মধ্যে ভিজ্যুয়াল প্রসঙ্গ বজায় রাখতে থট সিগনেচারের উপর নির্ভর করে।
অ্যাসপেক্ট রেশিও, এডিটিং ওয়ার্কফ্লো ও কনফিগারেশন বিকল্প সম্পর্কে সম্পূর্ণ বিবরণ পেতে, ছবি তৈরি করার নির্দেশিকা দেখুন।
Python
from google import genai
import base64
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-pro-image-preview",
input="Generate an infographic of the current weather in Tokyo.",
tools=[{"type": "google_search"}],
response_format={
"type": "image",
"aspect_ratio": "16:9",
"image_size": "4K"
}
)
from PIL import Image
import io
generated_image = interaction.output_image
if generated_image:
image_data = base64.b64decode(generated_image.data)
image = Image.open(io.BytesIO(image_data))
image.save('weather_tokyo.png')
image.show()
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as fs from "node:fs";
const client = new GoogleGenAI({});
async function run() {
const interaction = await client.interactions.create({
model: "gemini-3-pro-image-preview",
input: "Generate a visualization of the current weather in Tokyo.",
tools: [{ type: "google_search" }],
response_format: {
type: "image",
aspect_ratio: "16:9",
image_size: "4K"
}
});
const buffer = Buffer.from(interaction.output_image.data, 'base64');
fs.writeFileSync('weather_tokyo.png', buffer);
}
run();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
import com.google.genai.gaos.models.interactions.GoogleSearch;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageResponseFormat;
import com.google.genai.gaos.models.interactions.ImageResponseFormatAspectRatio;
import com.google.genai.gaos.models.interactions.ImageResponseFormatImageSize;
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.ResponseFormat;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.Optional;
Client client = new Client();
CreateModelInteraction request =
CreateModelInteraction.builder()
.model(Model.of("gemini-3-pro-image-preview"))
.input(InteractionsInput.of("Generate an infographic of the current weather in Tokyo."))
.tools(Arrays.asList(GoogleSearch.builder().build()))
.responseFormat(
CreateModelInteractionResponseFormat.of(
ResponseFormat.of(
ImageResponseFormat.builder()
.aspectRatio(ImageResponseFormatAspectRatio.ONE_HUNDRED_AND_SIXTY_NINE)
.imageSize(ImageResponseFormatImageSize.FOUR_K)
.build())))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(request)).interaction().get();
Optional<ImageContent> generatedImage = interaction.outputImage();
if (generatedImage.isPresent() && generatedImage.get().data().isPresent()) {
byte[] imageBytes = Base64.getDecoder().decode(generatedImage.get().data().get());
Files.write(Paths.get("weather_tokyo.png"), imageBytes);
}
খুলুন
package main
import (
"context"
"encoding/base64"
"log"
"os"
"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-pro-image-preview"),
Input: interactions.NewInteractionsInput("Generate an infographic of the current weather in Tokyo."),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleSearch{}),
},
ResponseFormat: genai.Ptr(interactions.NewCreateModelInteractionResponseFormat(
interactions.NewResponseFormat(interactions.ImageResponseFormat{
AspectRatio: interactions.ImageResponseFormatAspectRatioOneHundredAndSixtyNine.ToPointer(),
ImageSize: interactions.ImageResponseFormatImageSize("4K").ToPointer(),
}),
)),
}),
})
if err != nil {
log.Fatal(err)
}
if generatedImage := res.Interaction.GetOutputImage(); generatedImage != nil && generatedImage.Data != nil {
imageBytes, err := base64.StdEncoding.DecodeString(*generatedImage.Data)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("weather_tokyo.png", imageBytes, 0644); 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-pro-image-preview",
"input": "Generate a visualization of the current weather in Tokyo.",
"tools": [{"type": "google_search"}],
"response_format": {
"type": "image",
"aspect_ratio": "16:9",
"image_size": "4K"
}
}'
উত্তরের উদাহরণ

ছবির মাধ্যমে কোড এক্সিকিউশন
Gemini 3 Flash, ভিশনকে শুধু স্থির এক ঝলক হিসেবে না দেখে, একটি অ্যাক্টিভ তদন্ত হিসেবে বিবেচনা করতে পারে। কোড এক্সিকিউশন-এর সাথে যুক্তিকে একত্রিত করে, মডেল একটি প্ল্যান তৈরি করে, তারপর জুম ইন, ক্রপ, অ্যানোটেট বা অন্যভাবে ছবি ম্যানিপুলেট করার জন্য Python কোড লেখে এবং ধাপে ধাপে এক্সিকিউট করে যাতে তার উত্তরগুলি দৃশ্যত গ্রাউন্ড করা যায়।
ব্যবহারের ক্ষেত্র:
- জুম ও পরীক্ষা করা: কোনও বিবরণ খুব ছোট হলে (যেমন, দূর থেকে কোনও গেজ বা সিরিয়াল নম্বর পড়া) মডেলটি তা বুঝে নেয় এবং কোড লিখে সেটি ক্রপ করে নেয় এবং আরও উন্নত রেজোলিউশনে সেই জায়গাটি আবার পরীক্ষা করে দেখে।
- ভিজ্যুয়াল ম্যাথ ও প্লটিং: মডেলটি কোড ব্যবহার করে একাধিক ধাপের গণনা করতে পারে (যেমন, রসিদে আইটেম যোগ করা বা এক্সট্র্যাক্ট করা ডেটা থেকে Matplotlib চার্ট তৈরি করা)।
- ইমেজ অ্যানোটেশন: মডেলটি সরাসরি ছবিতে তীরচিহ্ন, বাউন্ডিং বক্স বা অন্যান্য অ্যানোটেশন আঁকতে পারে যাতে "এই আইটেমটি কোথায় রাখতে হবে?"-এর মতো স্থান সংক্রান্ত প্রশ্নের উত্তর দেওয়া যায়।
ভিজ্যুয়াল থিঙ্কিং চালু করতে, টুল হিসেবে কোড এক্সিকিউশন কনফিগার করুন। প্রয়োজন হলে, মডেলটি ছবি ম্যানিপুলেট করার জন্য অটোমেটিক কোড ব্যবহার করবে।
Python
from google import genai
from google.genai import types
import requests
from PIL import Image
import io
import base64
image_path = "https://goo.gle/instrument-img"
image_bytes = requests.get(image_path).content
image = types.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=[
image,
"Zoom into the expression pedals and tell me how many pedals are there?"
],
tools=[{"type": "code_execution"}],
)
from IPython.display import display
from PIL import Image
import io
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
elif content_block.type == "image":
display(Image.open(io.BytesIO(base64.b64decode(content_block.data))))
elif step.type == "code_execution_call":
print(step.code)
elif step.type == "code_execution_result":
print(step.output)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
async function main() {
const imageUrl = "https://goo.gle/instrument-img";
const response = await fetch(imageUrl);
const imageArrayBuffer = await response.arrayBuffer();
const base64ImageData = Buffer.from(imageArrayBuffer).toString("base64");
const interaction = await client.interactions.create({
model: "gemini-3-flash-preview",
input: [
{
type: "image",
mime_type: "image/jpeg",
data: base64ImageData,
},
{
type: "text",
text: "Zoom into the expression pedals and tell me how many pedals are there?",
},
],
tools: [{ type: "code_execution" }],
});
for (const step of interaction.steps) {
if (step.type === "model_output") {
for (const contentBlock of step.content) {
if (contentBlock.type === "text") {
console.log("Text:", contentBlock.text);
}
}
} else if (step.type === "code_execution_call") {
console.log("Code:", step.code);
} else if (step.type === "code_execution_result") {
console.log("Output:", step.output);
}
}
}
main();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CodeExecution;
import com.google.genai.gaos.models.interactions.CodeExecutionCallStep;
import com.google.genai.gaos.models.interactions.CodeExecutionResultStep;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
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.operations.CreateInteractionRequestBody;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
Client client = new Client();
URL url = new URL("https://goo.gle/instrument-img");
byte[] imageBytes;
try (InputStream is = url.openStream()) {
imageBytes = is.readAllBytes();
}
String base64ImageData = Base64.getEncoder().encodeToString(imageBytes);
CreateModelInteraction request =
CreateModelInteraction.builder()
.model(Model.of("gemini-3-flash-preview"))
.input(
InteractionsInput.ofContent(
Arrays.asList(
ImageContent.builder()
.mimeType(ImageContentMimeType.IMAGE_JPEG)
.data(base64ImageData)
.build(),
TextContent.builder()
.text("Zoom into the expression pedals and tell me how many pedals are there?")
.build())))
.tools(Arrays.asList(CodeExecution.builder().build()))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(request)).interaction().get();
for (Step step : interaction.steps().orElse(Collections.emptyList())) {
if (step instanceof ModelOutputStep) {
ModelOutputStep modelOutput = (ModelOutputStep) step;
for (Content contentBlock : modelOutput.content().orElse(Collections.emptyList())) {
if (contentBlock instanceof TextContent) {
System.out.println("Text: " + ((TextContent) contentBlock).text().orElse(""));
}
}
} else if (step instanceof CodeExecutionCallStep) {
CodeExecutionCallStep callStep = (CodeExecutionCallStep) step;
callStep.arguments().flatMap(args -> args.code()).ifPresent(code -> System.out.println("Code: " + code));
} else if (step instanceof CodeExecutionResultStep) {
CodeExecutionResultStep resultStep = (CodeExecutionResultStep) step;
System.out.println("Output: " + resultStep.result().orElse(""));
}
}
খুলুন
package main
import (
"context"
"encoding/base64"
"fmt"
"io"
"log"
"net/http"
"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)
}
httpRes, err := http.Get("https://goo.gle/instrument-img")
if err != nil {
log.Fatal(err)
}
defer httpRes.Body.Close()
imageBytes, err := io.ReadAll(httpRes.Body)
if err != nil {
log.Fatal(err)
}
base64ImageData := base64.StdEncoding.EncodeToString(imageBytes)
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3-flash-preview"),
Input: interactions.NewInteractionsInput([]interactions.Content{
interactions.NewContent(interactions.ImageContent{
MimeType: interactions.ImageContentMimeType("image/jpeg").ToPointer(),
Data: genai.Ptr(base64ImageData),
}),
interactions.NewContent(interactions.TextContent{
Text: "Zoom into the expression pedals and tell me how many pedals are there?",
}),
}),
Tools: []interactions.Tool{
interactions.NewTool(interactions.CodeExecution{}),
},
}),
})
if err != nil {
log.Fatal(err)
}
for _, step := range res.Interaction.Steps {
if modelOutput := step.ModelOutputStep; modelOutput != nil {
for _, contentBlock := range modelOutput.Content {
if textContent := contentBlock.TextContent; textContent != nil {
fmt.Println("Text:", textContent.Text)
}
}
} else if callStep := step.CodeExecutionCallStep; callStep != nil {
if callStep.Arguments.Code != nil {
fmt.Println("Code:", *callStep.Arguments.Code)
}
} else if resultStep := step.CodeExecutionResultStep; resultStep != nil {
fmt.Println("Output:", resultStep.Result)
}
}
}
REST
IMG_URL="https://goo.gle/instrument-img"
MODEL="gemini-3-flash-preview"
MIME_TYPE=$(curl -sIL "$IMG_URL" | grep -i '^content-type:' | awk -F ': ' '{print $2}' | sed 's/\r$//' | head -n 1)
if [[ -z "$MIME_TYPE" || ! "$MIME_TYPE" == image/* ]]; then
MIME_TYPE="image/jpeg"
fi
if [[ "$(uname)" == "Darwin" ]]; then
IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -b 0)
elif [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
IMAGE_B64=$(curl -sL "$IMG_URL" | base64)
else
IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -w0)
fi
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "'$MODEL'",
"input": [
{
"type": "image",
"mime_type":"'"$MIME_TYPE"'",
"data": "'"$IMAGE_B64"'"
},
{"type": "text", "text": "Zoom into the expression pedals and tell me how many pedals are there?"}
],
"tools": [{"type": "code_execution"}]
}'
ছবির সাথে কোড এক্সিকিউশন সম্পর্কে আরও বিবরণের জন্য, কোড এক্সিকিউশন দেখুন।
মাল্টিমোডাল ফাংশন রেসপন্স
মাল্টিমোডাল ফাংশন কলিং ব্যবহারকারীদের এমন ফাংশন রেসপন্স পেতে দেয় যাতে মাল্টিমোডাল অবজেক্ট থাকে। এর ফলে মডেলের ফাংশন কলিং ক্ষমতার আরও ভালো ব্যবহার করা যায়। স্ট্যান্ডার্ড ফাংশন কলিং শুধুমাত্র টেক্সট-ভিত্তিক ফাংশন উত্তরকে সাপোর্ট করে:
Python
# This will only work for SDK newer than 2.0.0
from google import genai
import requests
import base64
client = genai.Client()
# 1. Define the tool
get_image_tool = {
"type": "function",
"name": "get_image",
"description": "Retrieves the image file reference for a specific order item.",
"parameters": {
"type": "object",
"properties": {
"item_name": {
"type": "string",
"description": "The name or description of the item ordered (e.g., 'instrument')."
}
},
"required": ["item_name"],
},
}
# 2. Send the request with tools
interaction_1 = client.interactions.create(
model="gemini-3-flash-preview",
input="Show me the instrument I ordered last month.",
tools=[get_image_tool],
)
# 3. Find the function call step
fc_step = next(s for s in interaction_1.steps if s.type == "function_call")
print(f"Tool Call: {fc_step.name}({fc_step.arguments})")
# Execute tool (fetch image)
image_path = "https://goo.gle/instrument-img"
image_bytes = requests.get(image_path).content
image_b64 = base64.b64encode(image_bytes).decode("utf-8")
# 4. Send multimodal function result back
interaction_2 = client.interactions.create(
model="gemini-3-flash-preview",
previous_interaction_id=interaction_1.id,
input=[{
"type": "function_result",
"name": fc_step.name,
"call_id": fc_step.id,
"result": [
{"type": "text", "text": "instrument.jpg"},
{
"type": "image",
"mime_type": "image/jpeg",
"data": image_b64,
}
]
}],
tools=[get_image_tool]
)
print(f"\nFinal model response: {interaction_2.output_text}")
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const getImageTool = {
type: 'function',
name: 'get_image',
description: 'Retrieves the image file reference for a specific order item.',
parameters: {
type: 'object',
properties: {
item_name: {
type: 'string',
description: "The name or description of the item ordered (e.g., 'instrument').",
},
},
required: ['item_name'],
},
};
const interaction1 = await client.interactions.create({
model: 'gemini-3-flash-preview',
input: 'Use the get_image tool to show me the instrument I ordered last month.',
tools: [getImageTool],
});
const fcStep = interaction1.steps.find(s => s.type === 'function_call');
console.log(`Tool Call: ${fcStep.name}(${JSON.stringify(fcStep.arguments)})`);
const imageUrl = 'https://goo.gle/instrument-img';
const response = await fetch(imageUrl);
const imageArrayBuffer = await response.arrayBuffer();
const base64ImageData = Buffer.from(imageArrayBuffer).toString('base64');
const interaction2 = await client.interactions.create({
model: 'gemini-3-flash-preview',
previous_interaction_id: interaction1.id,
input: [{
type: 'function_result',
name: fcStep.name,
call_id: fcStep.id,
result: [
{ type: 'text', text: 'instrument.jpg' },
{
type: 'image',
mime_type: 'image/jpeg',
data: base64ImageData,
}
]
}],
tools: [getImageTool]
});
console.log(`\nFinal model response: ${interaction2.output_text}`);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.FunctionCallStep;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
import com.google.genai.gaos.models.interactions.FunctionResultSubcontent;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
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.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Client client = new Client();
Map<String, Object> itemProp = new HashMap<>();
itemProp.put("type", "string");
itemProp.put("description", "The name or description of the item ordered (e.g., 'instrument').");
Map<String, Object> properties = new HashMap<>();
properties.put("item_name", itemProp);
Map<String, Object> parameters = new HashMap<>();
parameters.put("type", "object");
parameters.put("properties", properties);
parameters.put("required", Arrays.asList("item_name"));
Function getImageTool =
Function.builder()
.name("get_image")
.description("Retrieves the image file reference for a specific order item.")
.parameters(parameters)
.build();
CreateModelInteraction req1 =
CreateModelInteraction.builder()
.model(Model.of("gemini-3-flash-preview"))
.input(
InteractionsInput.of(
"Use the get_image tool to show me the instrument I ordered last month."))
.tools(Arrays.asList(getImageTool))
.build();
Interaction interaction1 =
client.interactions.create(CreateInteractionRequestBody.of(req1)).interaction().get();
FunctionCallStep fcStep = null;
for (Step step : interaction1.steps().orElse(Collections.emptyList())) {
if (step instanceof FunctionCallStep) {
fcStep = (FunctionCallStep) step;
break;
}
}
if (fcStep != null) {
System.out.println("Tool Call: " + fcStep.name().orElse(""));
URL url = new URL("https://goo.gle/instrument-img");
byte[] imageBytes;
try (InputStream is = url.openStream()) {
imageBytes = is.readAllBytes();
}
String base64ImageData = Base64.getEncoder().encodeToString(imageBytes);
List<FunctionResultSubcontent> subcontents = new ArrayList<>();
subcontents.add(TextContent.builder().text("instrument.jpg").build());
subcontents.add(
ImageContent.builder()
.mimeType(ImageContentMimeType.IMAGE_JPEG)
.data(base64ImageData)
.build());
FunctionResultStep funcResult =
FunctionResultStep.builder()
.name(fcStep.name().orElse(""))
.callId(fcStep.id().orElse(""))
.result(FunctionResultStepResultUnion.of(subcontents))
.build();
CreateModelInteraction req2 =
CreateModelInteraction.builder()
.model(Model.of("gemini-3-flash-preview"))
.input(InteractionsInput.ofStep(Arrays.asList(funcResult)))
.tools(Arrays.asList(getImageTool))
.previousInteractionId(interaction1.id().orElse(""))
.build();
Interaction interaction2 =
client.interactions.create(CreateInteractionRequestBody.of(req2)).interaction().get();
System.out.println("Final model response: " + interaction2.outputText().orElse(""));
}
খুলুন
package main
import (
"context"
"encoding/base64"
"fmt"
"io"
"log"
"net/http"
"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)
}
getImageTool := interactions.NewTool(interactions.Function{
Name: genai.Ptr("get_image"),
Description: genai.Ptr("Retrieves the image file reference for a specific order item."),
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{
"item_name": map[string]any{
"type": "string",
"description": "The name or description of the item ordered (e.g., 'instrument').",
},
},
"required": []string{"item_name"},
},
})
res1, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3-flash-preview"),
Input: interactions.NewInteractionsInput("Use the get_image tool to show me the instrument I ordered last month."),
Tools: []interactions.Tool{getImageTool},
}),
})
if err != nil {
log.Fatal(err)
}
for _, step := range res1.Interaction.Steps {
if fcStep := step.FunctionCallStep; fcStep != nil {
fmt.Println("Tool Call:", fcStep.Name)
httpRes, err := http.Get("https://goo.gle/instrument-img")
if err != nil {
log.Fatal(err)
}
defer httpRes.Body.Close()
imageBytes, err := io.ReadAll(httpRes.Body)
if err != nil {
log.Fatal(err)
}
base64ImageData := base64.StdEncoding.EncodeToString(imageBytes)
funcResult := interactions.NewStep(interactions.FunctionResultStep{
Name: genai.Ptr(fcStep.Name),
CallID: fcStep.ID,
Result: interactions.NewFunctionResultStepResultUnion([]interactions.FunctionResultSubcontent{
interactions.NewFunctionResultSubcontent(interactions.TextContent{
Text: "instrument.jpg",
}),
interactions.NewFunctionResultSubcontent(interactions.ImageContent{
MimeType: interactions.ImageContentMimeType("image/jpeg").ToPointer(),
Data: genai.Ptr(base64ImageData),
}),
}),
})
res2, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3-flash-preview"),
PreviousInteractionID: res1.Interaction.ID,
Tools: []interactions.Tool{getImageTool},
Input: interactions.NewInteractionsInput([]interactions.Step{funcResult}),
}),
})
if err != nil {
log.Fatal(err)
}
if res2.Interaction.OutputText != nil {
fmt.Println("Final model response:", *res2.Interaction.OutputText)
}
break
}
}
}
REST
IMG_URL="https://goo.gle/instrument-img"
MIME_TYPE=$(curl -sIL "$IMG_URL" | grep -i '^content-type:' | awk -F ': ' '{print $2}' | sed 's/\r$//' | head -n 1)
if [[ -z "$MIME_TYPE" || ! "$MIME_TYPE" == image/* ]]; then
MIME_TYPE="image/jpeg"
fi
# Check for macOS
if [[ "$(uname)" == "Darwin" ]]; then
IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -b 0)
elif [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
IMAGE_B64=$(curl -sL "$IMG_URL" | base64)
else
IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -w0)
fi
# 1. First interaction (triggers function call)
# 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-flash-preview", "input": "Show me the instrument I ordered last month.", "tools": [...] }'
# 2. Send multimodal function result back (Replace INTERACTION_ID and CALL_ID)
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-flash-preview",
"previous_interaction_id": "INTERACTION_ID",
"input": [{
"type": "function_result",
"name": "get_image",
"call_id": "CALL_ID",
"result": [
{ "type": "text", "text": "instrument.jpg" },
{
"type": "image",
"mime_type": "'"$MIME_TYPE"'",
"data": "'"$IMAGE_B64"'"
}
]
}]
}'
বিল্ট-ইন টুল ও ফাংশন কলিংয়ের সুবিধা একত্রিত করা
Gemini 3 একই API কলে বিল্ট-ইন টুল (যেমন, Google Search, URL কনটেক্সট ও আরও) এবং কাস্টম ফাংশন কলিং টুল ব্যবহার করার অনুমতি দেয়, যা আরও জটিল ওয়ার্কফ্লোয়ের জন্য সহায়ক।
Python
from google import genai
from google.genai import types
client = genai.Client()
getWeather = {
"type": "function",
"name": "getWeather",
"description": "Gets the weather for a requested city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city and state, e.g. Utqiaġvik, Alaska",
},
},
"required": ["city"],
},
}
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input="What is the northernmost city in the United States? What's the weather like there today?",
tools=[
{"type": "google_search"},
getWeather
],
)
fc_step = next((s for s in interaction.steps if s.type == "function_call"), None)
if fc_step:
result = {"response": "Very cold. 22 degrees Fahrenheit."}
final_interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=[
{"type": "function_result", "name": fc_step.name, "call_id": fc_step.id, "result": result}
],
tools=[
{"type": "google_search"},
getWeather
],
previous_interaction_id=interaction.id,
)
print(final_interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI, Type } from '@google/genai';
const client = new GoogleGenAI({});
const getWeatherDeclaration = {
type: 'function',
name: 'getWeather',
description: 'Gets the weather for a requested city.',
parameters: {
type: Type.OBJECT,
properties: {
city: {
type: Type.STRING,
description: 'The city and state, e.g. Utqiaġvik, Alaska',
},
},
required: ['city'],
},
};
const interaction = await client.interactions.create({
model: 'gemini-3-flash-preview',
input: "What is the northernmost city in the United States? What's the weather like there today?",
tools: [
{ type: "google_search" },
getWeatherDeclaration
],
});
const fcStep = interaction.steps.find(s => s.type === 'function_call');
if (fcStep) {
const result = { response: "Very cold. 22 degrees Fahrenheit." };
const finalInteraction = await client.interactions.create({
model: 'gemini-3-flash-preview',
input: [
{ type: 'function_result', name: fcStep.name, call_id: fcStep.id, result: result }
],
tools: [
{ type: "google_search" },
getWeatherDeclaration
],
previous_interaction_id: interaction.id,
});
console.log(finalInteraction.output_text);
}
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.FunctionCallStep;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
import com.google.genai.gaos.models.interactions.GoogleSearch;
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.Step;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Client client = new Client();
Map<String, Object> cityProp = new HashMap<>();
cityProp.put("type", "string");
cityProp.put("description", "The city and state, e.g. Utqiaġvik, Alaska");
Map<String, Object> properties = new HashMap<>();
properties.put("city", cityProp);
Map<String, Object> parameters = new HashMap<>();
parameters.put("type", "object");
parameters.put("properties", properties);
parameters.put("required", Arrays.asList("city"));
Function getWeather =
Function.builder()
.name("getWeather")
.description("Gets the weather for a requested city.")
.parameters(parameters)
.build();
CreateModelInteraction request =
CreateModelInteraction.builder()
.model(Model.of("gemini-3-flash-preview"))
.input(
InteractionsInput.of(
"What is the northernmost city in the United States? What's the weather like there today?"))
.tools(Arrays.asList(GoogleSearch.builder().build(), getWeather))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(request)).interaction().get();
FunctionCallStep fcStep = null;
for (Step step : interaction.steps().orElse(Collections.emptyList())) {
if (step instanceof FunctionCallStep) {
fcStep = (FunctionCallStep) step;
break;
}
}
if (fcStep != null) {
FunctionResultStep funcResult =
FunctionResultStep.builder()
.name(fcStep.name().orElse(""))
.callId(fcStep.id().orElse(""))
.result(
FunctionResultStepResultUnion.of(
"{\"response\": \"Very cold. 22 degrees Fahrenheit.\"}"))
.build();
CreateModelInteraction finalRequest =
CreateModelInteraction.builder()
.model(Model.of("gemini-3-flash-preview"))
.input(InteractionsInput.ofStep(Arrays.asList(funcResult)))
.tools(Arrays.asList(GoogleSearch.builder().build(), getWeather))
.previousInteractionId(interaction.id().orElse(""))
.build();
Interaction finalInteraction =
client.interactions.create(CreateInteractionRequestBody.of(finalRequest)).interaction().get();
System.out.println(finalInteraction.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)
}
getWeather := interactions.NewTool(interactions.Function{
Name: genai.Ptr("getWeather"),
Description: genai.Ptr("Gets the weather for a requested city."),
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{
"city": map[string]any{
"type": "string",
"description": "The city and state, e.g. Utqiaġvik, Alaska",
},
},
"required": []string{"city"},
},
})
tools := []interactions.Tool{
interactions.NewTool(interactions.GoogleSearch{}),
getWeather,
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3-flash-preview"),
Input: interactions.NewInteractionsInput("What is the northernmost city in the United States? What's the weather like there today?"),
Tools: tools,
}),
})
if err != nil {
log.Fatal(err)
}
for _, step := range res.Interaction.Steps {
if fcStep := step.FunctionCallStep; fcStep != nil {
funcResult := interactions.NewStep(interactions.FunctionResultStep{
Name: genai.Ptr(fcStep.Name),
CallID: fcStep.ID,
Result: interactions.NewFunctionResultStepResultUnion(`{"response": "Very cold. 22 degrees Fahrenheit."}`),
})
finalRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3-flash-preview"),
PreviousInteractionID: res.Interaction.ID,
Tools: tools,
Input: interactions.NewInteractionsInput([]interactions.Step{funcResult}),
}),
})
if err != nil {
log.Fatal(err)
}
if finalRes.Interaction.OutputText != nil {
fmt.Println(*finalRes.Interaction.OutputText)
}
break
}
}
}
Gemini 2.5 থেকে মাইগ্রেশন
Gemini 3 হল এখনও পর্যন্ত আমাদের সবচেয়ে সক্ষম মডেল ফ্যামিলি এবং এটি Gemini 2.5-এর তুলনায় ধাপে ধাপে উন্নত। মাইগ্রেশন করার সময়, নিম্নলিখিত বিষয়গুলি বিবেচনা করুন:
- থিঙ্কিং: আপনি যদি আগে Gemini 2.5-কে রিজনিং করতে বাধ্য করার জন্য জটিল প্রম্পট ইঞ্জিনিয়ারিং (যেমন
চেন অফ থট) ব্যবহার করে থাকেন, তাহলে
thinking_level: "high"ও সরলীকৃত প্রম্পট সহ Gemini 3 ব্যবহার করে দেখুন। - টেম্পারেচার সেটিংস: আপনার আগে থেকে থাকা কোড যদি স্পষ্টভাবে টেম্পারেচার সেট করে থাকে (বিশেষত ডিটারমিনিস্টিক আউটপুটের জন্য কম ভ্যালু), তাহলে আমরা এই প্যারামিটার সরিয়ে দেওয়ার এবং সম্ভাব্য লুপ সংক্রান্ত সমস্যা বা জটিল টাস্কে পারফর্ম্যান্স খারাপ হওয়া এড়াতে Gemini 3-এর ডিফল্ট ভ্যালু ১.০ ব্যবহার করার সাজেশন দিই।
- পিডিএফ ও ডকুমেন্ট বোঝা:
আপনি যদি ঘন ডকুমেন্ট পার্সিংয়ের জন্য নির্দিষ্ট আচরণের উপর নির্ভর করে থাকেন, তাহলে
media_resolution_highনতুন সেটিং পরীক্ষা করে দেখুন যাতে সঠিক ফলাফল পাওয়া চালিয়ে যাওয়া যায়। - টোকেন ব্যবহার: Gemini 3 ডিফল্টে মাইগ্রেট করলে, PDF-এর জন্য টোকেন ব্যবহার বেড়ে যেতে পারে, তবে ভিডিওর জন্য টোকেন ব্যবহার কমে যেতে পারে। ডিফল্ট রেজোলিউশন বেশি হওয়ার কারণে এখন অনুরোধ যদি কন্টেক্সট উইন্ডোর সীমা অতিক্রম করে যায়, তাহলে আমরা স্পষ্টভাবে মিডিয়ার রেজোলিউশন কমানোর সাজেশন দিই।
- ইমেজ সেগমেন্টেশন: ইমেজ সেগমেন্টেশন সংক্রান্ত ক্ষমতা (অবজেক্টের জন্য পিক্সেল-লেভেল মাস্ক রিটার্ন করা) Gemini 3 Pro বা Gemini 3 Flash-এ কাজ করে না। বিল্ট-ইন ইমেজ সেগমেন্টেশন প্রয়োজনীয় ওয়ার্কলোডের জন্য, আমরা থিংকিং বন্ধ করে Gemini 2.5 Flash ব্যবহার চালিয়ে যাওয়ার সাজেশন দিই।
- কম্পিউটার ব্যবহার: Gemini 3 Pro ও Gemini 3 Flash কম্পিউটার ব্যবহার সমর্থন করে। 2.5 সিরিজের মতো, কম্পিউটার ব্যবহার টুল অ্যাক্সেস করার জন্য আপনাকে আলাদা মডেল ব্যবহার করতে হবে না।
- টুল সাপোর্ট: Gemini 3 মডেলের জন্য এখন ফাংশন কলিংয়ের সাথে বিল্ট-ইন টুল একত্রিত করা যায়। এছাড়াও, Gemini 3 মডেলের জন্য এখন Maps গ্রাউন্ডিং কাজ করে।
OpenAI-এর সাথে মানানসই
OpenAI কম্প্যাটিবিলিটি লেয়ার ব্যবহারকারী গ্রাহকদের জন্য,
স্ট্যান্ডার্ড প্যারামিটার (OpenAI-এর reasoning_effort) অটোমেটিক
Gemini (thinking_level) সমতুল্য প্যারামিটারের সাথে ম্যাপ করা হয়।
প্রম্পট সংক্রান্ত পেশাদার পদ্ধতি
Gemini 3 হল একটি রিজনিং মডেল, যা আপনাকে প্রম্পট করার পদ্ধতি পরিবর্তন করে।
- সুনির্দিষ্ট নির্দেশাবলী: আপনার ইনপুট প্রম্পটে সংক্ষিপ্তভাবে লিখুন। Gemini 3 সরাসরি, স্পষ্ট নির্দেশাবলী অনুযায়ী সবচেয়ে ভাল উত্তর দেয়। এটি পুরনো মডেলের জন্য ব্যবহৃত অত্যধিক জটিল প্রম্পট ইঞ্জিনিয়ারিং টেকনিকের অত্যধিক বিশ্লেষণ করতে পারে।
- আউটপুটের বাচালতা: ডিফল্ট হিসেবে, Gemini 3 কম বাচাল এবং সরাসরি, কার্যকর উত্তর প্রদান করতে পছন্দ করে। আপনার ব্যবহারের ক্ষেত্রে যদি আরও বেশি কথোপকথনমূলক বা "চ্যাট-নির্ভর" পার্সোনার প্রয়োজন হয়, তাহলে আপনাকে অবশ্যই প্রম্পটে মডেলটিকে স্পষ্টভাবে নির্দেশ দিতে হবে (যেমন, "এটি একজন বন্ধুত্বপূর্ণ, বাচাল অ্যাসিস্ট্যান্ট হিসেবে ব্যাখ্যা করো")।
- প্রসঙ্গ ম্যানেজমেন্ট: বড় ডেটাসেট (যেমন, সম্পূর্ণ বই, কোডবেস বা দীর্ঘ ভিডিও) নিয়ে কাজ করার সময়, ডেটা প্রসঙ্গ শেষ হওয়ার পরে, প্রম্পটের শেষে আপনার নির্দিষ্ট নির্দেশাবলী বা প্রশ্ন লিখুন। মডেলের যুক্তিকে প্রদত্ত ডেটার সাথে অ্যাঙ্কর করুন। এর জন্য, আপনার প্রশ্নটি এমন একটি বাক্যাংশ দিয়ে শুরু করুন, যেমন, "আগের তথ্য অনুযায়ী..."।
প্রম্পট ইঞ্জিনিয়ারিং গাইড থেকে প্রম্পট ডিজাইন স্ট্র্যাটেজি সম্পর্কে আরও জানুন।
প্রায়শই জিজ্ঞাসিত প্রশ্ন
Gemini 3-এর নলেজ কাট-অফ কী? Gemini 3 মডেলে জানুয়ারি ২০২৫ পর্যন্ত তথ্য আছে। আরও সাম্প্রতিক তথ্যের জন্য, সার্চ গ্রাউন্ডিং টুল ব্যবহার করুন।
কন্টেক্সট উইন্ডোর সীমা কত? Gemini 3 মডেল ১ মিলিয়ন টোকেন ইনপুট কন্টেক্সট উইন্ডো এবং সর্বাধিক ৬৪ হাজার টোকেন আউটপুট সাপোর্ট করে।
Gemini 3-এর কি কোনও ফ্রি টিয়ার আছে? Gemini 3 Flash
gemini-3-flash-preview-এর Gemini API-তে ফ্রি টিয়ার আছে। আপনি Google AI Studio-তে Gemini 3.1 Pro ও 3 Flash ফ্রিতে ব্যবহার করে দেখতে পারেন, তবে Gemini API-তেgemini-3.1-pro-preview-এর জন্য কোনও ফ্রি টিয়ার উপলভ্য নেই।আমার পুরনো
thinking_budgetকোড কি এখনও কাজ করবে? হ্যাঁ,thinking_budgetএখনও পুরনো ভার্সনের সাথে মানানসই হিসেবে কাজ করে, তবে আরও অনুমানযোগ্য পারফর্ম্যান্সের জন্যthinking_level-এ মাইগ্রেট করার সাজেশন দিই। একই অনুরোধে দুটিই ব্যবহার করবেন না।Gemini 3 কি ব্যাচ API-কে সাপোর্ট করে? হ্যাঁ, Gemini 3-তে Batch API কাজ করে।
কন্টেক্সট ক্যাশিং কি কাজ করে? হ্যাঁ, Gemini 3-এর জন্য কন্টেক্সট ক্যাশিং কাজ করে।
Gemini 3-তে কোন কোন টুল কাজ করে? Gemini 3-এ Google Search, Google Maps-এর মাধ্যমে গ্রাউন্ডিং, ফাইল সার্চ, কোড এক্সিকিউশন এবং URL কনটেক্সট কাজ করে। এছাড়াও, এটি আপনার নিজস্ব কাস্টম টুলের জন্য স্ট্যান্ডার্ড ফাংশন কলিং এবং বিল্ট-ইন টুলের সাথে কম্বিনেশন সাপোর্ট করে।
gemini-3.1-pro-preview-customtoolsকী? আপনি যদিgemini-3.1-pro-previewব্যবহার করেন এবং মডেলটি bash কমান্ডের পরিবর্তে আপনার কাস্টম টুল উপেক্ষা করে, তাহলেgemini-3.1-pro-preview-customtoolsমডেলটি ব্যবহার করে দেখুন। আরও তথ্য [এখানে][customtools-model] দেখুন।