Gemini 3 के लिए डेवलपर गाइड

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.steps[-1].content[0].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.steps.at(-1).content[0].text);
}

run();

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-preview 10 लाख / 64 हज़ार जनवरी 2025 0.25 डॉलर (टेक्स्ट, इमेज, वीडियो), 0.50 डॉलर (ऑडियो) / 1.50 डॉलर
gemini-3.1-flash-image-preview 1 लाख 28 हज़ार / 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 में 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.steps[-1].content[0].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?",
    generationConfig: {
      thinking_level: "low",
    },
  });

console.log(interaction.steps.at(-1).content[0].text);

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?",
    "config": {
      "thinking_level": "low"
    }
  }'

तापमान

हमारा सुझाव है कि Gemini 3 के सभी मॉडल के लिए, तापमान पैरामीटर को डिफ़ॉल्ट वैल्यू 1.0 पर सेट रखें.

पिछले मॉडल में, क्रिएटिविटी बनाम डिटरमिनिज़्म को कंट्रोल करने के लिए, तापमान को ट्यून करने से अक्सर फ़ायदा मिलता था. हालांकि, Gemini 3 की रीज़निंग क्षमताओं को डिफ़ॉल्ट सेटिंग के लिए ऑप्टिमाइज़ किया गया है. तापमान बदलने (इसे 1.0 से कम पर सेट करने) से, अनचाहा व्यवहार हो सकता है. जैसे, लूपिंग या परफ़ॉर्मेंस में गिरावट. खास तौर पर, गणित या रीज़निंग के मुश्किल टास्क में ऐसा हो सकता है.

थॉट सिग्नेचर

Gemini 3 मॉडल, एपीआई कॉल के दौरान रीज़निंग कॉन्टेक्स्ट को बनाए रखने के लिए, थॉट सिग्नेचर का इस्तेमाल करते हैं. ये सिग्नेचर, मॉडल की इंटरनल थॉट प्रोसेस के एन्क्रिप्ट किए गए वर्शन होते हैं.

  • स्टेटफ़ुल मोड (सुझाया गया): स्टेटफ़ुल मोड में Interactions API का इस्तेमाल करते समय (previous_interaction_id उपलब्ध कराने पर), सर्वर, बातचीत के इतिहास और थॉट सिग्नेचर को अपने-आप मैनेज करता है.
  • स्टेटलेस मोड: अगर बातचीत के इतिहास को मैन्युअल तरीके से मैनेज किया जा रहा है, तो आपको पुष्टि करने के लिए, बाद के अनुरोधों में सिग्नेचर के साथ थॉट ब्लॉक शामिल करने होंगे.

ज़्यादा जानकारी के लिए, थॉट सिग्नेचर वाला पेज देखें.

इमेज जनरेट और एडिट करने की सुविधा

gemini-3-pro-image-preview और gemini-3.1-flash-image-preview के लिए, बातचीत के दौरान इमेज में बदलाव करने के लिए, थॉट सिग्नेचर ज़रूरी हैं. जब मॉडल से किसी इमेज में बदलाव करने के लिए कहा जाता है, तो वह ओरिजनल इमेज की कंपोज़िशन और लॉजिक को समझने के लिए, पिछले टर्न के signature पर निर्भर करता है.

  • एडिटिंग: रिस्पॉन्स के थॉट (text या inlineData) के बाद, पहले हिस्से और हर अगले inlineData हिस्से पर सिग्नेचर की गारंटी होती है. गड़बड़ियों से बचने के लिए, आपको ये सभी सिग्नेचर वापस भेजने होंगे.

कोड के उदाहरण

मल्टी-स्टेप फ़ंक्शन कॉलिंग (सीक्वेंशियल)

उपयोगकर्ता, एक ही टर्न में ऐसा सवाल पूछता है जिसके लिए दो अलग-अलग चरणों की ज़रूरत होती है (फ़्लाइट की जानकारी देखना -> टैक्सी बुक करना).

पहला चरण: मॉडल, फ़्लाइट टूल को कॉल करता है.
मॉडल, सिग्नेचर दिखाता है <Sig_A>

// Model Response (Turn 1, Step 1)
  {
    "id": "interaction-123",
    "steps": [
      {
        "type": "function_call",
        "name": "check_flight",
        "arguments": {"flight": "AA100"},
        "signature": "<Sig_A>" // SAVE THIS
      }
    ]
  }

