Thinking Stay organized with collections Save and categorize content based on your preferences.
To see an example of Gemini 2.5 Flash, run the "Intro to Gemini 2.5 Flash" notebook in one of the following environments:
Open in Colab |Open in Colab Enterprise |Openin Vertex AI Workbench |View on GitHub
Thinking models are trained to generate the "thinking process" the model goesthrough as part of its response. As a result, thinking models are capable ofstronger reasoning capabilities in its responses than equivalent base models.
The thinking process is enabled by default. When you useVertex AI Studio, you can view the full thinking process togetherwith the model's generated response.
Supported models
Thinking is supported in the following models:
- Gemini 3 FlashPreview model
- Gemini 3 ProPreview model
- Gemini 3 Pro ImagePreview model
- Gemini 2.5 Pro
- Gemini 2.5 FlashPreview model
- Gemini 2.5 Flash-LitePreview model
- Gemini 2.5 Flash
- Gemini 2.5 Flash-Lite
Use a thinking model
Note:Fine-tuning isn'tsupported when thinking is enabled.To use thinking with a supported model, do the following:
Console
- OpenVertex AI Studio > Create prompt.
- In theModel panel, clickSwitch model and select one of thesupported models from the menu.
- (Gemini 2.5 Flash only)Thinking budget is set toAuto by default when the model is loaded.
- (Optional) Give the model some detailed instructions on how the model should format its responses in theSystem instructions field.
- Enter a prompt in theWrite your prompt field.
- Click Run.
Gemini returns a response after the response is generated. Depending on the complexity of the response, generation can take several seconds:
(Gemini 2.5 Flash only) To turn thinking off, setThinking budget toOff.
Python
Install
pip install --upgrade google-genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
fromgoogleimportgenaiclient=genai.Client()response=client.models.generate_content(model="gemini-2.5-pro",contents="solve x^2 + 4x + 4 = 0",)print(response.text)# Example Response:# Okay, let's solve the quadratic equation x² + 4x + 4 = 0.## We can solve this equation by factoring, using the quadratic formula, or by recognizing it as a perfect square trinomial.## **Method 1: Factoring**## 1. We need two numbers that multiply to the constant term (4) and add up to the coefficient of the x term (4).# 2. The numbers 2 and 2 satisfy these conditions: 2 * 2 = 4 and 2 + 2 = 4.# 3. So, we can factor the quadratic as:# (x + 2)(x + 2) = 0# or# (x + 2)² = 0# 4. For the product to be zero, the factor must be zero:# x + 2 = 0# 5. Solve for x:# x = -2## **Method 2: Quadratic Formula**## The quadratic formula for an equation ax² + bx + c = 0 is:# x = [-b ± sqrt(b² - 4ac)] / (2a)## 1. In our equation x² + 4x + 4 = 0, we have a=1, b=4, and c=4.# 2. Substitute these values into the formula:# x = [-4 ± sqrt(4² - 4 * 1 * 4)] / (2 * 1)# x = [-4 ± sqrt(16 - 16)] / 2# x = [-4 ± sqrt(0)] / 2# x = [-4 ± 0] / 2# x = -4 / 2# x = -2## **Method 3: Perfect Square Trinomial**## 1. Notice that the expression x² + 4x + 4 fits the pattern of a perfect square trinomial: a² + 2ab + b², where a=x and b=2.# 2. We can rewrite the equation as:# (x + 2)² = 0# 3. Take the square root of both sides:# x + 2 = 0# 4. Solve for x:# x = -2## All methods lead to the same solution.## **Answer:**# The solution to the equation x² + 4x + 4 = 0 is x = -2. This is a repeated root (or a root with multiplicity 2).Go
Learn how to install or update theGo.
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
import("context""fmt""io""google.golang.org/genai")//generateThinkingWithTextshowshowtogeneratethinkingusingatextprompt.funcgenerateThinkingWithText(wio.Writer)error{ctx:=context.Background()client,err:=genai.NewClient(ctx, &genai.ClientConfig{HTTPOptions:genai.HTTPOptions{APIVersion:"v1"},})iferr!=nil{returnfmt.Errorf("failed to create genai client: %w",err)}resp,err:=client.Models.GenerateContent(ctx,"gemini-2.5-flash",genai.Text("solve x^2 + 4x + 4 = 0"),nil,)iferr!=nil{returnfmt.Errorf("failed to generate content: %w",err)}respText:=resp.Text()fmt.Fprintln(w,respText)//Exampleresponse://Tosolvethequadraticequation$x^2+4x+4=0$,wecanuseafewmethods:////**Method1:Factoring(RecognizingaPerfectSquareTrinomial)**//**1.TheFoundation:DataandAlgorithms**////Noticethattheleftsideoftheequationisaperfectsquaretrinomial.//...returnnil}Control model thinking
You can control the amount of thinking the model performs before returning aresponse. The method for controlling thinking differs depending on the modelversion.
Gemini 3 and later models
Gemini 3 models introduce thethinking_level parameter, whichsimplifies thinking budget configuration into levels. By default,Gemini 3 models use dynamic thinking to reason through prompts.For faster, lower-latency responses when complex reasoning isn't required, youcan constrain the model'sthinking_level.
MINIMAL:(Gemini 3 Flash only) Constrains the model to use asfew tokens as possible for thinking and is best used for low-complexitytasks that wouldn't benefit from extensive reasoning.MINIMALis as closeas possible to a zero budget for thinking but still requiresthoughtsignatures. If thought signatures aren't provided in your request, the modelreturns a400error. For more information, seeThought signatures.fromgoogleimportgenaifromgoogle.genaiimporttypesclient=genai.Client()response=client.models.generate_content(model="gemini-3-flash-preview",contents="How does AI work?",config=types.GenerateContentConfig(thinking_config=types.ThinkingConfig(thinking_level=types.ThinkingLevel.MINIMAL)),)print(response.text)LOW: Constrains the model to use fewer tokens for thinking and is suitable forsimpler tasks where extensive reasoning is not required.LOWis ideal forhigh-throughput tasks where speed is essential:fromgoogleimportgenaifromgoogle.genaiimporttypesclient=genai.Client()response=client.models.generate_content(model="gemini-3-pro-preview",contents="How does AI work?",config=types.GenerateContentConfig(thinking_config=types.ThinkingConfig(thinking_level=types.ThinkingLevel.LOW)),)print(response.text)MEDIUM:(Gemini 3 Flash only) Offers a balanced approachsuitable for tasks of moderate complexity that benefit from reasoning butdon't require deep, multi-step planning. It provides more reasoningcapability thanLOWwhile maintaining lower latency thanHIGH:fromgoogleimportgenaifromgoogle.genaiimporttypesclient=genai.Client()response=client.models.generate_content(model="gemini-3-flash-preview",contents="How does AI work?",config=types.GenerateContentConfig(thinking_config=types.ThinkingConfig(thinking_level=types.ThinkingLevel.MEDIUM)),)print(response.text)HIGH: Allows the model to use more tokens for thinking and is suitable forcomplex prompts requiring deep reasoning, such as multi-step planning,verified code generation, or advanced function calling scenarios. This is thedefault level for Gemini 3 Pro and Gemini 3 Flash. Use thisconfiguration when replacing tasks you might have previously relied onspecialized reasoning models for:fromgoogleimportgenaifromgoogle.genaiimporttypesclient=genai.Client()response=client.models.generate_content(model="gemini-3-pro-preview",contents="Find the race condition in this multi-threaded C++ snippet: [code here]",config=types.GenerateContentConfig(thinking_config=types.ThinkingConfig(thinking_level=types.ThinkingLevel.HIGH)),)print(response.text)
Thinking cannot be turned off for Gemini 3 Pro.
If you specify boththinking_level andthinking_budget in the same requestfor a Gemini 3 model, the model returns an error.
Gemini 2.5 and earlier models
For models earlier than Gemini 3, you can control thinking using thethinking_budget parameter, which sets an upper limit on the number of tokensthe model can use for its thought process. By default, ifthinking_budget isnot set, the model automatically controls how much it thinks up to a maximum of8,192 tokens. To use dynamic budget through the API, setthinking_budget to-1.
You can manually setthinking_budget to a specific token limit in situationswhere you might need more or less thinking than the default. Set a lower tokenlimit for less complex tasks, or a higher limit for more complexones. If latency is more important, use a lower budget or disable thinking bysetting the budget to 0.
The following table shows the minimum and maximum amounts you can set thethinking_budget to for each supported model:
| Model | Minimum token amount | Maximum token amount |
|---|---|---|
| Gemini 2.5 Flash | 1 | 24,576 |
| Gemini 2.5 Pro | 128 | 32,768 |
| Gemini 2.5 Flash-Lite | 512 | 24,576 |
If you setthinking_budget to0 when using Gemini 2.5 Flash andGemini 2.5 Flash-Lite, thinking is turned off. Thinking can't be turnedoff for Gemini 2.5 Pro.
If you use thethinking_level parameter with a model earlier than Gemini 3, themodel returns an error.
Console
- OpenVertex AI Studio > Create prompt.
- In theModel panel, clickSwitch model and select one of thesupported models from the menu.
- SelectManual from theThinking budget drop-down selector and then use the slider to adjust the thinking budget limit.
Python
Install
pip install --upgrade google-genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
fromgoogleimportgenaifromgoogle.genai.typesimportGenerateContentConfig,ThinkingConfigclient=genai.Client()response=client.models.generate_content(model="gemini-2.5-flash",contents="solve x^2 + 4x + 4 = 0",config=GenerateContentConfig(thinking_config=ThinkingConfig(thinking_budget=1024,# Use `0` to turn off thinking)),)print(response.text)# Example response:# To solve the equation $x^2 + 4x + 4 = 0$, you can use several methods:# **Method 1: Factoring**# 1. Look for two numbers that multiply to the constant term (4) and add up to the coefficient of the $x$ term (4).# 2. The numbers are 2 and 2 ($2 \times 2 = 4$ and $2 + 2 = 4$).# ...# ...# All three methods yield the same solution. This quadratic equation has exactly one distinct solution (a repeated root).# The solution is **x = -2**.# Token count for `Thinking`print(response.usage_metadata.thoughts_token_count)# Example response:# 886# Total token countprint(response.usage_metadata.total_token_count)# Example response:# 1525Node.js
Install
npm install @google/genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
const{GoogleGenAI}=require('@google/genai');constGOOGLE_CLOUD_PROJECT=process.env.GOOGLE_CLOUD_PROJECT;constGOOGLE_CLOUD_LOCATION=process.env.GOOGLE_CLOUD_LOCATION||'global';asyncfunctiongenerateWithThoughts(projectId=GOOGLE_CLOUD_PROJECT,location=GOOGLE_CLOUD_LOCATION){constclient=newGoogleGenAI({vertexai:true,project:projectId,location:location,});constresponse=awaitclient.models.generateContent({model:'gemini-2.5-flash',contents:'solve x^2 + 4x + 4 = 0',config:{thinkingConfig:{thinkingBudget:1024,},},});console.log(response.text);//Exampleresponse://Tosolvetheequation$x^2+4x+4=0$,youcanuseseveralmethods://**Method1:Factoring**//1.Lookfortwonumbersthatmultiplytotheconstantterm(4)andadduptothecoefficientofthe$x$term(4).//2.Thenumbersare2and2($2\times2=4$and$2+2=4$).//...//...//Allthreemethodsyieldthesamesolution.Thisquadraticequationhasexactlyonedistinctsolution(arepeatedroot).//Thesolutionis**x=-2**.//Tokencountfor`Thinking`console.log(response.usageMetadata.thoughtsTokenCount);//Exampleresponse://886//Totaltokencountconsole.log(response.usageMetadata.totalTokenCount);//Exampleresponse://1525returnresponse.text;}View thought summaries
Experimental
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
Thought summaries are the abbreviated output of the thinking process that themodel went through when generating its response. You can view thought summariesin Gemini 2.5 and newer models. To view thoughtsummaries, do the following:
Note: Thought summarization is a best-effort feature. You aren't guaranteed toreceive thethoughts section in the API response even if you setinclude_thoughts=True.Console
Thought summaries are enabled by default in Vertex AI Studio. You can see the model's summarized thought process by expanding theThoughts panel.
Python
Install
pip install --upgrade google-genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
fromgoogleimportgenaifromgoogle.genai.typesimportGenerateContentConfig,ThinkingConfigclient=genai.Client()response=client.models.generate_content(model="gemini-2.5-pro",contents="solve x^2 + 4x + 4 = 0",config=GenerateContentConfig(thinking_config=ThinkingConfig(include_thoughts=True)),)print(response.text)# Example Response:# Okay, let's solve the quadratic equation x² + 4x + 4 = 0.# ...# **Answer:**# The solution to the equation x² + 4x + 4 = 0 is x = -2. This is a repeated root (or a root with multiplicity 2).forpartinresponse.candidates[0].content.parts:ifpartandpart.thought:# show thoughtsprint(part.text)# Example Response:# **My Thought Process for Solving the Quadratic Equation**## Alright, let's break down this quadratic, x² + 4x + 4 = 0. First things first:# it's a quadratic; the x² term gives it away, and we know the general form is# ax² + bx + c = 0.## So, let's identify the coefficients: a = 1, b = 4, and c = 4. Now, what's the# most efficient path to the solution? My gut tells me to try factoring; it's# often the fastest route if it works. If that fails, I'll default to the quadratic# formula, which is foolproof. Completing the square? It's good for deriving the# formula or when factoring is difficult, but not usually my first choice for# direct solving, but it can't hurt to keep it as an option.## Factoring, then. I need to find two numbers that multiply to 'c' (4) and add# up to 'b' (4). Let's see... 1 and 4 don't work (add up to 5). 2 and 2? Bingo!# They multiply to 4 and add up to 4. This means I can rewrite the equation as# (x + 2)(x + 2) = 0, or more concisely, (x + 2)² = 0. Solving for x is now# trivial: x + 2 = 0, thus x = -2.## Okay, just to be absolutely certain, I'll run the quadratic formula just to# double-check. x = [-b ± √(b² - 4ac)] / 2a. Plugging in the values, x = [-4 ±# √(4² - 4 * 1 * 4)] / (2 * 1). That simplifies to x = [-4 ± √0] / 2. So, x =# -2 again – a repeated root. Nice.## Now, let's check via completing the square. Starting from the same equation,# (x² + 4x) = -4. Take half of the b-value (4/2 = 2), square it (2² = 4), and# add it to both sides, so x² + 4x + 4 = -4 + 4. Which simplifies into (x + 2)²# = 0. The square root on both sides gives us x + 2 = 0, therefore x = -2, as# expected.## Always, *always* confirm! Let's substitute x = -2 back into the original# equation: (-2)² + 4(-2) + 4 = 0. That's 4 - 8 + 4 = 0. It checks out.## Conclusion: the solution is x = -2. Confirmed.Node.js
Install
npm install @google/genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
const{GoogleGenAI}=require('@google/genai');constGOOGLE_CLOUD_PROJECT=process.env.GOOGLE_CLOUD_PROJECT;constGOOGLE_CLOUD_LOCATION=process.env.GOOGLE_CLOUD_LOCATION||'global';asyncfunctiongenerateWithThoughts(projectId=GOOGLE_CLOUD_PROJECT,location=GOOGLE_CLOUD_LOCATION){constclient=newGoogleGenAI({vertexai:true,project:projectId,location:location,});constresponse=awaitclient.models.generateContent({model:'gemini-2.5-pro',contents:'solvex^2+4x+4=0',config:{thinkingConfig:{includeThoughts:true,},},});console.log(response.text);// Example Response:// Okay, let's solve the quadratic equation x² + 4x + 4 = 0.// ...// **Answer:**// The solution to the equation x² + 4x + 4 = 0 is x = -2. This is a repeated root (or a root with multiplicity 2).for(constpartofresponse.candidates[0].content.parts){if(part &&part.thought){console.log(part.text);}}// Example Response:// **My Thought Process for Solving the Quadratic Equation**//// Alright, let's break down this quadratic, x² + 4x + 4 = 0. First things first:// it's a quadratic; the x² term gives it away, and we know the general form is// ax² + bx + c = 0.//// So, let's identify the coefficients: a = 1, b = 4, and c = 4. Now, what's the// most efficient path to the solution? My gut tells me to try factoring; it's// often the fastest route if it works. If that fails, I'll default to the quadratic// formula, which is foolproof. Completing the square? It's good for deriving the// formula or when factoring is difficult, but not usually my first choice for// direct solving, but it can't hurt to keep it as an option.//// Factoring, then. I need to find two numbers that multiply to 'c' (4) and add// up to 'b' (4). Let's see... 1 and 4 don't work (add up to 5). 2 and 2? Bingo!// They multiply to 4 and add up to 4. This means I can rewrite the equation as// (x + 2)(x + 2) = 0, or more concisely, (x + 2)² = 0. Solving for x is now// trivial: x + 2 = 0, thus x = -2.//// Okay, just to be absolutely certain, I'll run the quadratic formula just to// double-check. x = [-b ± √(b² - 4ac)] / 2a. Plugging in the values, x = [-4 ±// √(4² - 4 * 1 * 4)] / (2 * 1). That simplifies to x = [-4 ± √0] / 2. So, x =// -2 again – a repeated root. Nice.//// Now, let's check via completing the square. Starting from the same equation,// (x² + 4x) = -4. Take half of the b-value (4/2 = 2), square it (2² = 4), and// add it to both sides, so x² + 4x + 4 = -4 + 4. Which simplifies into (x + 2)²// = 0. The square root on both sides gives us x + 2 = 0, therefore x = -2, as// expected.//// Always, *always* confirm! Let's substitute x = -2 back into the original// equation: (-2)² + 4(-2) + 4 = 0. That's 4 - 8 + 4 = 0. It checks out.//// Conclusion: the solution is x = -2. Confirmed.returnresponse.text;}Thought signatures
Thought signatures are encrypted representations of the model's internal thoughtprocess that preserve the Gemini reasoning state during multi-turnconversations, especially when usingfunctioncalling.
To ensure the model maintains full context across multiple turns of aconversation, you must return the thought signatures from previous responses inyour subsequent requests, regardless of the thinking level used. If you areusing the official Google Gen AI SDK (Python, Node.js, Go, orJava) and using the standard chat history features or appending the full modelresponse to the history, thought signatures are handled automatically.
For more information, seeThought signatures.
Prompting techniques
Effective prompting is crucial for maximizing the benefits of theGemini thinking models. This section outlines some prompting practicesfor thinking models.
Begin with general instructions that describe the preferred outcome. Start with alow-complexity prompt and observe the model's initial thoughts on how to respond.
Describe the most unusual or striking architectural feature you've ever seen in a building or structure. <...>The most unusual architectural feature that has truly stayed with me is the "floating roof" of the Heydar Aliyev Center in Baku, Azerbaijan, designed by Zaha Hadid Architects.Visually, it's breathtaking. Imagine a vast, undulating landscape of pure white, seemingly drapedover the building. It's not just a roof in the traditional sense; it's an extension of the ground,flowing seamlessly upwards and over the building's various spaces before curving back down to meetthe earth again. There are no sharp angles, no rigid lines. Instead, everything is fluid, organic,and continuous. It resembles a giant, pristine white wave frozen in motion, or perhaps a sand dunesculpted by an unseen wind.<...> |
Provide step-by-step instructions
If the initial attempt does not yield the expected result, refine your prompt byproviding more explicit step-by-step instructions to guide Geminithrough the problem-solving process for a more focused approach. This allows yousteer the model's initial understanding of the task with explicit suggestionsand guidance.
Now imagine that architectural feature is not just for looks, but has a specific function orpurpose related to the building's environment or the people who use it. Explain what thatfunction could be and how it enhances the building's overall design and usability. <...>Let's imagine that the "floating roof" of the Heydar Aliyev Center is not purely aesthetic butserves a crucial environmental and user-centric function: it's designed as a sophisticated climatemoderator and natural ventilation system for the Baku environment.Here's how this function would work and enhance the building:Function: Passive Climate Control and Natural Ventilation SystemShading and Solar Heat Mitigation: The undulating curves of the white GFRC roof are strategicallyshaped and oriented to provide optimal shading throughout the day, year-round. Baku experiencesintense sun, especially during the summer. The overhanging curves, acting like giant brise-soleils,would block direct sunlight from hitting the building's glass facade, significantly reducing solarheat gain. The varying heights and depths of the curves would create dynamic shade patterns, ensuringthat different parts of the building are shaded at different times of the day, optimizing comfortand reducing the need for excessive air conditioning. The white color of the GFRC further enhancesthis by reflecting a large portion of the solar radiation.<...> |
Multishot prompting with thinking
Multishot prompting in conjunction with thinking can further enhanceGemini's understanding and improve the accuracy of its responses.Provide several examples of input-output pairs, demonstrating the preferredbehavior and output format in your prompt.
Example 1:User: What is the tallest mountain in the world?Assistant: Mount EverestExample 2:User: What is the largest ocean?Assistant: Pacific OceanUser: What is the longest river in the world?Assistant: Amazon River |
Defining output and behavior
When building an application where users will interact directly with the model,you may want to provide guidance for how Gemini's output and responseswill sound and be formatted.
System instructions
System instructions are a set of instructions that the model processes before itprocesses prompts. They are recalled each time the model is prompted and tellthe model how you want it to behave and respond. For example, you can includethings like the role or persona, contextual information, and formattinginstructions.
System Instruction: You are a helpful and concise coding tutor. Always provide code examples and explain them briefly.User Prompt: Explain what is a closure in Javascript and give an example. function outerFunction(outerVar) { function innerFunction(innerVar) { console.log(outerVar); // Accessing outerVar from outerFunction's scope console.log(innerVar); } return innerFunction; } const closureExample = outerFunction('I am from outer'); closureExample('I am from inner');Explanation:A closure is created when a function (innerFunction in this example) is defined inside another function(outerFunction) and the inner function remembers and has access to the variables from the outerfunction's scope, even after the outer function has finished executing.In the example:outerFunction is called with 'I am from outer' and returns innerFunction.closureExample now holds a reference to innerFunction.When closureExample('I am from inner') is called, innerFunction executes.Even though outerFunction has already finished, innerFunction can still access and use outerVar(which is 'I am from outer') because of the closure.In essence, the innerFunction "closes over" the variables of its outer function's scope, creatinga closure. |
Verification and reflection
Include specific verification steps in either the system instructions or yourprompts directly. For example, ask Gemini to verify its sources, reviewits reasoning, identify potential errors, and check its final answer.
Verify the following statement and provide your sources: The capital of Brazil is Rio de Janeiro. The statement "The capital of Brazil is Rio de Janeiro" is incorrect.The current capital of Brazil is Brasília.Rio de Janeiro was the capital of Brazil for a significant period, from 1763 to 1960. However, thecapital was moved to Brasília in 1960 as part of a plan to develop the country's interior and createa more centrally located capital.Verification and Sources:You can easily verify this information from numerous reliable sources:Encyclopedias:Britannica: Searching for "Brazil" on Britannica will clearly state Brasília as the capital.https://www.britannica.com/place/Brazil (Look for the "Capital" information in the introductory summary or "Geography" section)Wikipedia: The Wikipedia article for "Brazil" also states Brasília as the capital.https://en.wikipedia.org/wiki/Brazil (Look in the infobox or introductory section)Government and Official Sources:CIA World Factbook: This is a highly reliable source for country information. Searching for "Brazil"will list Brasília as the capital.https://www.cia.gov/the-world-factbook/countries/brazil/ (Look under "Government" > "Capital")Official Website of the Brazilian Government (if accessible and in English): While navigating officialgovernment websites can sometimes be complex, they would definitively list Brasília as the capital.Geographic Resources:National Geographic: Their website and publications will confirm Brasília as the capital of Brazil.Atlases and Geography Textbooks: Any modern atlas or geography textbook will list Brasília as the capital.Why the confusion?The confusion might arise because:Rio de Janeiro is a very famous Brazilian city: It's a major tourist destination, known for itsbeaches, Carnival, and iconic landmarks like Christ the Redeemer. Its past status as capital addsto its historical significance and public recognition.Historical context: Rio de Janeiro was the capital for a long time. People who learned about Brazilin the past might remember it as the capital.In conclusion, the statement is false. The capital of Brazil is Brasília, not Rio de Janeiro. Riode Janeiro was the former capital but is no longer the current capital.You can confidently use the sources listed above to verify this information. |
Debugging and steering
Vertex AI Studio provides developers access to the model's thoughts inthe UI. This is helpful as a developer reviewing your prompt when debugging:
Analyze the thought process
Carefully review Gemini's thought process to identify any areas whereit may have gone astray. This analysis can provide valuable clues for refiningyour prompts and getting your expected response consistently in yourapplication.
Example Scenario: If Gemini's thought process shows it misunderstood a step ina complex instruction, you can refine the prompt to clarify that specific step.
Step 1: Summarize the following article about quantum physics.Step 2: Translate the summary into Spanish.Step 3: Extract the key entities from the Spanish summary.Article: ... [Article Text] ... The user wants me to process an article about Google's new quantum chip called Willow in three steps:Step 1: Summarize the article.Step 2: Translate the summary into Spanish.Step 3: Extract the key entities from the Spanish summary.Let's break down each step.Step 1: Summarize the article.I need to read the article and identify the main points. The article is about Google's new quantumchip, Willow, and its achievements. The key achievements are:Exponential error reduction as qubits scale up.Outperforming supercomputers in a benchmark computation (RCS).Willow is a step towards commercially relevant quantum computing.It's the first system below threshold for quantum error correction.It achieved a benchmark computation in under 5 minutes that would take a supercomputer 10 septillion years.It was fabricated in a new facility.It has state-of-the-art performance and high quality qubits.Google is looking towards real-world applications with Willow.Quantum computing will benefit AI.I will synthesize these points into a concise summary.Step 2: Translate the summary into Spanish.Once I have the summary in English, I will translate it into Spanish. I need to ensure the translationis accurate and natural-sounding in Spanish.Step 3: Extract the key entities from the Spanish summary.After translating the summary, I will identify and extract the key entities. Key entities are typicallynouns or noun phrases that represent important objects, concepts, or actors. In this context, theywill likely include:Names of chips (Willow, Sycamore)Companies/Organizations (Google Quantum AI, Google Research)Technologies (quantum chip, quantum computer, qubits, quantum error correction, superconductingquantum system, classical computers, supercomputers, AI)Benchmarks (random circuit sampling, RCS)People (Julian Kelly, Peter Shor, David Deutsch, Sergio Boixo, Hartmut Neven, John Preskill)Concepts (exponential error reduction, below threshold, beyond breakeven, state-of-the-art performance,commercially relevant applications, quantum mechanics, multiverse, T1 times, system benchmarks,algorithmic benchmarks)I will need to carefully review the Spanish summary to identify these entities and list them out. |
Provide corrective feedback
If you observe errors or inconsistencies in Gemini's reasoning, providecorrective feedback in your prompt and the system instructions to anticipatewhere the model's response may deviate from your desired outcome.
You are an expert in botany. When asked to identify a plant, focus on leaf shape, flower structure, and stem characteristics.Identify this plant based on these characteristics: ... [Plant Characteristics Description] ...Previous incorrect response focused on habitat only. Please disregard habitat and focus on morphology. Previous incorrect response focused on habitat only. Please disregard habitat and focus on morphology. Tabebuia vellosoi |
Making the best of long outputs and long-form thinking
Thinking generates "thoughts" as part of the Token Output that showcasesGemini's detailed reasoning. To make the most of these outputs:
Review the reasoning
Pay close attention to Gemini's reasoning process (available in theVertex AI Studio UI), how it broke down the task and the choices itmade for your output. This can help you understand how it arrived at itsconclusion.
Provide guidance in reasoning
If you want your output to be particularly lengthy, you may want to provide moreguidance in your prompt to constrain the amount of thinking needed to accomplishthe task presented in the prompt. This lets you reserve more of the token outputfor your response.
*Example: For a detailed report, you might specify sections and subsections inyour prompt to guide Gemini's thinking and structure the output efficiently.
Generate a detailed report on the impact of climate change on coastal ecosystems.Report Structure:IntroductionRising Sea Levels2.1. Impact on Mangroves2.2. Impact on Coral ReefsOcean Acidification3.1. Impact on Shellfish3.2. Impact on PlanktonExtreme Weather Events4.1. Increased Storm Intensity4.2. Coastal ErosionConclusionProvide detailed analysis within each section. <...>Climate Change Impact on Coastal Ecosystems: A Detailed Report1. IntroductionCoastal ecosystems, the dynamic interface between land and sea, are among the most productive andbiodiverse environments on Earth. They provide crucial ecosystem services, including coastal protection,fisheries, carbon sequestration, and support for a vast array of species. However, these vitalecosystems are increasingly threatened by the multifaceted impacts of climate change. Driven byanthropogenic greenhouse gas emissions, climate change is manifesting in several interconnected waysthat are profoundly altering the physical and chemical conditions of coastal environments. This reportwill delve into the key impacts of climate change on coastal ecosystems, focusing on rising sea levels,ocean acidification, and extreme weather events, and their specific consequences for critical habitatslike mangroves and coral reefs, and key organisms like shellfish and plankton. Understanding theseimpacts is crucial for developing effective conservation and management strategies to mitigate thedamage and enhance the resilience of these invaluable ecosystems.2. Rising Sea LevelsRising sea levels are a direct and significant consequence of global warming, driven by thermalexpansion of seawater and the melting of land ice (glaciers and ice sheets). This phenomenon poses adirect threat to low-lying coastal ecosystems by inundating habitats, altering salinity regimes, andincreasing erosion rates. The rate of sea level rise is accelerating, and projections for the 21stcentury indicate a continued upward trend, with potentially devastating consequences for coastalenvironments.2.1. Impact on MangrovesMangrove forests are unique coastal ecosystems found in tropical and subtropical intertidal zones.They provide numerous benefits, including coastal protection against storms, nursery grounds forfish and invertebrates, and significant carbon sequestration...<...> |
Pricing
You are charged for the tokens that are generated during a model's thinkingprocess. For some models, such as Gemini 3 Pro andGemini 2.5 Pro, thinking is enabled bydefault and you are billed for these tokens.
For more information, seeVertex AI pricing.To learn how to manage costs, seeControl the thinking budget.
What's next?
Try using a thinking model for yourself with ourColabnotebook,or open theVertex AIconsole and try prompting the model for yourself.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-17 UTC.
Open in Colab
Open in Colab Enterprise
Openin Vertex AI Workbench
View on GitHub