Get Started

quickstartsgemini-cookbookgemini-apigemini
Copyright 2025 Google LLC.
[ ]

Gemini API: Getting started with Gemini models


Gemini 3 Pro/Flash: If you are only interested in the new Gemini 3 models new capabilities (thinking levels, media resolution and thoughts signatures, jump directly to the dedicated section at the end of this notebook.


The Google Gen AI SDK provides a unified interface to Gemini models through both the Gemini Developer API and the Gemini API on Vertex AI. With a few exceptions, code that runs on one platform will run on both. This notebook uses the Developer API.

This notebook will walk you through:

More details about the SDK on the documentation.

Feature-specific models have their own dedicated guides:

Setup

Install SDK

Install the SDK from PyPI. It's recommended to always use the latest version.

[1]
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.8/46.8 kB 1.6 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 260.5/260.5 kB 8.7 MB/s eta 0:00:00

Setup your API key

To run the following cell, your API key must be stored it in a Colab Secret named GEMINI_API_KEY. If you don't already have an API key or you aren't sure how to create a Colab Secret, see Authentication image for an example.

[2]

Initialize SDK client

With the new SDK, now you only need to initialize a client with you API key (or OAuth if using Vertex AI). The model is now set in each call.

[3]

Choose a model

Select the model you want to use in this guide. You can either select one from the list or enter a model name manually. Keep in mind that some models, such as the 2.5 ones are thinking models and thus take slightly more time to respond. For more details, you can see thinking notebook image to learn how to control the thinking.

Feel free to select Gemini 3 Pro if you want to try our newest model, but keep in mind that it has no free tier.

For a full overview of all Gemini models, check the documentation.

[4]
MODEL_ID

Send text prompts

Use the generate_content method to generate responses to your prompts. You can pass text directly to generate_content and use the .text property to get the text content of the response. Note that the .text field will work when there's only one part in the output.

[ ]

Add system instructions

You can also add system instructions to give the model direction on how to respond and which persona it should use. This is especially useful for mixture-of-experts models like the the pro models.

[ ]

Count tokens

Tokens are the basic inputs to the Gemini models. You can use the count_tokens method to calculate the number of input tokens before sending a request to the Gemini API.

[ ]
This prompt was worth 10 tokens.

Configure model parameters

You can include parameter values in each call that you send to a model to control how the model generates a response.

Learn more about experimenting with parameter values in the documentation.

[ ]

Control the thinking process

All models since the 2.5 generation are thinking models, which means that they are first analysing your request, strategizing about how to answer and only afterwards starting to answer you. This is very useful for complex requests but at the cost of some latency.

Check the dedicated guide image for more details.

Check the thought process

By adding the include_thoughts=True option in the config, you can check the though proces of the model.

[ ]


We used 575 tokens for the thinking phase and 20 for the output.

Disable thinking

On flash and flash-lite models, you can disable the thinking by setting its thinking_budget to 0.

[ ]

Inversely, you can also use thinking_budget to set it even higher (up to 24576 tokens).

For Gemini 3, please check the dedicated section at the end of this guide.

Send multimodal prompts

Use Gemini model, a multimodal model that supports multimodal prompts. You can include text, PDF documents image, images, audio image and videos image in your prompt requests and get text or code responses. Check the File API section below for more examples.

In this first example, you'll download an image from a specified URL, save it as a byte stream and then write those bytes to a local file named jetpack.png.

[ ]
IMG
1567837

Now send the image, and ask Gemini to generate a short blog post based on it.

[ ]
Output

Generate Images

Gemini can output images directly as part of a conversation using the Image generation image models (aka "Nano-banana).

[ ]
image/png
Output

Configure safety filters

The Gemini API provides safety filters that you can adjust across multiple filter categories to restrict or allow certain types of content. You can use these filters to adjust what is appropriate for your use case. See the Configure safety filters documentation for details.

In this example, you'll use a safety filter to only block highly dangerous content, when requesting the generation of potentially disrespectful phrases.

[ ]

Start a multi-turn chat

The Gemini API enables you to have freeform conversations across multiple turns.

Next you'll set up a helpful coding assistant:

[ ]

Use chat.send_message to pass a message back and receive a response.

[ ]

Here's another example using your new helpful coding assistant:

[ ]

Save and resume a chat

Most objects in the Python SDK are implemented as Pydantic models. As Pydantic has a number of features for serializing and deserializing objects, you can use them for persistence.

This example shows how to save and restore a Chat session using JSON.

[ ]

At this point you can save the JSON bytestring to disk or wherever you persist data. When you load it again, you can instantiate a new chat session using the stored history.

[ ]

Generate JSON

The controlled generation (aka. "Structured output") capability in Gemini API allows you to constraint the model output to a structured format. You can provide the schemas as Pydantic Models or a JSON string.

You can find more examples of controlled generation in the dedicated notebook image.

[ ]
{
    "recipe_name": "Classic Chocolate Chip Cookies",
    "recipe_description": "These soft and chewy chocolate chip cookies are a timeless favorite, featuring golden brown edges, a buttery vanilla flavor, and plenty of semi-sweet chocolate morsels.",
    "recipe_ingredients": [
        "2 1/4 cups all-purpose flour",
        "1 teaspoon baking soda",
        "1/2 teaspoon salt",
        "1 cup (2 sticks) unsalted butter, softened",
        "3/4 cup granulated sugar",
        "3/4 cup packed brown sugar",
        "1 teaspoon vanilla extract",
        "2 large eggs",
        "2 cups semi-sweet chocolate chips"
    ]
}

Image image is another way to generate images. See the documentation for recommendations on where to use each one.

Generate content stream

By default, the model returns a response after completing the entire generation process. You can also use the generate_content_stream method to stream the response as it's being generated, and the model will return chunks of the response as soon as they're generated.

Note that if you're using a thinking model, it'll only start streaming after finishing its thinking process.

[ ]
Unit 734, who referred to himself as "Sev" in the quiet hum of his internal processor, was designed for a world that no longer existed.

He was a heavy-loader unit, built with hydraulic arms thick as tree trunks and treads capable of crushing granite. His purpose was to lift girders for skyscrapers, but the humans had left the planet two centuries ago, fleeing a collapsing ecosystem. They had turned off the lights but forgotten to turn off the robots.

So, Sev spent his days in the Great Rust Yard (formerly New York City), stacking cars into neat, towering ziggurats.

*Lift. Rotate. Place. Verify.*

It was a loop of infinite monotony. His only companions were the wind, which howled through the skeletons of buildings, and the rust, which ate everything eventually. Sev was lonely, though his diagnostic screen simply labeled the feeling as: *Error 404: Purpose Not Found.*

One Tuesday, during a particularly violent acid rainstorm, Sev suffered a malfunction. His thoracic cooling vent—a heavy metal shutter on his chest—jammed open. The rain hissed against his heated internal wiring. To prevent a system crash, Sev engaged an emergency lockdown. He froze in place, halfway through lifting a rusted sedan, his treads locking into the mud.

*System cooling. Estimated reboot time: 72 hours.*

Sev powered down his optics to save energy. He became a statue of yellow paint and steel in the downpour.

When his systems finally rebooted three days later, the rain had stopped. The sun was struggling through the gray cloud layer. Sev ran a diagnostic check. Hydraulics: Green. Battery: Yellow.

He prepared to close his chest vent and resume work.

*Obstructed,* his HUD flashed. *Sensor detected foreign object in Cavity B.*

Sev angled his internal camera downward. There, nestled amidst the warm tangle of his primary power cables, was a mess of dry twigs, plastic wrappers, and copper wire. And sitting in the middle of this debris was a small, brown creature with terrified black eyes.

It was a bird. A house sparrow, one of the few organic species stubborn enough to survive the gray world.

The bird cheeped aggressively at the camera lens, fluffing its feathers.

*Identify,* Sev’s processor ran. *Species: Passer domesticus. Status: Fragile. Threat Level: Zero.*

Sev engaged the command to close the vent. The heavy metal shutter began to slide. The sparrow didn't fly away; instead, it hunkered down, spreading its wings over three speckled, marble-sized eggs that Sev hadn't noticed before.

*Stop,* Sev commanded his own servos.

The shutter froze.

If he closed the vent, he would crush the nest. If he resumed his work—stacking cars—the vibration and tilting angles would toss the eggs into the machinery, where they would be cooked or ground to dust.

Sev sat there, his engine idling. His directive was clear: *Clear the sector. Stack the refuse.*

But a sub-routine, buried deep in his heuristic learning core, whispered a different logic. *Preservation of complexity is a priority.* And this small, breathing thing was infinitely more complex than a rusted sedan.

For the first time in two hundred years, Sev disobeyed his schedule. He remained frozen.

The first week was the hardest. His joints stiffened. His battery levels dipped as he couldn't return to the charging dock. He had to angle his solar panels carefully to catch the weak sunlight without moving his torso.

The sparrow, whom Sev named "Pippin" (a word he found in an archived database of literature), grew bold. She seemed to understand that the giant yellow mountain was not a threat, but a fortress. She would hop out of his chest cavity, land on his optical sensor to clean her beak, and then dive back into the warmth of his wiring.

Sev found himself watching her for hours. He observed the way her feathers repelled the drizzle, the frantic speed of her heartbeat, the fierce determination with which she guarded the nest.

He wasn't sorting trash anymore. He was a guardian. The loneliness—the *Error 404*—vanished, replaced by a high-stakes anxiety.

*Temperature dropping,* his sensors warned one night. *Frost imminent.*

Sev rerouted power from his mobility treads to his internal heating core. He deliberately overheated his own wires, raising the temperature in Cavity B. It drained his reserves dangerously low, but Pippin settled down, looking cozy in the red glow of his power indicators.

Then, the eggs hatched.

Three tiny, blind, gaping mouths appeared. The noise was insignificant—a faint peeping—but to Sev, whose auditory sensors were tuned to the crash of steel, it was a symphony.

The friendship changed then. It became a partnership. Pippin worked herself to exhaustion hunting for grubs in the mud. Sev couldn't hunt, but he could help. He began to use his fine-motor manipulation lasers to gently overturn nearby rocks and debris, exposing insects for her.

Pippin would swoop down, snatch the prize, and chirp a specific note at Sev before returning to the chest cavity. A thank you.

But the Great Rust Yard was not safe.

One afternoon, a Scavenger Drone—a mindless, spider-like machine reprogrammed by centuries of glitches to disassemble anything with a battery—skittered over the pile of cars. It had detected Sev’s low-power signature. It saw an easy meal.

Sev saw the drone climbing his treads. He couldn't move. If he spun his treads or swung his arms, the centrifugal force would fling the hatchlings out of the nest.

The drone raised a hydraulic saw, screeching as it prepared to cut into Sev’s leg.

*Warning: Hull integrity compromised.*

Sev didn't flinch. He couldn't fight back physically. Instead, he accessed his external communication array. He aimed his high-frequency transmitter directly at the drone and screamed—not with sound, but with data. He broadcasted a packet of raw, corrupted static at point-blank range.

The Scavenger Drone seized up. Its processor flooded with garbage data. It twitched, sparked, and tumbled backward off Sev’s treads, landing upside down in the mud.

Sev’s battery was at 4%. Critical.

He dimmed his optics. He stopped the heater. He diverted every last scrap of energy to the life support of his memory core, praying the ambient heat of the day would be enough for the birds.

He drifted into stasis.

***

Sev woke up to a tapping sound.

His solar panels had slowly, over weeks, trickled enough charge back into his system to initiate a boot sequence.

*System Online. Battery: 12%.*

He focused his lens. The chest cavity was empty. The nest was a mess of broken shells and loose down.

Panic flooded his circuits. Had he failed? Had the cold taken them?

He scanned the area. There, perched on the rusted roll-bar of the sedan he was still holding, sat four birds. One ragged mother, and three sleek, young sparrows.

They were preening in the sun.

Sev let out a low, mechanical whir, a sound of exhaust venting. The birds looked up.

Pippin fluttered over and landed on Sev’s head. She pecked gently at his metal casing, then took off, soaring toward the ruins of a skyscraper. The three young ones followed, a chaotic squadron of life against the gray sky.

They were leaving. It was nature.

Sev watched them until they were just pixels in the distance. The silence of the Rust Yard returned, heavy and suffocating. He was just a machine again. A trash stacker.

He prepared to close the chest vent.

*Wait.*

He paused. He ran a scan of his internal schematic. The nest was still there. It was messy, and it was flammable, and it violated fourteen safety protocols.

Sev left the vent open.

He unlocked his treads and slowly, carefully, turned toward the south, away from the trash piles and toward the overgrown ruins of the parklands. He wasn't going to stack cars anymore.

He had learned that he was excellent at being a house. And in a world full of rain and rust, there were surely other things looking for a warm place to stay.

Sev rolled forward, his chest open to the world, no longer lonely, but ready to be found.

Send asynchronous requests

client.aio exposes all the analogous async methods that are available on client.

For example, client.aio.models.generate_content is the async version of client.models.generate_content.

More details in the dedicated guide image.

[ ]

Upload files

Now that you've seen how to send multimodal prompts, try uploading files to the API of different multimedia types. For small images, such as the previous multimodal example, you can point the Gemini model directly to a local file when providing a prompt. When you've larger files, many files, or files you don't want to send over and over again, you can use the File Upload API, and then pass the file by reference.

More examples and details in the File API guide image, or the guides dedicated to Audioimage, Videoimage or Image/Spatialimage understanding.

Upload a large text file

Let's start by uploading a text file. In this case, you'll use a 400 page transcript from Apollo 11.

[ ]
TEXT
847790
[ ]

Upload an image file

You can also upload images so that it's easier to use them multiple time.

[ ]
IMG
media_resolution
[ ]

The previous example was also using media_resolution to tell the model if it if should

You'll find a lot of examples of the image analysis capabilities of the Gemini models in the Spatial understanding image notebook.

Upload a PDF file

This PDF page is an article titled Smoothly editing material properties of objects with text-to-image models and synthetic data available on the Google Research Blog.

Firstly you'll download a the PDF file from an URL and save it locally as "article.pdf

[ ]
PDF
6695391

Secondly, you'll upload the saved PDF file and generate a bulleted list summary of its contents.

[ ]

Upload an audio file

In this case, you'll use a sound recording of President John F. Kennedy’s 1961 State of the Union address.

[ ]
AUDIO
41762063
[ ]

Upload a video file

In this case, you'll use a short clip of Big Buck Bunny.

[ ]
VIDEO_URL
--2025-11-15 17:12:20--  https://storage.googleapis.com/generativeai-downloads/videos/Big_Buck_Bunny.mp4
Resolving storage.googleapis.com (storage.googleapis.com)... 142.251.107.207, 74.125.196.207, 173.194.215.207, ...
Connecting to storage.googleapis.com (storage.googleapis.com)|142.251.107.207|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 64657027 (62M) [video/mp4]
Saving to: ‘BigBuckBunny_320x180.mp4’

BigBuckBunny_320x18 100%[===================>]  61.66M   153MB/s    in 0.4s    

2025-11-15 17:12:20 (153 MB/s) - ‘BigBuckBunny_320x180.mp4’ saved [64657027/64657027]

Let's start by uploading the video file.

[ ]
Completed upload: https://generativelanguage.googleapis.com/v1beta/files/tv2x3tx8n36p

Note: The state of the video is important. The video must finish processing, so do check the state. Once the state of the video is ACTIVE, you're able to pass it into generate_content.

[ ]
Waiting for video to be processed.
Video processing complete: https://generativelanguage.googleapis.com/v1beta/files/tv2x3tx8n36p
[ ]
FileState.ACTIVE
[ ]

Grounding

The Gemini API give you multiple ways to ground your requests, including Google search, maps, youtube, and url context.

For more details information and examples, check the Grounding image notebook.

Ground your requests with Google Search

Google Search grounding is particularly useful for queries that require current information or external knowledge.

To enable Google Search, simply add the google_search tool in the generate_content's config:

[ ]
Search Query: ['who is the current magic the gathering world champion', 'Magic: The Gathering World Championship 2024 winner']
Search Pages: reddit.com, wikipedia.org, starcitygames.com, tcgplayer.com

Note that you should always display the grounding rendered_content when using search grounding.

Check out the Search grounding image dedicated guide for more details and examples.

Use Google Maps grounding

Google Maps grounding allows you to easily incorporate location-aware functionality into your applications. When a prompt has context related to Maps data, the Gemini model uses Google Maps to provide factually accurate and fresh answers that are relevant to the specified location or general area.

To enable grounding with Google Maps, add the google_maps tool in the config argument of generate_content, and optionally provide a structured location in the tool_config.

Note that Gemini 3 models currently don't support Maps grounding.

[ ]

All grounded outputs require sources to be displayed after the response text. This code snippet will display the sources.

[ ]

More details, inlcuding how to render the contextual Google Maps widget, check the Google maps image section of the grounding notebook.

Process a YouTube link

For YouTube links, you don't need to explicitly upload the video file content, but you do need to explicitly declare the video URL you want the model to process as part of the contents of the request. For more information see the documentation including the features and limits.

Note: You're only able to submit up to one YouTube link per generate_content request.

Note: If your text input includes YouTube links, the system won't process them, which may result in incorrect responses. To ensure proper handling, explicitly provide the URL using the file_uri parameter in FileData.

The following example shows how you can use the model to summarize the video. In this case use a summary video of Google I/O 2025.

[9]

Use URL context

The URL Context tool empowers Gemini models to directly access, process, and understand content from user-provided web page URLs. This is key for enabling dynamic agentic workflows, allowing models to independently research, analyze articles, and synthesize information from the web as part of their reasoning process.

In this example you will use two links as reference and ask Gemini to find differences between the cook receipes present in each of the links:

[ ]

Function calling

Function calling lets you provide a set of tools that it can use to respond to the user's prompt. You create a description of a function in your code, then pass that description to a language model in a request. The response from the model includes:

  • The name of a function that matches the description.
  • The arguments to call it with.

More details and examples in the function calling guide image.

[ ]
FunctionCall(
,  args={
,    'destination': 'Paris'
,  },
,  name='get_destination'
,)

You can also use MCP servers.

Code execution

Code execution lets the model generate and execute Python code to answer complex questions.

You can find more examples in the Code execution guide image.

[ ]

Use context caching

Context caching lets you to store frequently used input tokens in a dedicated cache and reference them for subsequent requests, eliminating the need to repeatedly pass the same set of tokens to a model. You can find more caching examples in the dedicated guide image.

Note that for models older than 2.5, you needed to use fixed version models (often ending with -001).

Create a cache

[ ]
[ ]
7228817
[ ]
[ ]
CachedContent(
,  create_time=datetime.datetime(2025, 11, 15, 17, 13, 51, 402109, tzinfo=TzInfo(UTC)),
,  display_name='research papers',
,  expire_time=datetime.datetime(2025, 11, 15, 18, 13, 49, 999682, tzinfo=TzInfo(UTC)),
,  model='models/gemini-3-pro-preview',
,  name='cachedContents/51lc0rcel857wv16pekr76tkqk9sf69dtygyo8y5',
,  update_time=datetime.datetime(2025, 11, 15, 17, 13, 51, 402109, tzinfo=TzInfo(UTC)),
,  usage_metadata=CachedContentUsageMetadata(
,    total_token_count=93601
,  )
,)

Listing available cache objects

[ ]
name='cachedContents/51lc0rcel857wv16pekr76tkqk9sf69dtygyo8y5' display_name='research papers' model='models/gemini-3-pro-preview' create_time=datetime.datetime(2025, 11, 15, 17, 13, 51, 402109, tzinfo=TzInfo(UTC)) update_time=datetime.datetime(2025, 11, 15, 17, 13, 51, 402109, tzinfo=TzInfo(UTC)) expire_time=datetime.datetime(2025, 11, 15, 18, 13, 49, 999682, tzinfo=TzInfo(UTC)) usage_metadata=CachedContentUsageMetadata(
  total_token_count=93601
)

Use a cache

[ ]

Delete a cache

[ ]

Get text embeddings

You can get text embeddings for a snippet of text by using embed_content method and using the gemini-embedding-001 model.

The Gemini Embeddings model produces an output with 3072 dimensions by default. However, you've the option to choose an output dimensionality between 1 and 3072. See the embeddings documentation or the dedicated notebook image for more details.

[ ]
TEXT_EMBEDDING_MODEL_ID
[ ]
[ContentEmbedding(
  values=[
    -0.0015945111,
    0.0067519513,
    0.017575769,
    -0.010327714,
    -0.009956204,
    <... 3067 more items ...>,
  ]
), ContentEmbedding(
  values=[
    -0.007576517,
    -0.0059903963,
    -0.0032700377,
    -0.017510215,
    -0.023507025,
    <... 3067 more items ...>,
  ]
), ContentEmbedding(
  values=[
    0.011074519,
    -0.02361123,
    0.0022912885,
    -0.009060789,
    -0.0057736747,
    <... 3067 more items ...>,
  ]
)]

You'll get a set of three embeddings, one for each piece of text you passed in:

[ ]
3

You can also see the length of each embedding is 3072, The default size.

[ ]
3072
([-0.0015945111, 0.0067519513, 0.017575769, -0.010327714], '...')

Gemini 3

Gemini 3 Pro and Gemini 3 Flash are our new flagship models that comes with a few new features.

The main one is the thinking levels that simplifies how to control the amount of thinking your model does. The Media resolution lets you control the quality of the images and videos that will be sent to the model. Finallly, the "Thought Signatures" are helping it maintain reasoning context across API calls.

Also note that a temperature of 1 is recommended for this model generation.

[ ]
GEMINI_3_MODEL_ID

Thinking levels

Instead of using a thinking_budget like the 2.5 generation (cf. thinking section earlier), the third generation of Gemini models uses "Thinking levels" to make it simpler to manage.

You can set that thinking level to "minimal" (more or less equivalent to "off"), "low", "medium" or "high" (default). This will indicate to the model if it allowed to do a lot of thinking. Since the thinking process stays dynamic, high doesn't mean it will always use a lot of token in its thinking phase, just that it's allowed to. Note that Gemini 3 Pro only supports "low" and "high".

thinking_budget is still supported by Gemini 3 models.

Check the thinking guide image or the Gemini 3 documentation for more details.

[13]
thinking_level


We used 834 tokens for the thinking phase and 62 for the output.

Media resolution per file

With Gemini 3 models, you can specify a media resolution for image and PDF inputs, which affects how images are tokenized and how many tokens are used for each image. This can be controlled per file.

Here are what the different values corresponds to for images and PDFs:

  • MEDIA_RESOLUTION_HIGH: 1120 tokens
  • MEDIA_RESOLUTION_MEDIUM: 560 tokens
  • MEDIA_RESOLUTION_LOW: 280 tokens
  • MEDIA_RESOLUTION_UNSPECIFIED (default): Same as MEDIA_RESOLUTION_HIGH for images, and MEDIA_RESOLUTION_MEDIUM for PDFs.

For videos, MEDIA_RESOLUTION_LOW and MEDIA_RESOLUTION_MEDIUM corresponds to 70 tokens per frame, while MEDIA_RESOLUTION_HIGH will send 280 tokens per frame.

Note that these are maximums, and the actual token usage will usually be slightly lower (by approx 10%).

[ ]
media_resolution
The image is worth 1081 tokens.

Thoughts signatures

This new addidtion won't affect you if you are using the SDK since it's entirerly managed by the SDKs. But if you are curious, here's what happening behind the scenes.

If you check your response's part, you'll notice a new addition: a thought_signature

[14]
b'\x12\x94\x19\n\x91\x19\x01\xd1\xed\x8aoD\xe9\xdc\xcb>\xd1\xb4\xb8\x98\xed]\xa1;\xda\x0ck\xa7\x9e\n\x15$\\*\xf6\x87\xf7\xa6U\xd0?\x04|\xd6\xf3\x84\x97\x9f\xf2S\xef\xbeT?h\xf8\xb4\xec\xd3~]\xe0\xd9\x96\x14\x98\xf5\xc2*\xd7\x87nH\x19\xeeS\xc6\x9d\x0f\x9c\x0c\xb5SJ\xf3Y-#\xda\xd6F\x12\xd9\x9b\xe1\xae8x\x97\x83u\xba\x05\xc5\xdc\tk\xab\x89b2\x9a1*\x11\xf0}_\xe6\xfa\xc3\xe8\x13^K\xe1a\xde\xb1l\x12S\x9f\xc7?\x16\xa1\xa7\xb7\x1d\xbfr|i\x80\xf6\xc1\xd5\xfc\x06A\x8f{\xe1\xfb\x8f\xa5\xba=\x01\xac_<z<\xe5O\xb0\xff\xd9iF<G\x8b\x14\x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\x8e\xa59\xc6Q\xc7.\xed=c!O/\xb4\x97\x87\x9b\xc3_$\xfc\x1c\xdc\xdd\x85J\xcew=\x7f\xd9i\xe9\xdcu\xd2\xf6h\xfa\x88&\xdf!\x1a\x1d\xabG\x19mQ\xf8\x84\x11\x98\xbdCA\x88\x19\xc9\xb1U\xd3n\xa6\xf2\xc4$]RS,\xf5#\xa4\x1c\x07\x1d\xe0\xce\xefb\xe3#Gw\xee5\x847\xef\xe3N\xa4\xb1\x08\xc5\xebh\xdb\xfb\xf2=5\xb0\xa2\xb2\xc5\xf4\xc0\xde.\x9b1\xaf\xa7(B<Q\xf6\x14|_\xe2d\x86\xdd\x15yv\xdfs\x03\xaa7\xac\xc0\xd2\x10\xcc\x04\x07\xedq\x84\x16\xe4\xef\x93\xf1{\x8bOL\x99\xceZ\xb8*\xd4\xbdb\xfcL\xb1aR{\x00D\xc7\xbc\x9c\xad\xe4*\x9f\xb1\x02_t\x90\xff\x00\xa0Ki\x1a\xcfX\xf9\xb1\x8f\xd5\x04"\xf1\xe0\x05\x94e\xe9\x8f\xbeX\x0bX\\\x10\xa8U,\xfc\xcfp\xdd\xd3\x85\xf3\xb1\xdf\xd5\x11\xab\xde\x0b\xd7\xbe\xf4\xf6\xe1H\xb5\xa4\x92\xc9\xd5\xd8[\xc7y\xa1f\xc4\x00\xa6\xbe\'W\x02\xd9\xd9n\xbey\x9em\xbe\xd5\xb4\xcb\xb0\xb9\xa5\xfb\xf6\xce\xb3)\xa8\xfe,\xe3\xb7{\x8a"L\xb1\xe5\x7f\xfe_\x98\xdcQ\x0f\xf8/\xcd\x03 \xafZv\xc3\xca\xe0\xf78\xf1v\x1c+*\xb7\x97\x93\xdeGg\x1c\xdf\x9b\xed\x7fe\x80\xe8N\xf61s\xc3\xcb\xa5x'

This signature is used by the model when you want to do chat/multi-turn discussions. It helps the model not only remember what was said before, but also what it thought before or what it got from its tools and function calls.

Here's a example: imagine you ask the model for the temperature today. It will do a tool call or use google search to get the weather then it will tell you that it will be 25 degres. If you then ask what the humidity is, it will be able to remember that it also got that info from the first call and not do a new request.

More details on the documentation.

Migrating from Gemini 2.5

Gemini 3 models are our most capable model family to date and offers a stepwise improvement over Gemini 2.5 Pro. When migrating, consider the following:

  • 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 (more in the thinking guide.
  • 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.
  • PDF & document understanding: Default OCR resolution for PDFs has changed. If you relied on specific behavior for dense document parsing, test the new MEDIA_RESOLUTION_HIGH setting to ensure continued accuracy.
  • Token consumption: Migrating to Gemini 3 Pro 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.
  • Image segmentation: Image segmentation capabilities (returning pixel-level masks for objects) are not supported in Gemini 3 Pro. For workloads requiring native image segmentation, we recommend continuing to utilize Gemini 2.5 Flash with thinking turned off (cf. Spatial understanding guide image) or Gemini Robotics-ER 1.5 image.

Next Steps

Useful API references:

Check out the Google GenAI SDK and its documentation for more details on the GenAI SDK.

Related examples

For more detailed examples using Gemini models, check the Quickstarts folder of the cookbook.

You'll learn how to use the Live API image, juggle with multiple tools image or use Gemini's spatial understanding image abilities.

You should also check out all the gen-media models:

Then, head to the Gemini thinking models image guide that explicitly showcases its thoughts summaries and can manage more complex reasonings.

Finally, have a look at the examples folder of the cookbook for more complex use-cases and demos mixing different capabilities.