מדריך למפתחים של Gemini 3
Gemini 3 הוא קבוצת המודלים הכי חכמה שלנו עד היום, שמבוססת על יכולות חשיבה רציונלית מתקדמות. הוא נועד להפוך כל רעיון למציאות באמצעות שליטה בתהליכי עבודה מבוססי-סוכן, בתכנות אוטונומי ובמשימות מורכבות מרובות-מוֹדָלִים. במדריך הזה נסביר על התכונות העיקריות של משפחת מודלים Gemini 3 ואיך להפיק ממנה את המרב.
כדאי לעיין באוסף אפליקציות Gemini 3 כדי לראות איך המודל מתמודד עם חשיבה רציונלית משופרת, תכנות אוטונומי ומשימות מורכבות מרובות-אופנים.
כדי להתחיל, אפשר להשתמש בכמה שורות קוד:
Python
# This will only work for SDK newer than 2.0.0
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
// This will only work for SDK newer than 2.0.0
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
# Specifies the API revision to avoid breaking changes when they become default
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]"
}'
הכירו את סדרת Gemini 3
Gemini 3.1 Pro הוא המודל הכי טוב למשימות מורכבות שדורשות ידע רחב על העולם וחשיבה רציונלית משופרת במגוון אופנים.
Gemini 3 Flash הוא המודל העדכני ביותר בסדרת 3, עם יכולות AI ברמת 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 | 1M / 64k | ינואר 2025 | 0.25$ (טקסט, תמונה, סרטון), 0.50$ (אודיו) / 1.50$ |
| gemini-3.1-flash-image-preview | 128k / 32k | ינואר 2025 | 0.25$ (קלט טקסט) / 0.067$ (פלט תמונה)** |
| gemini-3.1-pro-preview | 1M / 64k | ינואר 2025 | 2$ / 12$ (<200k tokens) 4$ / 18$ (>200k tokens) |
| gemini-3-flash-preview | 1M / 64k | ינואר 2025 | 0.50$ / 3$ |
| gemini-3-pro-image-preview | 65,000 / 32,000 | ינואר 2025 | 2$ (הזנת טקסט) / 0.134$ (פלט תמונה)** |
* המחירים הם למיליון טוקנים, אלא אם צוין אחרת. ** המחיר של התמונות משתנה בהתאם לרזולוציה. פרטים נוספים מופיעים בדף התמחור.
מידע נוסף על מגבלות, מחירים ופרטים נוספים זמין בדף המודלים.
תכונות חדשות ב-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
# This will only work for SDK newer than 2.0.0
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
// This will only work for SDK newer than 2.0.0
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.steps.at(-1).content[0].text);
REST
# Specifies the API revision to avoid breaking changes when they become default
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"
}
}'
טמפרטורה
בכל המודלים של Gemini 3, מומלץ מאוד להשאיר את פרמטר רמת האקראיות בערך ברירת המחדל שלו, 1.0.
במודלים קודמים, כדאי היה לכוונן את רמת האקראיות כדי לשלוט ביצירתיות לעומת דטרמיניזם, אבל יכולות החשיבה הרציונלית של Gemini 3 מותאמות להגדרת ברירת המחדל. שינוי הטמפרטורה (הגדרה של ערך מתחת ל-1.0) עלול להוביל להתנהגות לא צפויה, כמו לולאות או ביצועים ירודים, במיוחד במשימות מורכבות שקשורות למתמטיקה או להיגיון.
חתימות של תהליכי חשיבה
מודלים של Gemini 3 משתמשים בחתימות מחשבה כדי לשמור על הקשר של הנימוקים בקריאות ל-API. החתימות האלה הן ייצוגים מוצפנים של תהליך החשיבה הפנימי של המודל.
- מצב Stateful (מומלץ): כשמשתמשים ב-Interactions API במצב Stateful (מספקים
previous_interaction_id), השרת מנהל באופן אוטומטי את היסטוריית השיחות ואת חתימות המחשבה. - מצב ללא שמירת מצב: אם אתם מנהלים את היסטוריית השיחות באופן ידני, אתם צריכים לכלול בלוקים של מחשבות עם החתימות שלהם בבקשות הבאות כדי לאמת את האותנטיות.
מידע מפורט זמין בדף חתימות מחשבה.
פלט מובנה עם כלים
מודלים של Gemini 3 מאפשרים לכם לשלב פלט מובנה עם כלים מובנים, כולל עיגון באמצעות חיפוש Google, הקשר של כתובת URL, הרצת קוד וקריאה לפונקציה.
Python
# This will only work for SDK newer than 2.0.0
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.steps[-1].content[0].text)
print(result)
JavaScript
// This will only work for SDK newer than 2.0.0
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.steps.at(-1).content[0].text));
console.log(match);
}
run();
REST
# Specifies the API revision to avoid breaking changes when they become default
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"]
}
}
}'
יצירת תמונות
Gemini 3.1 Flash Image ו-Gemini 3 Pro Image מאפשרים ליצור ולערוך תמונות באמצעות הנחיות טקסט. הוא משתמש בחשיבה רציונלית כדי 'לחשוב' על הנחיה, ויכול לאחזר נתונים בזמן אמת – כמו תחזיות מזג אוויר או תרשימי מניות – לפני שהוא משתמש בעיגון של חיפוש Google כדי ליצור תמונות ברמת דיוק גבוהה.
יכולות חדשות ומשופרות:
- 4K ועיבוד טקסט: יצירת טקסט ודיאגרמות חדים וקריאים ברזולוציות של עד 2K ו-4K.
- יצירה מבוססת-קרקע: אפשר להשתמש בכלי
google_searchכדי לאמת עובדות וליצור תמונות שמבוססות על מידע מהעולם האמיתי. Grounding עם חיפוש תמונות ב-Google זמין ל-Gemini 3.1 Flash Image. - עריכה בממשק שיחה: עריכת תמונות בכמה שלבים פשוט על ידי בקשת שינויים (למשל, "הפוך את הרקע לשקיעה"). תהליך העבודה הזה מסתמך על חתימות מחשבה כדי לשמור על ההקשר החזותי בין התורות.
פרטים מלאים על יחסי גובה-רוחב, תהליכי עריכה ואפשרויות הגדרה זמינים במדריך ליצירת תמונות.
Python
# This will only work for SDK newer than 2.0.0
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
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
// This will only work for SDK newer than 2.0.0
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"
}
});
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
# Specifies the API revision to avoid breaking changes when they become default
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"
}
}'
דוגמה לתשובה

