راهنمای توسعهدهندگان جمینی ۳
جمینی ۳ هوشمندترین خانواده مدل ما تا به امروز است که بر پایه استدلال پیشرفته ساخته شده است. این مدل به گونهای طراحی شده است که با تسلط بر گردشهای کاری عاملمحور، کدنویسی خودکار و وظایف پیچیده چندوجهی، هر ایدهای را به واقعیت تبدیل کند. این راهنما ویژگیهای کلیدی خانواده مدل جمینی ۳ و نحوه بهرهبرداری هرچه بیشتر از آن را پوشش میدهد.
مجموعه برنامههای Gemini 3 ما را بررسی کنید تا ببینید که چگونه این مدل، استدلال پیشرفته، کدنویسی خودکار و وظایف پیچیده چندوجهی را مدیریت میکند.
با چند خط کد شروع کنید:
پایتون
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)
جاوا اسکریپت
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();
استراحت
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 Pro Image نیز شناخته میشود) مدل تولید تصویر با بالاترین کیفیت ما است و نانو بنانا ۲ (که با نام Gemini 3.1 Flash Image نیز شناخته میشود) معادل آن با حجم بالا، راندمان بالا و قیمت پایینتر است.
Gemini 3.1 Flash-Lite مدل قدرتمند ما است که برای مدلهای مقرونبهصرفه و کارهای با حجم بالا ساخته شده است.
تمام مدلهای Gemini 3 در حال حاضر در مرحله پیشنمایش هستند.
| شناسه مدل | پنجره زمینه (ورودی/خروجی) | حد دانش | قیمتگذاری (ورودی / خروجی)* |
|---|---|---|---|
| پیشنمایش gemini 3.1-flash-lite | ۱ میلیون / ۶۴ هزار | ژانویه ۲۰۲۵ | ۰.۲۵ دلار (متن، تصویر، ویدیو)، ۰.۵۰ دلار (صوتی) / ۱.۵۰ دلار |
| پیشنمایش تصویر فلش جمینی ۳.۱ | ۱۲۸ هزار / ۳۲ هزار | ژانویه ۲۰۲۵ | $0.25 (ورودی متن) / $0.067 (خروجی تصویر)** |
| پیشنمایش gemini 3.1 pro | ۱ میلیون / ۶۴ هزار | ژانویه ۲۰۲۵ | ۲ دلار / ۱۲ دلار (کمتر از ۲۰۰ هزار توکن) ۴ دلار / ۱۸ دلار (بیش از ۲۰۰ هزار توکن) |
| پیشنمایش gemini-3-flash | ۱ میلیون / ۶۴ هزار | ژانویه ۲۰۲۵ | ۰.۵۰ دلار / ۳ دلار |
| پیشنمایش تصویر gemini 3 pro | ۶۵ هزار / ۳۲ هزار | ژانویه ۲۰۲۵ | $2 (ورودی متن) / $0.134 (خروجی تصویر)** |
* قیمتگذاری به ازای هر ۱ میلیون توکن است، مگر اینکه خلاف آن ذکر شده باشد. ** قیمتگذاری تصویر بر اساس وضوح تصویر متفاوت است. برای جزئیات بیشتر به صفحه قیمتگذاری مراجعه کنید.
برای اطلاع از جزئیات محدودیتها، قیمتگذاری و اطلاعات بیشتر، به صفحه مدلها مراجعه کنید.
ویژگیهای جدید API در Gemini 3
Gemini 3 پارامترهای جدیدی را معرفی میکند که برای کنترل بیشتر توسعهدهندگان بر تأخیر، هزینه و وفاداری چندوجهی طراحی شدهاند.
سطح تفکر
مدلهای سری Gemini 3 به طور پیشفرض از تفکر پویا برای استدلال از طریق دستورالعملها استفاده میکنند. میتوانید از پارامتر thinking_level استفاده کنید که حداکثر عمق فرآیند استدلال داخلی مدل را قبل از تولید پاسخ کنترل میکند. Gemini 3 این سطوح را به عنوان مجوزهای نسبی برای تفکر در نظر میگیرد، نه به عنوان تضمینهای دقیق توکن.
اگر thinking_level مشخص نشده باشد، Gemini 3 به طور پیشفرض روی high تنظیم میشود. برای پاسخهای سریعتر و با تأخیر کمتر، زمانی که استدلال پیچیده مورد نیاز نیست، میتوانید سطح تفکر مدل را روی low محدود کنید.
| سطح تفکر | جمینی ۳.۱ پرو | جمینی ۳.۱ فلش-لایت | فلش جمینی ۳ | توضیحات |
|---|---|---|---|---|
minimal | پشتیبانی نمیشود | پشتیبانیشده (پیشفرض) | پشتیبانی شده | برای اکثر پرسوجوها با تنظیمات «بدون تفکر» مطابقت دارد. مدل ممکن است برای وظایف کدنویسی پیچیده بسیار مینیمال فکر کند. تأخیر را برای چت یا برنامههای با توان عملیاتی بالا به حداقل میرساند. توجه داشته باشید، minimal تضمین نمیکند که تفکر غیرفعال باشد. |
low | پشتیبانی شده | پشتیبانی شده | پشتیبانی شده | تأخیر و هزینه را به حداقل میرساند. بهترین گزینه برای دنبال کردن دستورالعملهای ساده، چت یا برنامههای کاربردی با توان عملیاتی بالا. |
medium | پشتیبانی شده | پشتیبانی شده | پشتیبانی شده | تفکر متعادل برای اکثر وظایف. |
high | پشتیبانیشده (پیشفرض، پویا) | پشتیبانی شده (پویا) | پشتیبانیشده (پیشفرض، پویا) | عمق استدلال را به حداکثر میرساند. ممکن است مدل برای رسیدن به اولین نشانه خروجی (غیر تفکری) به طور قابل توجهی زمان بیشتری صرف کند، اما خروجی با دقت بیشتری استدلال خواهد شد. |
پایتون
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)
جاوا اسکریپت
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);
استراحت
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 برای تنظیم پیشفرض بهینه شدهاند. تغییر دما (تنظیم آن زیر ۱.۰) ممکن است منجر به رفتار غیرمنتظرهای مانند حلقه زدن یا کاهش عملکرد، به ویژه در کارهای پیچیده ریاضی یا استدلالی شود.
امضاهای فکری
مدلهای Gemini 3 از امضاهای فکری برای حفظ زمینه استدلال در سراسر فراخوانیهای API استفاده میکنند. این امضاها، نمایشهای رمزگذاریشده از فرآیند تفکر داخلی مدل هستند.
- حالت Stateful (توصیه شده) : هنگام استفاده از Interactions API در حالت Stateful (با ارائه
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 به شما امکان میدهند خروجیهای ساختاریافته را با ابزارهای داخلی، از جمله Grounding with Google Search ، URL Context ، Code Execution و Function Calling، ترکیب کنید.
پایتون
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)
جاوا اسکریپت
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();
استراحت
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"]
}
}
}'
تولید تصویر
نرمافزارهای Gemini 3.1 Flash Image و Gemini 3 Pro Image به شما امکان میدهند تصاویر را از متنهای پیشنهادی تولید و ویرایش کنید. این نرمافزار از استدلال برای «فکر کردن» در مورد یک متن پیشنهادی استفاده میکند و میتواند دادههای بلادرنگ - مانند پیشبینی آب و هوا یا نمودارهای سهام - را قبل از استفاده از جستجوی گوگل و قبل از تولید تصاویر با کیفیت بالا، بازیابی کند.
قابلیتهای جدید و بهبود یافته:
- رندر متن و کیفیت 4K: متن و نمودارهای واضح و خوانا را با وضوح حداکثر 2K و 4K تولید کنید.
- تولید تصویر به صورت زمینی: از ابزار
google_searchبرای تأیید حقایق و تولید تصاویر بر اساس اطلاعات دنیای واقعی استفاده کنید. تولید تصویر به صورت زمینی با جستجوی تصویر گوگل برای تصویر فلش Gemini 3.1 در دسترس است. - ویرایش محاورهای: ویرایش تصویر چند مرحلهای با درخواست تغییرات ساده (مثلاً «پسزمینه را به غروب آفتاب تبدیل کنید»). این گردش کار برای حفظ زمینه بصری بین نوبتها به Thought Signatures متکی است.
برای جزئیات کامل در مورد نسبتهای ابعاد، گردشهای کاری ویرایش و گزینههای پیکربندی، به راهنمای تولید تصویر مراجعه کنید.
پایتون
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()
جاوا اسکریپت
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();
استراحت
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 میتواند بینایی را به عنوان یک بررسی فعال، نه فقط یک نگاه ایستا، در نظر بگیرد. با ترکیب استدلال با اجرای کد ، مدل یک طرح را تدوین میکند، سپس کد پایتون را برای بزرگنمایی، برش، حاشیهنویسی یا دستکاری گام به گام تصاویر مینویسد و اجرا میکند تا پاسخهای خود را به صورت بصری ارائه دهد.
موارد استفاده:
- بزرگنمایی و بازرسی: این مدل به طور ضمنی تشخیص میدهد که جزئیات چه زمانی خیلی کوچک هستند (مثلاً خواندن یک گیج یا شماره سریال از راه دور) و کدی را برای برش و بررسی مجدد ناحیه با وضوح بالاتر مینویسد.
- محاسبات و ترسیم بصری: این مدل میتواند محاسبات چند مرحلهای را با استفاده از کد انجام دهد (مثلاً جمع کردن اقلام خط روی رسید یا تولید نمودار Matplotlib از دادههای استخراج شده).
- حاشیهنویسی تصویر: مدل میتواند فلشها، کادرهای محدودکننده یا سایر حاشیهنویسیها را مستقیماً روی تصاویر رسم کند تا به سؤالات مکانی مانند «این مورد کجا باید قرار گیرد؟» پاسخ دهد.
برای فعال کردن تفکر بصری، اجرای کد را به عنوان یک ابزار پیکربندی کنید. مدل به طور خودکار از کد برای دستکاری تصاویر در صورت نیاز استفاده خواهد کرد.
پایتون
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)
جاوا اسکریپت
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();
استراحت
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": {}}]
}'
برای جزئیات بیشتر در مورد اجرای کد با تصاویر، به بخش اجرای کد مراجعه کنید.
پاسخهای تابع چندوجهی
فراخوانی تابع چندوجهی به کاربران این امکان را میدهد که پاسخهای تابعی حاوی اشیاء چندوجهی داشته باشند که امکان استفاده بهتر از قابلیتهای فراخوانی تابع مدل را فراهم میکند. فراخوانی تابع استاندارد فقط از پاسخهای تابع مبتنی بر متن پشتیبانی میکند:
پایتون
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}")
جاوا اسکریپت
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}`);
استراحت
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 امکان استفاده از ابزارهای داخلی (مانند جستجوی گوگل، متن URL و موارد دیگر ) و ابزارهای فراخوانی تابع سفارشی را در همان فراخوانی API فراهم میکند و امکان گردشهای کاری پیچیدهتری را فراهم میکند.
پایتون
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)
جاوا اسکریپت
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 را با
thinking_level: "high"و دستورالعملهای سادهشده امتحان کنید. - تنظیمات دما: اگر کد موجود شما صریحاً دما را تنظیم میکند (بهویژه برای خروجیهای قطعی روی مقادیر پایین)، توصیه میکنیم این پارامتر را حذف کرده و از مقدار پیشفرض ۱.۰ در Gemini 3 استفاده کنید تا از مشکلات احتمالی حلقه یا کاهش عملکرد در کارهای پیچیده جلوگیری شود.
- درک PDF و اسناد: اگر برای تجزیه و تحلیل متراکم اسناد به رفتار خاصی متکی هستید، تنظیم جدید
media_resolution_highرا آزمایش کنید تا از دقت مداوم آن اطمینان حاصل شود. - مصرف توکن: مهاجرت به پیشفرضهای Gemini 3 ممکن است استفاده از توکن را برای فایلهای PDF افزایش دهد اما استفاده از توکن را برای ویدیو کاهش دهد . اگر درخواستها اکنون به دلیل وضوح پیشفرض بالاتر از پنجره زمینه فراتر میروند، توصیه میکنیم وضوح رسانه را به صراحت کاهش دهید.
- تقسیمبندی تصویر: قابلیتهای تقسیمبندی تصویر (بازگرداندن ماسکهای سطح پیکسل برای اشیاء) در Gemini 3 Pro یا Gemini 3 Flash پشتیبانی نمیشوند. برای بارهای کاری که نیاز به تقسیمبندی تصویر داخلی دارند، توصیه میکنیم به استفاده از Gemini 2.5 Flash با خاموش بودن thinking یا Gemini Robotics-ER 1.6 ادامه دهید.
- استفاده از کامپیوتر: Gemini 3 Pro و Gemini 3 Flash از ابزار استفاده از کامپیوتر پشتیبانی میکنند. برخلاف سری ۲.۵، برای دسترسی به ابزار استفاده از کامپیوتر نیازی به استفاده از مدل جداگانهای ندارید.
- پشتیبانی ابزار : ترکیب ابزارهای داخلی با فراخوانی تابع اکنون برای مدلهای Gemini 3 پشتیبانی میشود. همچنین اتصال به زمین نقشهها نیز اکنون برای مدلهای Gemini 3 پشتیبانی میشود.
سازگاری با OpenAI
برای کاربرانی که از لایه سازگاری OpenAI استفاده میکنند، پارامترهای استاندارد ( reasoning_effort مربوط به OpenAI ) به طور خودکار به معادلهای Gemini ( thinking_level ) نگاشت میشوند.
ارائه بهترین شیوهها
جمینی ۳ یک مدل استدلال است که نحوهی ارائهی پیشنهاد را تغییر میدهد.
- دستورالعملهای دقیق: در دستورالعملهای ورودی خود مختصر باشید. Gemini 3 به دستورالعملهای مستقیم و واضح بهترین پاسخ را میدهد. ممکن است تکنیکهای مهندسی دستورالعمل طولانی یا بیش از حد پیچیده مورد استفاده در مدلهای قدیمی را بیش از حد تجزیه و تحلیل کند.
- حجم خروجی: به طور پیشفرض، Gemini 3 کمتر حجم خروجی دارد و ترجیح میدهد پاسخهای مستقیم و کارآمد ارائه دهد. اگر مورد استفاده شما نیاز به یک شخصیت محاورهای یا "پرحرف" دارد، باید صریحاً مدل را در اعلان هدایت کنید (مثلاً "این را به عنوان یک دستیار دوستانه و پرحرف توضیح دهید").
- مدیریت زمینه: هنگام کار با مجموعه دادههای بزرگ (مثلاً کل کتابها، پایگاههای کد یا ویدیوهای طولانی)، دستورالعملها یا سوالات خاص خود را در انتهای دستور، پس از زمینه دادهها قرار دهید. با شروع سوال خود با عبارتی مانند «براساس اطلاعات قبلی...»، استدلال مدل را به دادههای ارائه شده متصل کنید.
در راهنمای مهندسی سریع، درباره استراتژیهای طراحی سریع بیشتر بیاموزید.
سوالات متداول
حد نهایی دانش برای Gemini 3 چیست؟ مدلهای Gemini 3 دارای حد نهایی دانش ژانویه 2025 هستند. برای اطلاعات جدیدتر، از ابزار Search Grounding استفاده کنید.
محدودیتهای پنجره زمینه چیست؟ مدلهای Gemini 3 از یک پنجره زمینه ورودی ۱ میلیون توکن و تا ۶۴ هزار توکن خروجی پشتیبانی میکنند.
آیا نسخه رایگانی برای Gemini 3 وجود دارد؟ Gemini 3 Flash
gemini-3-flash-previewدر رابط برنامهنویسی Gemini یک نسخه رایگان دارد. میتوانید Gemini 3.1 Pro و 3 Flash را به صورت رایگان در Google AI Studio امتحان کنید، اما هیچ نسخه رایگانی برایgemini-3.1-pro-previewدر رابط برنامهنویسی Gemini وجود ندارد.آیا کد قدیمی
thinking_budgetمن هنوز کار خواهد کرد؟ بله،thinking_budgetهنوز برای سازگاری با نسخههای قبلی پشتیبانی میشود، اما برای عملکرد قابل پیشبینیتر، توصیه میکنیم بهthinking_levelمهاجرت کنید. از هر دو در یک درخواست استفاده نکنید.آیا جمینی ۳ از Batch API پشتیبانی میکند؟ بله، جمینی ۳ از Batch API پشتیبانی میکند.
آیا از ذخیرهسازی زمینه (Context Caching) پشتیبانی میشود؟ بله، ذخیرهسازی زمینه برای Gemini 3 پشتیبانی میشود.
کدام ابزارها در Gemini 3 پشتیبانی میشوند؟ Gemini 3 از جستجوی گوگل ، اتصال به زمین با نقشههای گوگل ، جستجوی فایل ، اجرای کد و متن URL پشتیبانی میکند. همچنین از فراخوانی تابع استاندارد برای ابزارهای سفارشی شما و در ترکیب با ابزارهای داخلی پشتیبانی میکند.
gemini-3.1-pro-preview-customtoolsچیست؟ اگر ازgemini-3.1-pro-previewاستفاده میکنید و مدل، ابزارهای سفارشی شما را به نفع دستورات bash نادیده میگیرد، به جای آن مدلgemini-3.1-pro-preview-customtoolsرا امتحان کنید. اطلاعات بیشتر اینجا .