दूसरा चरण: उपयोगकर्ता, फ़्लाइट की जानकारी भेजता है
मॉडल की सोच को बनाए रखने के लिए, हमें <Sig_A> वापस भेजना होगा.

// User Request (Turn 1, Step 2)
  {
    "model": "gemini-3-flash-preview",
    "previous_interaction_id": "interaction-123",
    "input": [
      {
        "type": "function_result",
        "call_id": "fc_check_flight",
        "name": "check_flight",
        "result": [{ "type": "text", "text": "{\"status\": \"delayed\", \"departure_time\": \"12 PM\"}" }]
      }
    ]
  }

तीसरा चरण: मॉडल, टैक्सी टूल को कॉल करता है
मॉडल, <Sig_A> का इस्तेमाल करके, फ़्लाइट में हुई देरी को याद रखता है. अब वह टैक्सी बुक करने का फ़ैसला लेता है. वह एक नया सिग्नेचर <Sig_B> जनरेट करता है.

// Model Response (Turn 1, Step 3)
  {
    "id": "interaction-123",
    "steps": [
      {
        "type": "function_call",
        "name": "book_taxi",
        "arguments": {"time": "10 AM"},
        "signature": "<Sig_B>" // SAVE THIS
      }
    ]
  }

चौथा चरण: उपयोगकर्ता, टैक्सी की जानकारी भेजता है
टर्न पूरा करने के लिए, आपको पूरी चेन वापस भेजनी होगी: <Sig_A> और <Sig_B>.

// User Request (Turn 1, Step 4)
  {
    "model": "gemini-3-flash-preview",
    "previous_interaction_id": "interaction-123",
    "input": [
      {
        "type": "function_result",
        "call_id": "fc_book_taxi",
        "name": "book_taxi",
        "result": [{ "type": "text", "text": "{\"booking_status\": \"success\"}" }]
      }
    ]
  }

पैरलल फ़ंक्शन कॉलिंग

उपयोगकर्ता यह सवाल पूछता है: "दिल्ली और मुंबई का मौसम कैसा है?" मॉडल, एक ही जवाब में दो फ़ंक्शन कॉल दिखाता है.

// Model Response
  {
    "id": "interaction-456",
    "steps": [
      {
        "type": "function_call",
        "name": "check_weather",
        "arguments": { "city": "Paris" },
        "signature": "<Signature_A>" // INCLUDED on First FC
      },
      {
        "type": "function_call",
        "name": "check_weather",
        "arguments": { "city": "London" }
      }
    ]
  }

// User Request (Sending Parallel Results)
  {
    "model": "gemini-3-flash-preview",
    "previous_interaction_id": "interaction-456",
    "input": [
      {
        "type": "function_result",
        "call_id": "fc_paris",
        "name": "check_weather",
        "result": [{ "type": "text", "text": "15C" }]
      },
      {
        "type": "function_result",
        "call_id": "fc_london",
        "name": "check_weather",
        "result": [{ "type": "text", "text": "12C" }]
      }
    ]
  }

अन्य मॉडल से माइग्रेट करना

अगर बातचीत के इतिहास को किसी दूसरे मॉडल (जैसे, Gemini 2.5) से ट्रांसफ़र किया जा रहा है या Gemini 3 से जनरेट नहीं किया गया कोई कस्टम फ़ंक्शन कॉल जोड़ा जा रहा है, तो आपके पास मान्य सिग्नेचर नहीं होगा.

इन खास स्थितियों में, सख्त पुष्टि को बायपास करने के लिए, फ़ील्ड में यह डमी स्ट्रिंग डालें: "signature": "context_engineering_is_the_way to_go"

टूल के साथ स्ट्रक्चर्ड आउटपुट

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=[
        {"google_search": {}},
        {"url_context": {}}
    ],
    response_format={
        "type": "text",
        "mime_type": "application/json",
        "schema": MatchResult.model_json_schema()
    },
)

result = MatchResult.model_validate_json(interaction.steps[-1].content[0].text)
print(result)

JavaScript

import { GoogleGenAI } from "@google/genai";
import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";

const client = new GoogleGenAI({});