ביצוע קוד עם תמונות
Gemini 3 Flash יכול להתייחס לראייה כאל חקירה פעילה, ולא רק כאל מבט סטטי. באמצעות שילוב של חשיבה רציונלית עם הרצת קוד, המודל מגבש תוכנית, ואז כותב ומריץ קוד Python כדי להגדיל את התצוגה, לחתוך, להוסיף הערות או לבצע מניפולציות אחרות בתמונות, שלב אחר שלב, כדי לעגן את התשובות שלו באופן ויזואלי.
תרחישים לדוגמה:
- התקרבות ובדיקה: המודל מזהה באופן מובנה מתי הפרטים קטנים מדי (למשל, קריאת מד מרחק או מספר סידורי) וכותב קוד לחיתוך ולבדיקה מחדש של האזור ברזולוציה גבוהה יותר.
- מתמטיקה והצגה גרפית: המודל יכול לבצע חישובים מרובי-שלבים באמצעות קוד (למשל, סיכום פריטים בחשבונית או יצירת תרשים Matplotlib מנתונים שחולצו).
- הערות לתמונות: המודל יכול לצייר חצים, תיבות תוחמות או הערות אחרות ישירות על תמונות כדי לענות על שאלות שקשורות למיקום, כמו "איפה צריך למקם את הפריט הזה?".
כדי להפעיל חשיבה ויזואלית, צריך להגדיר את הפעלת קוד ככלי. המודל ישתמש אוטומטית בקוד כדי לערוך תמונות כשצריך.
Python
# This will only work for SDK newer than 2.0.0
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
// This will only work for SDK newer than 2.0.0
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
# Specifies the API revision to avoid breaking changes when they become default
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"}]
}'
מידע נוסף על הרצת קוד עם תמונות זמין במאמר בנושא הרצת קוד.
תשובות של פונקציות מרובות מצבים
בקשות להפעלת פונקציות מולטי-מודאליות מאפשרות למשתמשים לקבל תשובות לפונקציות שמכילות אובייקטים מולטי-מודאליים, וכך לשפר את השימוש ביכולות של המודל להפעלת פונקציות. קריאה רגילה לפונקציות תומכת רק בתשובות לפונקציות שמבוססות על טקסט:
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]
)
model_output_step = next(s for s in interaction_2.steps if s.type == "model_output")
print(f"\nFinal model response: {model_output_step.content[0].text}")
JavaScript
// This will only work for SDK newer than 2.0.0
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: 'Use the get_image tool to 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',
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.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' \
# -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)
# Specifies the API revision to avoid breaking changes when they become default
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"'"
}
]
}]
}'
שילוב של כלים מובנים וקריאות לפונקציות
Gemini 3 מאפשר שימוש בכלים מובנים (כמו חיפוש Google, הקשר של כתובת URL ועוד) ובכלים מותאמים אישית של בקשות להפעלת פונקציות באותה קריאה ל-API, וכך מאפשר תהליכי עבודה מורכבים יותר.
Python
# This will only work for SDK newer than 2.0.0
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
],
)
# 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=[
{"type": "google_search"},
getWeather
],
previous_interaction_id=interaction.id,
)
print(final_interaction.steps[-1].content[0].text)
JavaScript
// This will only work for SDK newer than 2.0.0
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
],
});
// 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: [
{ type: "google_search" },
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. Maps grounding נתמך עכשיו גם במודלים של Gemini 3.
תאימות ל-OpenAI
למשתמשים שמשתמשים בשכבת התאימות של OpenAI, פרמטרים רגילים (reasoning_effort של OpenAI) ממופים אוטומטית למקבילים ב-Gemini (thinking_level).
שיטות מומלצות לכתיבת הנחיות
Gemini 3 הוא מודל חשיבה רציונלית, ולכן צריך לשנות את ההנחיות שנותנים לו.
- הוראות מדויקות: כדאי לנסח את ההנחיות בצורה תמציתית. כדי לקבל את התשובות הכי טובות מ-Gemini 3, מומלץ לתת לו הוראות ברורות וישירות. יכול להיות שהיא תנתח יתר על המידה טכניקות מפורטות או מורכבות מדי של הנדסת הנחיות שמשמשות מודלים ישנים יותר.
- פירוט הפלט: כברירת מחדל, Gemini 3 פחות מפורט ומעדיף לספק תשובות ישירות ויעילות. אם התרחיש לדוגמה שלכם מחייב אישיות יותר שיחתית או "פטפטנית", אתם צריכים להנחות את המודל באופן מפורש בהנחיה (לדוגמה, "תסביר את זה בתור עוזר ידידותי ופטפטן").
- ניהול הקשר: כשעובדים עם מערכי נתונים גדולים (למשל, ספרים שלמים, בסיסי קוד או סרטונים ארוכים), כדאי למקם את ההוראות או השאלות הספציפיות בסוף ההנחיה, אחרי הקשר של הנתונים. כדי שההסקה של המודל תתבסס על הנתונים שסיפקתם, כדאי להתחיל את השאלה בניסוח כמו "בהתבסס על המידע שלמעלה...".
מידע נוסף על אסטרטגיות לעיצוב הנחיות זמין במדריך להנדסת הנחיות.
שאלות נפוצות
מהו תאריך סף הידע של Gemini 3? למודלים של Gemini 3 יש תאריך סף ידע של ינואר 2025. כדי לקבל מידע עדכני יותר, אפשר להשתמש בכלי הארקה של חיפוש.
מהן המגבלות של חלון ההקשר? מודלים של Gemini 3 תומכים בחלון הקשר של מיליון טוקנים לקלט ועד 64 אלף טוקנים לפלט.
יש תוכנית בחינם ל-Gemini 3? Gemini 3 Flash
gemini-3-flash-previewכולל רמת שימוש חינמית ב-Gemini API. אתם יכולים לנסות את Gemini 3.1 Pro ו-3 Flash בחינם ב-Google AI Studio, אבל אין רמת מינוי בחינם ל-gemini-3.1-pro-previewב-Gemini API.האם קוד
thinking_budgetהישן שלי ימשיך לפעול? כן,thinking_budgetעדיין נתמך לצורך תאימות לאחור, אבל מומלץ לעבור ל-thinking_levelכדי לקבל ביצועים צפויים יותר. אל תשתמשו בשניהם באותה בקשה.האם Gemini 3 תומך ב-Batch API? כן, Gemini 3 תומך ב-Batch API.
האם יש תמיכה בשמירת מטמון של הקשר? כן, שמירת ההקשר במטמון נתמכת ב-Gemini 3.
אילו כלים נתמכים ב-Gemini 3? Gemini 3 תומך בחיפוש Google, בעיגון בעזרת מפות Google, בחיפוש קבצים, בהרצת קוד ובהקשר של כתובת URL. הוא תומך גם בקריאה לפונקציות סטנדרטית עבור כלים מותאמים אישית משלכם, וגם בשילוב עם כלים מובנים.
מה זה
gemini-3.1-pro-preview-customtools? אם אתם משתמשים ב-gemini-3.1-pro-previewוהמודל מתעלם מהכלים המותאמים אישית שלכם ומעדיף פקודות bash, נסו להשתמש במודלgemini-3.1-pro-preview-customtools. מידע נוסף [כאן][customtools-model].