Repository Public
1# Gemini 3 Developer Guide23> [!NOTE]4> **Note** : This version of the page covers the new [Interactions API](https://ai.google.dev/gemini-api/docs/interactions/interactions-overview), which is currently in Beta. 5> For stable production deployments, we recommend you continue to use the `generateContent` API. You can use the toggle on this page to switch between the versions.67> [!CAUTION]8> **Deprecation notice:** This page is deprecated and will be removed. See the [What's new9> in Gemini 3.5 Flash](https://ai.google.dev/gemini-api/docs/interactions/whats-new-gemini-3.5) guide for the latest developer guidance, including migration instructions, prompting best practices, and an updated feature overview for all Gemini 3.x models.1011Gemini 3 is our most intelligent model family to date, built on a foundation of12state-of-the-art reasoning. It is designed to bring any idea to life by13mastering agentic workflows, autonomous coding, and complex multimodal tasks.14This guide covers key features of the Gemini 3 model family and how to get the15most out of it.1617Explore our [collection of Gemini 3 apps](https://aistudio.google.com/app/apps?source=showcase&showcaseTag=gemini-3) to18see how the model handles advanced reasoning, autonomous coding, and complex19multimodal tasks.2021Get started with a few lines of code:2223### Python2425 from google import genai2627 client = genai.Client()2829 interaction = client.interactions.create(30 model="gemini-3.1-pro-preview",31 input="Find the race condition in this multi-threaded C++ snippet: [code here]",32 )3334 print(interaction.output_text)3536### JavaScript3738 import { GoogleGenAI } from "@google/genai";3940 const client = new GoogleGenAI({});4142 async function run() {43 const interaction = await client.interactions.create({44 model: "gemini-3.1-pro-preview",45 input: "Find the race condition in this multi-threaded C++ snippet: [code here]",46 });4748 console.log(interaction.output_text);49 }5051 run();5253### REST5455 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \56 -H "x-goog-api-key: $GEMINI_API_KEY" \57 -H 'Content-Type: application/json' \58 -H "Api-Revision: 2026-05-20" \59 -d '{60 "model": "gemini-3.1-pro-preview",61 "input": "Find the race condition in this multi-threaded C++ snippet: [code here]"62 }'6364## Meet the Gemini 3 series6566Gemini 3.1 Pro is best for complex tasks that67require broad world knowledge and advanced reasoning across modalities.6869Gemini 3 Flash is our latest 3-series model, with Pro-level intelligence at the70speed and pricing of Flash.7172Nano Banana Pro (also known as Gemini 3 Pro Image) is our highest quality image73generation model, and Nano Banana 2 (also known as Gemini 3.1 Flash Image) is74the high-volume, high-efficiency, lower price-point equivalent.7576Gemini 3.1 Flash-Lite is our workhorse model built for cost-efficiency model and77high-volume tasks.7879All Gemini 3 models are currently in preview.8081| Model ID | Context Window (In / Out) | Knowledge Cutoff | Pricing (Input / Output)\* |82|---|---|---|---|83| **gemini-3.1-flash-lite** | 1M / 64k | Jan 2025 | $0.25 (text, image, video), $0.50 (audio) / $1.50 |84| **gemini-3.1-flash-image-preview** | 128k / 32k | Jan 2025 | $0.25 (Text Input) / $0.067 (Image Output)\*\* |85| **gemini-3.1-pro-preview** | 1M / 64k | Jan 2025 | $2 / $12 (\<200k tokens) $4 / $18 (\>200k tokens) |86| **gemini-3-flash-preview** | 1M / 64k | Jan 2025 | $0.50 / $3 |87| **gemini-3-pro-image-preview** | 65k / 32k | Jan 2025 | $2 (Text Input) / $0.134 (Image Output)\*\* |8889*\* Pricing is per 1 million tokens unless otherwise noted.*90*\*\* Image pricing varies by resolution. See the [pricing page](https://ai.google.dev/gemini-api/docs/pricing) for details.*9192For detailed limits, pricing, and additional information, see the93[models page](https://ai.google.dev/gemini-api/docs/models/gemini).9495## New API features in Gemini 39697Gemini 3 introduces new parameters designed to give developers more control over98latency, cost, and multimodal fidelity.99100### Level of thinking101102Gemini 3 series models use dynamic thinking by default to reason through103prompts. You can use the `thinking_level` parameter, which controls the104**maximum** depth of the model's internal reasoning process before it produces a105response. Gemini 3 treats these levels as relative allowances for thinking106rather than strict token guarantees.107108If `thinking_level` is not specified, Gemini 3 will default to `high`. For109faster, lower-latency responses when complex reasoning isn't required, you can110constrain the model's thinking level to `low`.111112| Thinking Level | Gemini 3.1 Pro | Gemini 3.1 Flash-Lite | Gemini 3 Flash | Description |113|---|---|---|---|---|114| **`minimal`** | Not supported | Supported (Default) | Supported | Matches the "no thinking" setting for most queries. The model may think very minimally for complex coding tasks. Minimizes latency for chat or high throughput applications. Note, `minimal` does not guarantee that thinking is off. |115| **`low`** | Supported | Supported | Supported | Minimizes latency and cost. Best for simple instruction following, chat, or high-throughput applications. |116| **`medium`** | Supported | Supported | Supported | Balanced thinking for most tasks. |117| **`high`** | Supported (Default, Dynamic) | Supported (Dynamic) | Supported (Default, Dynamic) | Maximizes reasoning depth. The model may take significantly longer to reach a first (non thinking) output token, but the output will be more carefully reasoned. |118119### Python120121 from google import genai122123 client = genai.Client()124125 interaction = client.interactions.create(126 model="gemini-3.1-pro-preview",127 input="How does AI work?",128 generation_config={"thinking_level": "low"},129 )130131 print(interaction.output_text)132133### JavaScript134135 import { GoogleGenAI } from "@google/genai";136137 const client = new GoogleGenAI({});138139 const interaction = await client.interactions.create({140 model: "gemini-3.1-pro-preview",141 input: "How does AI work?",142 generation_config: {143 thinking_level: "low",144 },145 });146147 console.log(interaction.output_text);148149### REST150151 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \152 -H "x-goog-api-key: $GEMINI_API_KEY" \153 -H 'Content-Type: application/json' \154 -H "Api-Revision: 2026-05-20" \155 -d '{156 "model": "gemini-3.1-pro-preview",157 "input": "How does AI work?",158 "generation_config": {159 "thinking_level": "low"160 }161 }'162163> [!IMPORTANT]164> **Important:** You cannot use both `thinking_level` and the legacy `thinking_budget` parameter in the same request. Doing so will return a 400 error.165166### Temperature167168For all Gemini 3 models, we strongly recommend keeping the temperature parameter169at its default value of `1.0`.170171While previous models often benefited from tuning temperature to control172creativity versus determinism, Gemini 3's reasoning capabilities are optimized173for the default setting. Changing the temperature (setting it below 1.0) may174lead to unexpected behavior, such as looping or degraded performance,175particularly in complex mathematical or reasoning tasks.176177### Thought signatures178179Gemini 3 models use thought signatures to maintain reasoning context across API calls. These signatures are encrypted representations of the model's internal thought process.180181- **Stateful Mode (Recommended)** : When using the Interactions API in stateful mode (providing `previous_interaction_id`), the server automatically manages conversation history and thought signatures.182- **Stateless Mode**: If you are managing conversation history manually, you must include thought blocks with their signatures in subsequent requests to validate authenticity.183184For detailed information, see the [Thought Signatures](https://ai.google.dev/gemini-api/docs/interactions/thinking) page.\`185186### Structured Outputs with tools187188Gemini 3 models allow you to combine [Structured Outputs](https://ai.google.dev/gemini-api/docs/interactions/structured-output) with built-in tools, including189[Grounding with Google Search](https://ai.google.dev/gemini-api/docs/interactions/google-search), [URL Context](https://ai.google.dev/gemini-api/docs/interactions/url-context), [Code Execution](https://ai.google.dev/gemini-api/docs/interactions/code-execution), and [Function Calling](https://ai.google.dev/gemini-api/docs/interactions/function-calling).190191### Python192193 from google import genai194 from pydantic import BaseModel, Field195 from typing import List196197 class MatchResult(BaseModel):198 winner: str = Field(description="The name of the winner.")199 final_match_score: str = Field(description="The final match score.")200 scorers: List[str] = Field(description="The name of the scorer.")201202 client = genai.Client()203204 interaction = client.interactions.create(205 model="gemini-3.1-pro-preview",206 input="Search for all details for the latest Euro.",207 tools=[208 {"type": "google_search"},209 {"type": "url_context"}210 ],211 response_format={212 "type": "text",213 "mime_type": "application/json",214 "schema": MatchResult.model_json_schema()215 },216 )217218 result = MatchResult.model_validate_json(interaction.output_text)219 print(result)220221### JavaScript222223 import { GoogleGenAI } from "@google/genai";224 import * as z from "zod";225226 const matchJsonSchema = {227 type: "object",228 properties: {229 winner: { type: "string", description: "The name of the winner." },230 final_match_score: { type: "string", description: "The final score." },231 scorers: {232 type: "array",233 items: { type: "string" },234 description: "The name of the scorer."235 }236 },237 required: ["winner", "final_match_score", "scorers"]238 };239240 const matchSchema = z.fromJSONSchema(matchJsonSchema);241242 const client = new GoogleGenAI({});243244 async function run() {245 const interaction = await client.interactions.create({246 model: "gemini-3.1-pro-preview",247 input: "Search for all details for the latest Euro.",248 tools: [249 { type: "google_search" },250 { type: "url_context" }251 ],252 response_format: {253 type: "text",254 mime_type: "application/json",255 schema: matchJsonSchema256 },257 });258259 const match = matchSchema.parse(JSON.parse(interaction.output_text));260 console.log(match);261 }262263 run();264265### REST266267 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \268 -H "x-goog-api-key: $GEMINI_API_KEY" \269 -H 'Content-Type: application/json' \270 -H "Api-Revision: 2026-05-20" \271 -d '{272 "model": "gemini-3.1-pro-preview",273 "input": "Search for all details for the latest Euro.",274 "tools": [275 {"type": "google_search"},276 {"type": "url_context"}277 ],278 "response_format": {279 "type": "text",280 "mime_type": "application/json",281 "schema": {282 "type": "object",283 "properties": {284 "winner": {"type": "string", "description": "The name of the winner."},285 "final_match_score": {"type": "string", "description": "The final score."},286 "scorers": {287 "type": "array",288 "items": {"type": "string"},289 "description": "The name of the scorer."290 }291 },292 "required": ["winner", "final_match_score", "scorers"]293 }294 }295 }'296297### Image generation298299Gemini 3.1 Flash Image and Gemini 3 Pro Image let you generate and edit images300from text prompts. It uses301reasoning to "think" through a prompt and can retrieve real-time data---such as302weather forecasts or stock charts---before using [Google Search](https://ai.google.dev/gemini-api/docs/interactions/google-search) grounding before generating high-fidelity303images.304305**New \& improved capabilities:**306307- **4K \& text rendering:** Generate sharp, legible text and diagrams with up to 2K and 4K resolutions.308- **Grounded generation:** Use the `google_search` tool to verify facts and generate imagery based on real-world information. Grounding with Google *Image* Search available for Gemini 3.1 Flash Image.309- **Conversational editing:** Multi-turn image editing by simply asking for changes (e.g., "Make the background a sunset"). This workflow relies on **Thought Signatures** to preserve visual context between turns.310311For complete details on aspect ratios, editing workflows, and configuration312options, see the [Image Generation guide](https://ai.google.dev/gemini-api/docs/interactions/image-generation).313314### Python315316 from google import genai317 import base64318319 client = genai.Client()320321 interaction = client.interactions.create(322 model="gemini-3-pro-image-preview",323 input="Generate an infographic of the current weather in Tokyo.",324 tools=[{"type": "google_search"}],325 response_format={326 "type": "image",327 "aspect_ratio": "16:9",328 "image_size": "4K"329 }330 )331332 from PIL import Image333 import io334335 generated_image = interaction.output_image336 if generated_image:337 image_data = base64.b64decode(generated_image.data)338 image = Image.open(io.BytesIO(image_data))339 image.save('weather_tokyo.png')340 image.show()341342### JavaScript343344 import { GoogleGenAI } from "@google/genai";345 import * as fs from "node:fs";346347 const client = new GoogleGenAI({});348349 async function run() {350 const interaction = await client.interactions.create({351 model: "gemini-3-pro-image-preview",352 input: "Generate a visualization of the current weather in Tokyo.",353 tools: [{ type: "google_search" }],354 response_format: {355 type: "image",356 aspect_ratio: "16:9",357 image_size: "4K"358 }359 });360361 const buffer = Buffer.from(interaction.output_image.data, 'base64');362363 fs.writeFileSync('weather_tokyo.png', buffer);364 }365366 run();367368### REST369370 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \371 -H "x-goog-api-key: $GEMINI_API_KEY" \372 -H 'Content-Type: application/json' \373 -H "Api-Revision: 2026-05-20" \374 -d '{375 "model": "gemini-3-pro-image-preview",376 "input": "Generate a visualization of the current weather in Tokyo.",377 "tools": [{"type": "google_search"}],378 "response_format": {379 "type": "image",380 "aspect_ratio": "16:9",381 "image_size": "4K"382 }383 }'384385**Example Response**386387388389### Code Execution with images390391Gemini 3 Flash can treat vision as an active investigation, not just a static392glance. By combining reasoning with [code execution](https://ai.google.dev/gemini-api/docs/interactions/code-execution), the model formulates a plan, then writes and393executes Python code to zoom in, crop, annotate, or otherwise manipulate images394step-by-step to visually ground its answers.395396**Use cases:**397398- **Zoom and inspect:** The model implicitly detects when details are too small (e.g., reading a distant gauge or serial number) and writes code to crop and re-examine the area at higher resolution.399- **Visual math and plotting:** The model can run multi-step calculations using code (e.g., summing line items on a receipt, or generating a Matplotlib chart from extracted data).400- **Image annotation:** The model can draw arrows, bounding boxes, or other annotations directly onto images to answer spatial questions like "Where should this item go?".401402To enable visual thinking, configure [Code Execution](https://ai.google.dev/gemini-api/docs/interactions/code-execution) as a tool. The model will automatically use403code to manipulate images when needed.404405### Python406407 from google import genai408 from google.genai import types409 import requests410 from PIL import Image411 import io412 import base64413414 image_path = "https://goo.gle/instrument-img"415 image_bytes = requests.get(image_path).content416 image = types.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")417418 client = genai.Client()419420 interaction = client.interactions.create(421 model="gemini-3-flash-preview",422 input=[423 image,424 "Zoom into the expression pedals and tell me how many pedals are there?"425 ],426 tools=[{"type": "code_execution"}],427 )428429 from IPython.display import display430 from PIL import Image431 import io432433 for step in interaction.steps:434 if step.type == "model_output":435 for content_block in step.content:436 if content_block.type == "text":437 print(content_block.text)438 elif content_block.type == "image":439 display(Image.open(io.BytesIO(base64.b64decode(content_block.data))))440 elif step.type == "code_execution_call":441 print(step.code)442 elif step.type == "code_execution_result":443 print(step.output)444445### JavaScript446447 import { GoogleGenAI } from "@google/genai";448449 const client = new GoogleGenAI({});450451 async function main() {452 const imageUrl = "https://goo.gle/instrument-img";453 const response = await fetch(imageUrl);454 const imageArrayBuffer = await response.arrayBuffer();455 const base64ImageData = Buffer.from(imageArrayBuffer).toString("base64");456457 const interaction = await client.interactions.create({458 model: "gemini-3-flash-preview",459 input: [460 {461 type: "image",462 mime_type: "image/jpeg",463 data: base64ImageData,464 },465 {466 type: "text",467 text: "Zoom into the expression pedals and tell me how many pedals are there?",468 },469 ],470 tools: [{ type: "code_execution" }],471 });472473 for (const step of interaction.steps) {474 if (step.type === "model_output") {475 for (const contentBlock of step.content) {476 if (contentBlock.type === "text") {477 console.log("Text:", contentBlock.text);478 }479 }480 } else if (step.type === "code_execution_call") {481 console.log("Code:", step.code);482 } else if (step.type === "code_execution_result") {483 console.log("Output:", step.output);484 }485 }486 }487488 main();489490### REST491492 IMG_URL="https://goo.gle/instrument-img"493 MODEL="gemini-3-flash-preview"494495 MIME_TYPE=$(curl -sIL "$IMG_URL" | grep -i '^content-type:' | awk -F ': ' '{print $2}' | sed 's/\r$//' | head -n 1)496 if [[ -z "$MIME_TYPE" || ! "$MIME_TYPE" == image/* ]]; then497 MIME_TYPE="image/jpeg"498 fi499500 if [[ "$(uname)" == "Darwin" ]]; then501 IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -b 0)502 elif [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then503 IMAGE_B64=$(curl -sL "$IMG_URL" | base64)504 else505 IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -w0)506 fi507508 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \509 -H "x-goog-api-key: $GEMINI_API_KEY" \510 -H 'Content-Type: application/json' \511 -H "Api-Revision: 2026-05-20" \512 -d '{513 "model": "'$MODEL'",514 "input": [515 {516 "type": "image",517 "mime_type":"'"$MIME_TYPE"'",518 "data": "'"$IMAGE_B64"'"519 },520 {"type": "text", "text": "Zoom into the expression pedals and tell me how many pedals are there?"}521 ],522 "tools": [{"type": "code_execution"}]523 }'524525For more details on code execution with images, see [Code Execution](https://ai.google.dev/gemini-api/docs/interactions/code-execution#images).526527### Multimodal function responses528529[Multimodal function calling](https://ai.google.dev/gemini-api/docs/interactions/function-calling#multimodal)530allows users to have function responses containing531multimodal objects allowing for improved utilization of function calling532capabilities of the model. Standard function calling only supports text-based533function responses:534535### Python536537 # This will only work for SDK newer than 2.0.0538 from google import genai539 import requests540 import base64541542 client = genai.Client()543544 # 1. Define the tool545 get_image_tool = {546 "type": "function",547 "name": "get_image",548 "description": "Retrieves the image file reference for a specific order item.",549 "parameters": {550 "type": "object",551 "properties": {552 "item_name": {553 "type": "string",554 "description": "The name or description of the item ordered (e.g., 'instrument')."555 }556 },557 "required": ["item_name"],558 },559 }560561 # 2. Send the request with tools562 interaction_1 = client.interactions.create(563 model="gemini-3-flash-preview",564 input="Show me the instrument I ordered last month.",565 tools=[get_image_tool],566 )567568 # 3. Find the function call step569 fc_step = next(s for s in interaction_1.steps if s.type == "function_call")570 print(f"Tool Call: {fc_step.name}({fc_step.arguments})")571572 # Execute tool (fetch image)573 image_path = "https://goo.gle/instrument-img"574 image_bytes = requests.get(image_path).content575 image_b64 = base64.b64encode(image_bytes).decode("utf-8")576577 # 4. Send multimodal function result back578 interaction_2 = client.interactions.create(579 model="gemini-3-flash-preview",580 previous_interaction_id=interaction_1.id,581 input=[{582 "type": "function_result",583 "name": fc_step.name,584 "call_id": fc_step.id,585 "result": [586 {"type": "text", "text": "instrument.jpg"},587 {588 "type": "image",589 "mime_type": "image/jpeg",590 "data": image_b64,591 }592 ]593 }],594 tools=[get_image_tool]595 )596597 print(f"\nFinal model response: {interaction_2.output_text}")598599### JavaScript600601 import { GoogleGenAI } from '@google/genai';602603 const client = new GoogleGenAI({});604605 const getImageTool = {606 type: 'function',607 name: 'get_image',608 description: 'Retrieves the image file reference for a specific order item.',609 parameters: {610 type: 'object',611 properties: {612 item_name: {613 type: 'string',614 description: "The name or description of the item ordered (e.g., 'instrument').",615 },616 },617 required: ['item_name'],618 },619 };620621 const interaction1 = await client.interactions.create({622 model: 'gemini-3-flash-preview',623 input: 'Use the get_image tool to show me the instrument I ordered last month.',624 tools: [getImageTool],625 });626627 const fcStep = interaction1.steps.find(s => s.type === 'function_call');628 console.log(`Tool Call: ${fcStep.name}(${JSON.stringify(fcStep.arguments)})`);629630 const imageUrl = 'https://goo.gle/instrument-img';631 const response = await fetch(imageUrl);632 const imageArrayBuffer = await response.arrayBuffer();633 const base64ImageData = Buffer.from(imageArrayBuffer).toString('base64');634635 const interaction2 = await client.interactions.create({636 model: 'gemini-3-flash-preview',637 previous_interaction_id: interaction1.id,638 input: [{639 type: 'function_result',640 name: fcStep.name,641 call_id: fcStep.id,642 result: [643 { type: 'text', text: 'instrument.jpg' },644 {645 type: 'image',646 mime_type: 'image/jpeg',647 data: base64ImageData,648 }649 ]650 }],651 tools: [getImageTool]652 });653654 console.log(`\nFinal model response: ${interaction2.output_text}`);655656### REST657658 IMG_URL="https://goo.gle/instrument-img"659660 MIME_TYPE=$(curl -sIL "$IMG_URL" | grep -i '^content-type:' | awk -F ': ' '{print $2}' | sed 's/\r$//' | head -n 1)661 if [[ -z "$MIME_TYPE" || ! "$MIME_TYPE" == image/* ]]; then662 MIME_TYPE="image/jpeg"663 fi664665 # Check for macOS666 if [[ "$(uname)" == "Darwin" ]]; then667 IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -b 0)668 elif [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then669 IMAGE_B64=$(curl -sL "$IMG_URL" | base64)670 else671 IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -w0)672 fi673674 # 1. First interaction (triggers function call)675 # curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \676 # -H "x-goog-api-key: $GEMINI_API_KEY" \677 # -H 'Content-Type: application/json' \678 # -H "Api-Revision: 2026-05-20" \679 # -d '{ "model": "gemini-3-flash-preview", "input": "Show me the instrument I ordered last month.", "tools": [...] }'680681 # 2. Send multimodal function result back (Replace INTERACTION_ID and CALL_ID)682 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \683 -H "x-goog-api-key: $GEMINI_API_KEY" \684 -H 'Content-Type: application/json' \685 -H "Api-Revision: 2026-05-20" \686 -d '{687 "model": "gemini-3-flash-preview",688 "previous_interaction_id": "INTERACTION_ID",689 "input": [{690 "type": "function_result",691 "name": "get_image",692 "call_id": "CALL_ID",693 "result": [694 { "type": "text", "text": "instrument.jpg" },695 {696 "type": "image",697 "mime_type": "'"$MIME_TYPE"'",698 "data": "'"$IMAGE_B64"'"699 }700 ]701 }]702 }'703704### Combine built-in tools and function calling705706Gemini 3 allows the use of built-in tools (like Google Search, URL707context, and [more](https://ai.google.dev/gemini-api/docs/tools)) and custom [function calling](https://ai.google.dev/gemini-api/docs/interactions/function-calling) tools in the same API call, allowing for708more complex workflows.709710### Python711712 from google import genai713 from google.genai import types714715 client = genai.Client()716717 getWeather = {718 "type": "function",719 "name": "getWeather",720 "description": "Gets the weather for a requested city.",721 "parameters": {722 "type": "object",723 "properties": {724 "city": {725 "type": "string",726 "description": "The city and state, e.g. Utqiaġvik, Alaska",727 },728 },729 "required": ["city"],730 },731 }732733 interaction = client.interactions.create(734 model="gemini-3-flash-preview",735 input="What is the northernmost city in the United States? What's the weather like there today?",736 tools=[737 {"type": "google_search"},738 getWeather739 ],740 )741742 fc_step = next((s for s in interaction.steps if s.type == "function_call"), None)743744 if fc_step:745 result = {"response": "Very cold. 22 degrees Fahrenheit."}746747 final_interaction = client.interactions.create(748 model="gemini-3-flash-preview",749 input=[750 {"type": "function_result", "name": fc_step.name, "call_id": fc_step.id, "result": result}751 ],752 tools=[753 {"type": "google_search"},754 getWeather755 ],756 previous_interaction_id=interaction.id,757 )758759 print(final_interaction.output_text)760761### JavaScript762763 import { GoogleGenAI, Type } from '@google/genai';764765 const client = new GoogleGenAI({});766767 const getWeatherDeclaration = {768 type: 'function',769 name: 'getWeather',770 description: 'Gets the weather for a requested city.',771 parameters: {772 type: Type.OBJECT,773 properties: {774 city: {775 type: Type.STRING,776 description: 'The city and state, e.g. Utqiaġvik, Alaska',777 },778 },779 required: ['city'],780 },781 };782783 const interaction = await client.interactions.create({784 model: 'gemini-3-flash-preview',785 input: "What is the northernmost city in the United States? What's the weather like there today?",786 tools: [787 { type: "google_search" },788 getWeatherDeclaration789 ],790 });791792 const fcStep = interaction.steps.find(s => s.type === 'function_call');793794 if (fcStep) {795 const result = { response: "Very cold. 22 degrees Fahrenheit." };796797 const finalInteraction = await client.interactions.create({798 model: 'gemini-3-flash-preview',799 input: [800 { type: 'function_result', name: fcStep.name, call_id: fcStep.id, result: result }801 ],802 tools: [803 { type: "google_search" },804 getWeatherDeclaration805 ],806 previous_interaction_id: interaction.id,807 });808809 console.log(finalInteraction.output_text);810 }811812## Migration from Gemini 2.5813814Gemini 3 is our most capable model family to date and offers a stepwise815improvement over Gemini 2.5. When migrating, consider the following:816817- **Thinking:** If you were previously using complex prompt engineering (like chain of thought) to force Gemini 2.5 to reason, try Gemini 3 with `thinking_level: "high"` and simplified prompts.818- **Temperature settings:** If your existing code explicitly sets temperature (especially to low values for deterministic outputs), we recommend removing this parameter and using the Gemini 3 default of 1.0 to avoid potential looping issues or performance degradation on complex tasks.819- **PDF \& document understanding:** If you relied on specific behavior for dense document parsing, test the new `media_resolution_high` setting to ensure continued accuracy.820- **Token consumption:** Migrating to Gemini 3 defaults may **increase** token usage for PDFs but **decrease** token usage for video. If requests now exceed the context window due to higher default resolutions, we recommend explicitly reducing the media resolution.821- **Image segmentation:** Image segmentation capabilities (returning pixel-level masks for objects) are not supported in Gemini 3 Pro or Gemini 3 Flash. For workloads requiring built-in image segmentation, we recommend continuing to utilize Gemini 2.5 Flash with thinking turned off or [Gemini Robotics-ER 1.6](https://ai.google.dev/gemini-api/docs/robotics-overview).822- **Computer Use:** Gemini 3 Pro and Gemini 3 Flash support [Computer823 Use](https://ai.google.dev/gemini-api/docs/interactions/computer-use). Unlike the 2.5 series, you don't need to use a separate model to access the Computer Use tool.824- **Tool support** : [Combining built-in tools with function calling](https://ai.google.dev/gemini-api/docs/interactions/tool-combination) is now supported for Gemini 3 models. [Maps825 grounding](https://ai.google.dev/gemini-api/docs/interactions/maps-grounding) is also now supported for Gemini 3 models.826827## OpenAI compatibility828829For users utilizing the [OpenAI compatibility layer](https://ai.google.dev/gemini-api/docs/openai),830standard parameters (OpenAI's `reasoning_effort`) are automatically mapped to831Gemini (`thinking_level`) equivalents.832833## Prompting best practices834835Gemini 3 is a reasoning model, which changes how you should prompt.836837- **Precise instructions:** Be concise in your input prompts. Gemini 3 responds best to direct, clear instructions. It may over-analyze verbose or overly complex prompt engineering techniques used for older models.838- **Output verbosity:** By default, Gemini 3 is less verbose and prefers providing direct, efficient answers. If your use case requires a more conversational or "chatty" persona, you must explicitly steer the model in the prompt (e.g., "Explain this as a friendly, talkative assistant").839- **Context management:** When working with large datasets (e.g., entire books, codebases, or long videos), place your specific instructions or questions at the end of the prompt, after the data context. Anchor the model's reasoning to the provided data by starting your question with a phrase like, "Based on the preceding information...".840841Learn more about prompt design strategies in the [prompt engineering guide](https://ai.google.dev/gemini-api/docs/prompting-strategies).842843## FAQ8448451. **What is the knowledge cutoff for Gemini 3?** Gemini 3 models have a846 knowledge cutoff of January 2025. For more recent information, use the847 [Search Grounding](https://ai.google.dev/gemini-api/docs/interactions/google-search) tool.8488492. **What are the context window limits?** Gemini 3 models support a 1 million850 token input context window and up to 64k tokens of output.8518523. **Is there a free tier for Gemini 3?** Gemini 3 Flash853 `gemini-3-flash-preview` has a free tier in the Gemini API. You can try854 Gemini 3.1 Pro and 3 Flash at no cost in Google AI Studio, but there855 is no free tier available for `gemini-3.1-pro-preview` in the Gemini API.8568574. **Will my old `thinking_budget` code still work?** Yes, `thinking_budget` is858 still supported for backward compatibility, but we recommend migrating to859 `thinking_level` for more predictable performance. Don't use both in the same860 request.8618625. **Does Gemini 3 support the Batch API?** Yes, Gemini 3 supports the863 [Batch API](https://ai.google.dev/gemini-api/docs/batch-api).8648656. **Is Context Caching supported?** Yes, [Context Caching](https://ai.google.dev/gemini-api/docs/interactions/caching) is supported for Gemini 3.8668677. **Which tools are supported in Gemini 3?** Gemini 3 supports868 [Google Search](https://ai.google.dev/gemini-api/docs/interactions/google-search),869 [Grounding with Google Maps](https://ai.google.dev/gemini-api/docs/interactions/maps-grounding),870 [File Search](https://ai.google.dev/gemini-api/docs/interactions/file-search),871 [Code Execution](https://ai.google.dev/gemini-api/docs/interactions/code-execution), and872 [URL Context](https://ai.google.dev/gemini-api/docs/interactions/url-context). It also supports873 standard [Function Calling](https://ai.google.dev/gemini-api/docs/interactions/function-calling) for874 your own custom tools, and in875 [combination with built-in tools](https://ai.google.dev/gemini-api/docs/interactions/tool-combination).8768778. **What is `gemini-3.1-pro-preview-customtools`?** If you are using878 `gemini-3.1-pro-preview` and the model ignores your custom tools in favor of879 bash commands, try the `gemini-3.1-pro-preview-customtools` model instead.880 More info \[here\]\[customtools-model\].