Panduan Developer Gemini 3

Gemini 3 adalah rangkaian model tercerdas kami hingga saat ini, yang dibangun berdasarkan fondasi penalaran canggih. Model ini dirancang untuk mewujudkan ide apa pun dengan menguasai alur kerja agen, coding otonom, dan tugas multimodal yang kompleks. Panduan ini membahas fitur utama rangkaian model Gemini 3 dan cara memaksimalkan penggunaannya.

Jelajahi koleksi aplikasi Gemini 3 kami untuk melihat cara model menangani penalaran lanjutan, coding otonom, dan tugas multimodal yang kompleks.

Mulai dengan beberapa baris kode:

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

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "model": "gemini-3.1-pro-preview",
    "input": "Find the race condition in this multi-threaded C++ snippet: [code here]"
  }'

Mengenal seri Gemini 3

Gemini 3.1 Pro paling cocok untuk tugas kompleks yang memerlukan pengetahuan dunia yang luas dan penalaran lanjutan di berbagai modalitas.

Gemini 3 Flash adalah model seri 3 terbaru kami, dengan kecerdasan tingkat Pro pada kecepatan dan harga Flash.

Nano Banana Pro (juga dikenal sebagai Gemini 3 Pro Image) adalah model pembuatan gambar berkualitas tertinggi kami, dan Nano Banana 2 (juga dikenal sebagai Gemini 3.1 Flash Image) adalah model yang setara dengan volume tinggi, efisiensi tinggi, dan harga yang lebih rendah.

Gemini 3.1 Flash-Lite adalah model andalan kami yang dibuat untuk model efisiensi biaya dan tugas bervolume tinggi.

Semua model Gemini 3 saat ini dalam versi pratinjau.

ID Model Jendela Konteks (Masuk / Keluar) Batas Informasi Harga (Input / Output)*
gemini-3.1-flash-lite 1 Juta / 64 Ribu Januari 2025 $0,25 (teks, gambar, video), $0,50 (audio) / $1,50
gemini-3.1-flash-image-preview 128 Ribu / 32 Ribu Januari 2025 $0,25 (Input Teks) / $0,067 (Output Gambar)**
gemini-3.1-pro-preview 1 Juta / 64 Ribu Januari 2025 $2 / $12 (<200 ribu token)
$4 / $18 (>200 ribu token)
gemini-3-flash-preview 1 Juta / 64 Ribu Januari 2025 $0,50 / $3
gemini-3-pro-image-preview 65 Ribu / 32 Ribu Januari 2025 $2 (Input Teks) / $0,134 (Output Gambar)**

* Harga per 1 juta token, kecuali jika dinyatakan lain. ** Harga gambar bervariasi menurut resolusi. Lihat halaman harga untuk mengetahui detail selengkapnya.

Untuk mengetahui batas, harga, dan informasi tambahan yang mendetail, lihat halaman model.

Fitur API baru di Gemini 3

Gemini 3 memperkenalkan parameter baru yang dirancang untuk memberi developer lebih banyak kontrol atas latensi, biaya, dan fidelitas multimodal.

Tingkat penalaran

Model seri Gemini 3 menggunakan penalaran dinamis secara default untuk menalar perintah. Anda dapat menggunakan parameter thinking_level, yang mengontrol kedalaman maksimum proses penalaran internal model sebelum menghasilkan respons. Gemini 3 memperlakukan tingkat ini sebagai alokasi relatif untuk penalaran, bukan jaminan token yang ketat.

Jika thinking_level tidak ditentukan, Gemini 3 akan menggunakan high sebagai default. Untuk respons yang lebih cepat dan latensi yang lebih rendah saat penalaran kompleks tidak diperlukan, Anda dapat membatasi tingkat penalaran model ke low.