const matchSchema = z.object({
  winner: z.string().describe("The name of the winner."),
  final_match_score: z.string().describe("The final score."),
  scorers: z.array(z.string()).describe("The name of the scorer.")
});

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: [
      { googleSearch: {} },
      { urlContext: {} }
    ],
    response_format: {
        type: "text",
        mime_type: "application/json",
        schema: zodToJsonSchema(matchSchema)
    },
  });

  const match = matchSchema.parse(JSON.parse(interaction.steps.at(-1).content[0].text));
  console.log(match);
}

run();

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": [
      {"google_search": {}},
      {"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 टूल का इस्तेमाल करें. Gemini 3.1 Flash Image के लिए, Google Image Search के साथ ग्राउंडिंग की सुविधा उपलब्ध है.
  • बातचीत के दौरान इमेज में बदलाव करना: सिर्फ़ बदलाव करने के लिए कहकर, मल्टी-टर्न इमेज एडिटिंग की जा सकती है. जैसे, "बैकग्राउंड को सनसेट बनाओ". इस वर्कफ़्लो में, टर्न के बीच विज़ुअल कॉन्टेक्स्ट को बनाए रखने के लिए, थॉट सिग्नेचर का इस्तेमाल किया जाता है.

आस्पेक्ट रेशियो, एडिटिंग वर्कफ़्लो, और कॉन्फ़िगरेशन के विकल्पों के बारे में पूरी जानकारी के लिए, इमेज जनरेशन गाइड देखें.

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=[{"google_search": {}}],
    response_format={
        "type": "image",
        "aspect_ratio": "16:9",
        "image_size": "4K"
    }
)

from PIL import Image
import io

image_blocks = [content_block for content_block in interaction.steps[-1].content if content_block.type == "image"]
if image_blocks:
    image_data = base64.b64decode(image_blocks[0].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: [{ googleSearch: {} }],
    responseFormat: {
      type: "image",
      aspectRatio: "16:9",
      imageSize: "4K"
    }
  });

  for (const contentBlock of interaction.steps.at(-1).content) {
    if (contentBlock.type === "image") {
      const buffer = Buffer.from(contentBlock.data, "base64");
      fs.writeFileSync("weather_tokyo.png", buffer);
    }
  }
}

run();

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": [{"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=[{"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: [
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageData,
        },
      },
      {
        text: "Zoom into the expression pedals and tell me how many pedals are there?",
      },
    ],
    tools: [{ codeExecution: {} }],
  });

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

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": [{
        "parts":[
            {
              "inline_data": {
                "mime_type":"'"$MIME_TYPE"'",
                "data": "'"$IMAGE_B64"'"
              }
            },
            {"text": "Zoom into the expression pedals and tell me how many pedals are there?"}
        ]
      }],
      "tools": [{"code_execution": {}}]
    }'

इमेज के साथ कोड एक्ज़ीक्यूशन के बारे में ज़्यादा जानकारी के लिए, कोड एक्ज़ीक्यूशन देखें.

मल्टीमॉडल फ़ंक्शन रिस्पॉन्स

मल्टीमॉडल फ़ंक्शन कॉलिंग की मदद से, उपयोगकर्ताओं को ऐसे फ़ंक्शन रिस्पॉन्स मिल सकते हैं जिनमें मल्टीमॉडल ऑब्जेक्ट शामिल होते हैं. इससे, मॉडल की फ़ंक्शन कॉलिंग क्षमताओं का बेहतर इस्तेमाल किया जा सकता है. स्टैंडर्ड फ़ंक्शन कॉलिंग में, सिर्फ़ टेक्स्ट पर आधारित फ़ंक्शन रिस्पॉन्स काम करते हैं:

Python

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],
    thinking_config={"include_thoughts": True},
)

print(f"\nFinal model response: {interaction_2.steps[-1].content[0].text}")

JavaScript

import { GoogleGenAI } from '@google/genai';

const client = new GoogleGenAI({});

// 1. Define the tool
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'],
    },
};

// 2. Send the request with tools
const interaction1 = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Show me the instrument I ordered last month.',
    tools: [getImageTool],
});

// 3. Find the function call step
const fcStep = interaction1.steps.find(s => s.type === 'function_call');
console.log(`Tool Call: ${fcStep.name}(${JSON.stringify(fcStep.arguments)})`);

