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)
JavaScript
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, 3-सीरीज़ का हमारा नया मॉडल है. इसमें Pro-लेवल की इंटेलिजेंस की सुविधा मिलती है. साथ ही, यह Flash की स्पीड और कीमत में उपलब्ध है.
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 | 10 लाख / 64 हज़ार | जनवरी 2025 | 0.25 डॉलर (टेक्स्ट, इमेज, वीडियो), 0.50 डॉलर (ऑडियो) / 1.50 डॉलर |
| gemini-3.1-flash-image-preview | 128 हज़ार / 32 हज़ार | जनवरी 2025 | 0.25 डॉलर (टेक्स्ट इनपुट) / 0.067 डॉलर (इमेज आउटपुट)** |
| gemini-3.1-pro-preview | 10 लाख / 64 हज़ार | जनवरी 2025 | 2 डॉलर / 12 डॉलर (2 लाख से कम टोकन) 4 डॉलर / 18 डॉलर (2 लाख से ज़्यादा टोकन) |
| gemini-3-flash-preview | 10 लाख / 64 हज़ार | जनवरी 2025 | 0.50 डॉलर / 3 डॉलर |
| gemini-3-pro-image-preview | 65 हज़ार / 32 हज़ार | जनवरी 2025 | $2 (टेक्स्ट इनपुट) / $0.134 (इमेज आउटपुट)** |
* जब तक कोई सूचना न दी जाए, तब तक कीमत 10 लाख टोकन के हिसाब से ली जाती है. ** इमेज की कीमत, रिज़ॉल्यूशन के हिसाब से अलग-अलग होती है. ज़्यादा जानकारी के लिए, शुल्क वाला पेज देखें.
सीमाओं, कीमत, और अन्य जानकारी के बारे में ज़्यादा जानने के लिए, मॉडल पेज देखें.
Gemini 3 में नई एपीआई सुविधाएं
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)
JavaScript
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 की तर्क करने की क्षमताओं को डिफ़ॉल्ट सेटिंग के लिए ऑप्टिमाइज़ किया गया है. टेंपरेचर को बदलने (इसे 1.0 से कम पर सेट करने) से, मॉडल का व्यवहार अप्रत्याशित हो सकता है. जैसे, लूपिंग या परफ़ॉर्मेंस में गिरावट. ऐसा खास तौर पर, गणित या तर्क से जुड़े मुश्किल कामों में होता है.
सोच के आधार पर हस्ताक्षर
Gemini 3 मॉडल, थॉट सिग्नेचर का इस्तेमाल करते हैं. इससे एपीआई कॉल के दौरान, तर्क देने के कॉन्टेक्स्ट को बनाए रखने में मदद मिलती है. ये सिग्नेचर, मॉडल की इंटरनल थॉट प्रोसेस के एन्क्रिप्ट किए गए वर्शन होते हैं.
- स्टेटफ़ुल मोड (सुझाया गया): स्टेटफ़ुल मोड (
previous_interaction_idउपलब्ध कराना) में Interactions API का इस्तेमाल करने पर, सर्वर बातचीत के इतिहास और थॉट सिग्नेचर को अपने-आप मैनेज करता है. - स्टेटलेस मोड: अगर बातचीत के इतिहास को मैन्युअल तरीके से मैनेज किया जा रहा है, तो आपको अगले अनुरोधों में, सोच-विचार वाले ब्लॉक और उनके हस्ताक्षर शामिल करने होंगे, ताकि यह पुष्टि की जा सके कि वे असली हैं.
ज़्यादा जानकारी के लिए, सोच के आधार पर तैयार किए गए जवाबों की पुष्टि करने वाली सुविधा पेज पर जाएं.`
टूल की मदद से स्ट्रक्चर्ड आउटपुट जनरेट करना
Gemini 3 मॉडल की मदद से, स्ट्रक्चर्ड आउटपुट को बिल्ट-इन टूल के साथ जोड़ा जा सकता है. इनमें ये शामिल हैं: Google Search से जानकारी पाना, यूआरएल का कॉन्टेक्स्ट, कोड एक्ज़ीक्यूट करना, और फ़ंक्शन कॉल करना.
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)
JavaScript
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"]
}
}
}'
Image generation
Gemini 3.1 Flash Image और Gemini 3 Pro Image की मदद से, टेक्स्ट प्रॉम्प्ट से इमेज जनरेट की जा सकती हैं और उनमें बदलाव किया जा सकता है. यह किसी प्रॉम्प्ट के बारे में "सोचने" के लिए, तर्क का इस्तेमाल करता है. साथ ही, Google Search से मिली जानकारी का इस्तेमाल करने से पहले, रीयल-टाइम डेटा को ऐक्सेस कर सकता है. जैसे, मौसम का पूर्वानुमान या स्टॉक चार्ट. इसके बाद, यह ज़्यादा सटीक इमेज जनरेट करता है.
नई और बेहतर सुविधाएँ:
- 4K और टेक्स्ट रेंडरिंग: 2K और 4K रिज़ॉल्यूशन तक के टेक्स्ट और डायग्राम जनरेट करें, जो साफ़ हों और पढ़ने में आसान हों.
- भरोसेमंद जानकारी के आधार पर कॉन्टेंट जनरेट करना:
google_searchटूल का इस्तेमाल करके, तथ्यों की पुष्टि करें और असल दुनिया की जानकारी के आधार पर इमेज जनरेट करें. Google इमेज की मदद से जवाब में भरोसेमंद जानकारी शामिल करना Gemini 3.1 Flash Image के लिए उपलब्ध है. - बातचीत करके बदलाव करना: बातचीत के दौरान, इमेज में कई बार बदलाव करना.इसके लिए, बस बदलाव करने का निर्देश देना होता है. उदाहरण के लिए, "बैकग्राउंड को सूर्यास्त वाली इमेज में बदल दो". यह वर्कफ़्लो, बारी-बारी से बातचीत के दौरान विज़ुअल कॉन्टेक्स्ट को बनाए रखने के लिए, थॉट सिग्नेचर पर निर्भर करता है.
आस्पेक्ट रेशियो, बदलाव करने के वर्कफ़्लो, और कॉन्फ़िगरेशन के विकल्पों के बारे में पूरी जानकारी के लिए, इमेज जनरेट करने से जुड़ी गाइड देखें.
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()
JavaScript
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)
JavaScript
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}")
JavaScript
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 की मदद से, एक ही एपीआई कॉल में बिल्ट-इन टूल (जैसे, Google Search, यूआरएल कॉन्टेक्स्ट, और अन्य) और कस्टम फ़ंक्शन कॉलिंग टूल का इस्तेमाल किया जा सकता है. इससे ज़्यादा मुश्किल वर्कफ़्लो को मैनेज किया जा सकता है.
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)
JavaScript
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 के डिफ़ॉल्ट टेंपरेचर 1.0 का इस्तेमाल करें. इससे, लूपिंग से जुड़ी समस्याओं या मुश्किल टास्क में परफ़ॉर्मेंस में गिरावट से बचा जा सकेगा.
- PDF और दस्तावेज़ को समझना:
अगर आपको दस्तावेज़ को पार्स करने के लिए किसी खास तरीके का इस्तेमाल करना है, तो नई
media_resolution_highसेटिंग को आज़माएं. इससे यह पक्का किया जा सकेगा कि आपको सटीक नतीजे मिलते रहें. - टोकन का इस्तेमाल: Gemini 3 डिफ़ॉल्ट पर माइग्रेट करने से, PDF के लिए टोकन का इस्तेमाल बढ़ सकता है. हालांकि, वीडियो के लिए टोकन का इस्तेमाल कम हो सकता है. अगर डिफ़ॉल्ट रिज़ॉल्यूशन ज़्यादा होने की वजह से, अनुरोधों की संख्या कॉन्टेक्स्ट विंडो से ज़्यादा हो जाती है, तो हमारा सुझाव है कि मीडिया रिज़ॉल्यूशन को कम करें.
- इमेज सेगमेंटेशन: इमेज सेगमेंटेशन की सुविधाएं (ऑब्जेक्ट के लिए पिक्सल-लेवल के मास्क दिखाना) Gemini 3 Pro या Gemini 3 Flash में काम नहीं करती हैं. जिन वर्कलोड के लिए इमेज सेगमेंटेशन की सुविधा की ज़रूरत होती है उनके लिए, हमारा सुझाव है कि आप Gemini 2.5 Flash का इस्तेमाल जारी रखें. साथ ही, 'सोचने की प्रक्रिया' सुविधा को बंद रखें.
- कंप्यूटर का इस्तेमाल: Gemini 3 Pro और Gemini 3 Flash, कंप्यूटर के इस्तेमाल की सुविधा के साथ काम करते हैं. 2.5 सीरीज़ के उलट, Computer Use टूल को ऐक्सेस करने के लिए, आपको अलग मॉडल का इस्तेमाल करने की ज़रूरत नहीं है.
- टूल के साथ काम करने की सुविधा: फ़ंक्शन कॉलिंग के साथ-साथ, पहले से मौजूद टूल का इस्तेमाल करने की सुविधा अब Gemini 3 मॉडल के लिए उपलब्ध है. अब Gemini 3 मॉडल के लिए, Maps से मिली जानकारी का इस्तेमाल करने की सुविधा भी उपलब्ध है.
OpenAI के साथ काम करने वाला
OpenAI के साथ काम करने वाली लेयर का इस्तेमाल करने वाले लोगों के लिए, स्टैंडर्ड पैरामीटर (OpenAI के reasoning_effort) अपने-आप Gemini (thinking_level) के बराबर के पैरामीटर पर मैप हो जाते हैं.
प्रॉम्प्ट लिखने के सबसे सही तरीके
Gemini 3, रिज़निंग मॉडल है. इससे प्रॉम्प्ट देने का तरीका बदल जाता है.
- सटीक निर्देश: इनपुट प्रॉम्प्ट में कम शब्दों का इस्तेमाल करें. Gemini 3, साफ़ तौर पर दिए गए निर्देशों का सबसे सही जवाब देता है. यह पुराने मॉडल के लिए इस्तेमाल की गई, ज़्यादा शब्दों वाली या बहुत मुश्किल प्रॉम्प्ट इंजीनियरिंग तकनीकों का ज़्यादा विश्लेषण कर सकता है.
- जवाब में शब्दों की संख्या: डिफ़ॉल्ट रूप से, Gemini 3 कम शब्दों में जवाब देता है. यह सीधे और असरदार तरीके से जवाब देने को प्राथमिकता देता है. अगर आपको अपने इस्तेमाल के उदाहरण के लिए, ज़्यादा बातचीत करने वाली या "चैटिंग" वाली पर्सोना की ज़रूरत है, तो आपको प्रॉम्प्ट में मॉडल को साफ़ तौर पर निर्देश देना होगा. उदाहरण के लिए, "इसे एक मददगार और बातचीत करने वाले असिस्टेंट के तौर पर समझाओ".
- कॉन्टेक्स्ट मैनेजमेंट: बड़े डेटासेट (जैसे, पूरी किताबें, कोडबेस या लंबे वीडियो) के साथ काम करते समय, अपने खास निर्देश या सवाल, प्रॉम्प्ट के आखिर में रखें. ऐसा डेटा के कॉन्टेक्स्ट के बाद करें. मॉडल के जवाब को दिए गए डेटा के हिसाब से तैयार करने के लिए, अपने सवाल की शुरुआत "ऊपर दी गई जानकारी के आधार पर..." जैसे वाक्यांश से करें.
प्रॉम्प्ट इंजीनियरिंग गाइड में, प्रॉम्प्ट डिज़ाइन करने की रणनीतियों के बारे में ज़्यादा जानें.
अक्सर पूछे जाने वाले सवाल
Gemini 3 के लिए, जानकारी अपडेट होने की आखिरी तारीख क्या है? Gemini 3 मॉडल के लिए, जानकारी अपडेट होने की आखिरी तारीख जनवरी 2025 है. ज़्यादा नई जानकारी के लिए, खोज के नतीजों से जानकारी पाने वाले टूल का इस्तेमाल करें.
कॉन्टेक्स्ट विंडो की सीमाएं क्या हैं? Gemini 3 मॉडल, 10 लाख टोकन वाली कॉन्टेक्स्ट विंडो के साथ इनपुट और 64 हज़ार टोकन तक का आउटपुट जनरेट कर सकते हैं.
क्या 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, Batch API के साथ काम करता है? हां, Gemini 3 में Batch API काम करता है.
क्या कॉन्टेक्स्ट के लिए कैश मेमोरी की सुविधा काम करती है? हां, Gemini 3 के लिए कॉन्टेक्स्ट के लिए कैश मेमोरी की सुविधा उपलब्ध है.
Gemini 3 में कौनसे टूल इस्तेमाल किए जा सकते हैं? Gemini 3 में ये सुविधाएँ काम करती हैं: Google Search, Google Maps से जानकारी पाना, फ़ाइलें खोजना, कोड एक्ज़ीक्यूशन, और यूआरएल कॉन्टेक्स्ट. यह आपके कस्टम टूल के लिए, स्टैंडर्ड फ़ंक्शन कॉलिंग की सुविधा भी देता है. साथ ही, पहले से मौजूद टूल के साथ मिलकर काम करता है.
gemini-3.1-pro-preview-customtoolsक्या है? अगरgemini-3.1-pro-previewका इस्तेमाल किया जा रहा है और मॉडल, बैश कमांड के लिए आपके कस्टम टूल को अनदेखा कर रहा है, तोgemini-3.1-pro-preview-customtoolsमॉडल का इस्तेमाल करके देखें. ज़्यादा जानकारी [यहां][customtools-model] दी गई है.