Tingkat Penalaran Gemini 3.1 Pro Gemini 3.1 Flash-Lite Gemini 3 Flash Deskripsi
minimal Tidak didukung Didukung (Default) Didukung Cocok dengan setelan "tanpa penalaran" untuk sebagian besar kueri. Model mungkin berpikir sangat minimal untuk tugas coding yang kompleks. Meminimalkan latensi untuk aplikasi chat atau throughput tinggi. Perhatikan, minimal tidak menjamin bahwa penalaran dinonaktifkan.
low Didukung Didukung Didukung Meminimalkan latensi dan biaya. Paling cocok untuk aplikasi chat, mengikuti petunjuk sederhana, atau aplikasi throughput tinggi.
medium Didukung Didukung Didukung Penalaran yang seimbang untuk sebagian besar tugas.
high Didukung (Default, Dinamis) Didukung (Dinamis) Didukung (Default, Dinamis) Memaksimalkan kedalaman penalaran. Model mungkin memerlukan waktu yang jauh lebih lama untuk mencapai token output pertama (tanpa penalaran), tetapi output akan lebih hati-hati.

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

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "model": "gemini-3.1-pro-preview",
    "input": "How does AI work?",
    "generation_config": {
      "thinking_level": "low"
    }
  }'

Suhu

Untuk semua model Gemini 3, sebaiknya pertahankan parameter suhu pada nilai default 1.0.

Meskipun model sebelumnya sering kali diuntungkan dengan menyesuaikan suhu untuk mengontrol kreativitas versus determinisme, kemampuan penalaran Gemini 3 dioptimalkan untuk setelan default. Mengubah suhu (menetapkannya di bawah 1.0) dapat menyebabkan perilaku yang tidak terduga, seperti looping atau penurunan performa, terutama dalam tugas matematika atau penalaran yang kompleks.

Tanda tangan pemikiran

Model Gemini 3 menggunakan tanda tangan pemikiran untuk mempertahankan konteks penalaran di seluruh panggilan API. Tanda tangan ini adalah representasi terenkripsi dari proses pemikiran internal model.

  • Mode Stateful (Direkomendasikan): Saat menggunakan Interactions API dalam mode stateful (memberikan previous_interaction_id), server akan otomatis mengelola histori percakapan dan tanda tangan pemikiran.
  • Mode Stateless: Jika mengelola histori percakapan secara manual, Anda harus menyertakan blok pemikiran dengan tanda tangannya dalam permintaan berikutnya untuk memvalidasi keaslian.

Untuk mengetahui informasi mendetail, lihat halaman Tanda Tangan Pemikiran.

Output Terstruktur dengan alat

Model Gemini 3 memungkinkan Anda menggabungkan Output Terstruktur dengan alat bawaan, termasuk Grounding dengan Google Penelusuran, Konteks URL, Eksekusi Kode, dan Panggilan Fungsi.

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

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Api-Revision: 2026-05-20" \
  -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"]
        }
    }
  }'

Pembuatan gambar

Gemini 3.1 Flash Image dan Gemini 3 Pro Image memungkinkan Anda membuat dan mengedit gambar dari perintah teks. Model ini menggunakan penalaran untuk "memikirkan" perintah dan dapat mengambil data real-time—seperti prakiraan cuaca atau grafik saham—sebelum menggunakan grounding Google Penelusuran sebelum membuat gambar dengan fidelitas tinggi.

Kemampuan baru &yang ditingkatkan:

  • Rendering teks &4K: Buat teks dan diagram yang tajam dan mudah dibaca dengan resolusi hingga 2K dan 4K.
  • Pembuatan berbasis grounding: Gunakan alat google_search untuk memverifikasi fakta dan membuat gambar berdasarkan informasi dunia nyata. Grounding dengan Google Image Search tersedia untuk Gemini 3.1 Flash Image.
  • Pengeditan via percakapan: Pengeditan gambar multi-turn hanya dengan meminta perubahan (misalnya, "Buat latar belakangnya menjadi matahari terbenam"). Alur kerja ini mengandalkan Tanda Tangan Pemikiran untuk mempertahankan konteks visual antar-turn.

Untuk mengetahui detail lengkap tentang rasio aspek, alur kerja pengeditan, dan opsi konfigurasi, lihat panduan Pembuatan Gambar.

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

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Api-Revision: 2026-05-20" \
  -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"
    }
  }'

Contoh Respons

Cuaca Tokyo

Eksekusi Kode dengan gambar