// Execute tool (fetch image)
const imageUrl = 'https://goo.gle/instrument-img';
const response = await fetch(imageUrl);
const imageArrayBuffer = await response.arrayBuffer();
const base64ImageData = Buffer.from(imageArrayBuffer).toString('base64');

// 4. Send multimodal function result back
const interaction2 = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    previousInteractionId: interaction1.id,
    input: [{
        type: 'function_result',
        name: fcStep.name,
        call_id: fcStep.id,
        result: [
            { type: 'text', text: 'instrument.jpg' },
            {
                type: 'image',
                mimeType: 'image/jpeg',
                data: base64ImageData,
            }
        ]
    }],
    tools: [getImageTool],
    thinking_config: { include_thoughts: true },
});

console.log(`\nFinal model response: ${interaction2.steps.at(-1).content[0].text}`);

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"'"
        }
      ]
    }],
    "thinking_config": { "include_thoughts": true }
  }'

इन-बिल्ट टूल और फ़ंक्शन कॉलिंग को जोड़ना

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=[
        {"google_search": {}},
        getWeather
    ],
)

# Find the function call step
fc_step = next((s for s in interaction.steps if s.type == "function_call"), None)

if fc_step:
    # Simulate a function result
    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=[
            {"google_search": {}},
            getWeather
        ],
        previous_interaction_id=interaction.id,
    )

    print(final_interaction.steps[-1].content[0].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: [
    { googleSearch: {} },
    getWeatherDeclaration
  ],
});

// Find the function call step
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: [
      { googleSearch: {} },
      getWeatherDeclaration
    ],
    previous_interaction_id: interaction.id,
  });

  console.log(finalInteraction.steps.at(-1).content[0].text);
}

Gemini 2.5 से माइग्रेट करना

Gemini 3, अब तक का हमारा सबसे बेहतरीन मॉडल है. यह Gemini 2.5 से बेहतर है. माइग्रेट करते समय, इन बातों का ध्यान रखें:

  • थिंकिंग: अगर पहले Gemini 2.5 से रीज़निंग कराने के लिए, मुश्किल प्रॉम्प्ट इंजीनियरिंग (जैसे, चेन ऑफ़ थॉट) का इस्तेमाल किया जाता था, तो अब Gemini 3 को thinking_level: "high" और आसान प्रॉम्प्ट के साथ आज़माएं.
  • तापमान की सेटिंग: अगर मौजूदा कोड में तापमान को साफ़ तौर पर सेट किया गया है (खास तौर पर, डिटरमिनिस्टिक आउटपुट के लिए कम वैल्यू पर), तो हमारा सुझाव है कि इस पैरामीटर को हटा दें और Gemini 3 के डिफ़ॉल्ट तापमान 1.0 का इस्तेमाल करें. इससे, लूपिंग की समस्याओं या मुश्किल टास्क में परफ़ॉर्मेंस में गिरावट से बचा जा सकता है.
  • PDF और दस्तावेज़ को समझना: अगर घने दस्तावेज़ को पार्स करने के लिए, किसी खास व्यवहार पर निर्भर रहा जाता था, तो सटीक जानकारी पाने के लिए, media_resolution_high की नई सेटिंग की जांच करें.
  • टोकन की खपत: Gemini 3 के डिफ़ॉल्ट पर माइग्रेट करने से, PDF के लिए टोकन का इस्तेमाल बढ़ सकता है. हालांकि, वीडियो के लिए टोकन का इस्तेमाल कम हो सकता है. अगर डिफ़ॉल्ट रिज़ॉल्यूशन ज़्यादा होने की वजह से, अनुरोध अब कॉन्टेक्स्ट विंडो से ज़्यादा हो जाते हैं, तो हमारा सुझाव है कि मीडिया रिज़ॉल्यूशन को साफ़ तौर पर कम करें.
  • इमेज सेगमेंटेशन: Gemini 3 Pro या Gemini 3 Flash में, इमेज सेगमेंटेशन की सुविधाएं (ऑब्जेक्ट के लिए पिक्सल-लेवल मास्क दिखाना) काम नहीं करती हैं. जिन वर्कलोड के लिए, इन-बिल्ट इमेज सेगमेंटेशन की ज़रूरत होती है उनके लिए, हमारा सुझाव है कि थिंकिंग की सुविधा बंद करके, Gemini 2.5 Flash या Gemini Robotics-ER 1.6 का इस्तेमाल जारी रखें.
  • कंप्यूटर का इस्तेमाल: 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 कम शब्दों का इस्तेमाल करता है और सीधे, सटीक जवाब देता है. अगर आपके इस्तेमाल के उदाहरण के लिए, ज़्यादा बातचीत करने वाले या "चैट करने वाले" मॉडल की ज़रूरत है, तो आपको प्रॉम्प्ट में साफ़ तौर पर मॉडल को निर्देश देना होगा. जैसे, "इसे एक दोस्त की तरह, बातूनी असिस्टेंट के तौर पर समझाओ".
  • कॉन्टेक्स्ट मैनेजमेंट: बड़े डेटासेट (जैसे, पूरी किताबें, कोडबेस या लंबे वीडियो) के साथ काम करते समय, अपने खास निर्देश या सवाल, प्रॉम्प्ट के आखिर में, डेटा कॉन्टेक्स्ट के बाद रखें. मॉडल की रीज़निंग को दिए गए डेटा से जोड़ने के लिए, अपने सवाल की शुरुआत "पिछली जानकारी के आधार पर..." जैसे वाक्यांश से करें.

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