Gemini 3 Flash dapat memperlakukan visi sebagai investigasi aktif, bukan hanya sekadar melihat statis. Dengan menggabungkan penalaran dengan eksekusi kode, model akan merumuskan rencana, lalu menulis dan menjalankan kode Python untuk memperbesar, memangkas, memberi anotasi, atau memanipulasi gambar langkah demi langkah untuk membumikan jawabannya secara visual.

Kasus penggunaan:

  • Memperbesar dan memeriksa: Model secara implisit mendeteksi kapan detail terlalu kecil (misalnya, membaca pengukur atau nomor seri yang jauh) dan menulis kode untuk memangkas dan memeriksa ulang area tersebut pada resolusi yang lebih tinggi.
  • Matematika dan pembuatan grafik visual: Model dapat menjalankan perhitungan multi-langkah menggunakan kode (misalnya, menjumlahkan item baris pada tanda terima, atau membuat diagram Matplotlib dari data yang diekstrak).
  • Anotasi gambar: Model dapat menggambar panah, kotak pembatas, atau anotasi lainnya langsung ke gambar untuk menjawab pertanyaan spasial seperti "Ke mana item ini harus ditempatkan?".

Untuk mengaktifkan pemikiran visual, konfigurasi Eksekusi Kode sebagai alat. Model akan otomatis menggunakan kode untuk memanipulasi gambar jika diperlukan.

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

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' \
    -H "Api-Revision: 2026-05-20" \
    -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"}]
    }'

Untuk mengetahui detail selengkapnya tentang eksekusi kode dengan gambar, lihat Eksekusi Kode.

Respons fungsi multimodal