अक्सर पूछे जाने वाले सवाल

  1. Gemini 3 के लिए, जानकारी न मिलने की समयसीमा क्या है? Gemini 3 मॉडल के लिए, जानकारी न मिलने की समयसीमा जनवरी 2025 है. हाल ही की जानकारी पाने के लिए, Search Grounding टूल का इस्तेमाल करें.

  2. कॉन्टेक्स्ट विंडो की सीमाएं क्या हैं? Gemini 3 मॉडल, 10 लाख टोकन वाली इनपुट कॉन्टेक्स्ट विंडो और 64 हज़ार टोकन तक का आउटपुट सपोर्ट करते हैं.

  3. क्या Gemini 3 के लिए कोई मुफ़्त टियर उपलब्ध है? Gemini API में, Gemini 3 Flash gemini-3-flash-preview के लिए एक मुफ़्त टियर उपलब्ध है. Google AI Studio में, Gemini 3.1 Pro और 3 Flash को बिना किसी शुल्क के आज़माया जा सकता है. हालांकि, Gemini API में gemini-3.1-pro-preview के लिए कोई मुफ़्त टियर उपलब्ध नहीं है.

  4. क्या मेरा पुराना thinking_budget कोड अब भी काम करेगा? हां, thinking_budget अब भी काम करता है. हालांकि, हम सुझाव देते हैं कि ज़्यादा सटीक परफ़ॉर्मेंस के लिए, thinking_level पर माइग्रेट करें. एक ही अनुरोध में, दोनों का इस्तेमाल न करें.

  5. क्या Gemini 3, बैच एपीआई को सपोर्ट करता है? हां, Gemini 3, बैच एपीआई को सपोर्ट करता है.

  6. क्या कॉन्टेक्स्ट कैशिंग की सुविधा काम करती है? हां, कॉन्टेक्स्ट कैशिंग की सुविधा Gemini 3 के लिए काम करती है.

  7. Gemini 3 में कौन-कौनसे टूल काम करते हैं? Gemini 3 में, Google Search, Google Maps के साथ ग्राउंडिंग, फ़ाइल सर्च, कोड एक्ज़ीक्यूशन, और यूआरएल कॉन्टेक्स्ट काम करते हैं. यह आपके कस्टम टूल के लिए, स्टैंडर्ड फ़ंक्शन कॉलिंग और इन बिल्ट टूल के साथ मिलकर काम करने की सुविधा भी देता है.

  8. क्या है gemini-3.1-pro-preview-customtools? अगर gemini-3.1-pro-preview का इस्तेमाल किया जा रहा है और मॉडल, bash कमांड के लिए आपके कस्टम टूल को अनदेखा कर रहा है, तो इसके बजाय gemini-3.1-pro-preview-customtools मॉडल का इस्तेमाल करें. ज़्यादा जानकारी यहां देखें.

अगले चरण