Panggilan fungsi multimodal memungkinkan pengguna memiliki respons fungsi yang berisi objek multimodal sehingga memungkinkan penggunaan kemampuan panggilan fungsi model yang lebih baik. Panggilan fungsi standar hanya mendukung respons fungsi berbasis teks:

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}`);

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' \
#   -H "Api-Revision: 2026-05-20" \
#   -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' \
  -H "Api-Revision: 2026-05-20" \
  -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"'"
        }
      ]
    }]
  }'

Menggabungkan alat bawaan dan panggilan fungsi

Gemini 3 memungkinkan penggunaan alat bawaan (seperti Google Penelusuran, konteks URL, dan lainnya) serta alat panggilan fungsi kustom dalam panggilan API yang sama, sehingga memungkinkan alur kerja yang lebih kompleks.

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

Migrasi dari Gemini 2.5

Gemini 3 adalah rangkaian model tercanggih kami hingga saat ini dan menawarkan peningkatan bertahap dibandingkan Gemini 2.5. Saat bermigrasi, pertimbangkan hal berikut:

  • Penalaran: Jika sebelumnya Anda menggunakan teknik rekayasa perintah yang kompleks (seperti alur berpikir) untuk memaksa Gemini 2.5 melakukan penalaran, coba Gemini 3 dengan thinking_level: "high" dan perintah yang disederhanakan.
  • Setelan suhu: Jika kode yang ada menetapkan suhu secara eksplisit (terutama ke nilai rendah untuk output deterministik), sebaiknya hapus parameter ini dan gunakan default Gemini 3 sebesar 1.0 untuk menghindari potensi masalah looping atau penurunan performa pada tugas yang kompleks.
  • Pemahaman PDF &dokumen: Jika Anda mengandalkan perilaku tertentu untuk penguraian dokumen padat, uji setelan media_resolution_high baru untuk memastikan akurasi berkelanjutan.
  • Konsumsi token: Bermigrasi ke default Gemini 3 dapat meningkatkan penggunaan token untuk PDF, tetapi menurunkan penggunaan token untuk video. Jika permintaan kini melebihi jendela konteks karena resolusi default yang lebih tinggi, sebaiknya kurangi resolusi media secara eksplisit.
  • Segmentasi gambar: Kemampuan segmentasi gambar (menampilkan mask tingkat piksel untuk objek) tidak didukung di Gemini 3 Pro atau Gemini 3 Flash. Untuk workload yang memerlukan segmentasi gambar bawaan, sebaiknya terus gunakan Gemini 2.5 Flash dengan penalaran dinonaktifkan atau Gemini Robotics-ER 1.6.
  • Penggunaan Komputer: Gemini 3 Pro dan Gemini 3 Flash mendukung Penggunaan Komputer. Tidak seperti seri 2.5, Anda tidak perlu menggunakan model terpisah untuk mengakses alat Penggunaan Komputer.
  • Dukungan alat: Menggabungkan alat bawaan dengan panggilan fungsi kini didukung untuk model Gemini 3. Grounding peta juga kini didukung untuk model Gemini 3.

Kompatibilitas OpenAI

Untuk pengguna yang menggunakan lapisan kompatibilitas OpenAI, parameter standar (OpenAI's reasoning_effort) akan otomatis dipetakan ke Gemini (thinking_level) yang setara.

Praktik terbaik perintah

Gemini 3 adalah model penalaran, yang mengubah cara Anda harus memberikan perintah.

  • Petunjuk yang tepat: Buat perintah input Anda secara ringkas. Gemini 3 merespons petunjuk yang langsung dan jelas dengan baik. Model ini mungkin menganalisis secara berlebihan teknik rekayasa perintah yang panjang atau terlalu kompleks yang digunakan untuk model lama.
  • Panjang output: Secara default, Gemini 3 tidak terlalu panjang dan lebih suka memberikan jawaban yang langsung dan efisien. Jika kasus penggunaan Anda memerlukan persona yang lebih percakapan atau "ramah", Anda harus secara eksplisit mengarahkan model dalam perintah (misalnya, "Jelaskan ini sebagai asisten yang ramah dan banyak bicara").
  • Pengelolaan konteks: Saat menggunakan set data besar (misalnya, seluruh buku, codebase, atau video panjang), tempatkan petunjuk atau pertanyaan spesifik Anda di akhir perintah, setelah konteks data. Arahkan penalaran model ke data yang diberikan dengan memulai pertanyaan Anda dengan frasa seperti, "Berdasarkan informasi sebelumnya...".

Pelajari lebih lanjut strategi desain perintah dalam panduan rekayasa perintah.

FAQ

  1. Berapa batas informasi untuk Gemini 3? Model Gemini 3 memiliki batas informasi Januari 2025. Untuk informasi terbaru, gunakan alat Grounding Penelusuran.

  2. Berapa batas jendela konteks? Model Gemini 3 mendukung jendela konteks input 1 juta token dan output hingga 64 ribu token.

  3. Apakah ada paket gratis untuk Gemini 3? Gemini 3 Flash gemini-3-flash-preview memiliki paket gratis di Gemini API. Anda dapat mencoba Gemini 3.1 Pro dan 3 Flash tanpa biaya di Google AI Studio, tetapi tidak ada paket gratis yang tersedia untuk gemini-3.1-pro-preview di Gemini API.

  4. Apakah kode thinking_budget lama saya masih berfungsi? Ya, thinking_budget masih didukung untuk kompatibilitas mundur, tetapi sebaiknya migrasikan ke thinking_level untuk performa yang lebih dapat diprediksi. Jangan gunakan keduanya dalam permintaan yang sama.

  5. Apakah Gemini 3 mendukung Batch API? Ya, Gemini 3 mendukung Batch API.

  6. Apakah Cache Konteks didukung? Ya, Cache Konteks didukung untuk Gemini 3.

  7. Alat mana yang didukung di Gemini 3? Gemini 3 mendukung Google Penelusuran, Grounding dengan Google Maps, Penelusuran File, Eksekusi Kode, dan Konteks URL. Model ini juga mendukung standar Panggilan Fungsi untuk alat kustom Anda sendiri, dan dalam kombinasi dengan alat bawaan.

  8. Apa yang dimaksud dengan gemini-3.1-pro-preview-customtools? Jika Anda menggunakan gemini-3.1-pro-preview dan model mengabaikan alat kustom Anda dan lebih memilih perintah bash, coba model gemini-3.1-pro-preview-customtools sebagai gantinya. Info selengkapnya [di sini][customtools-model].