Every current Gemini model thinks before it answers, and you pay for that thinking. This guide shows how to control it from Python with the google-genai SDK, using both generateContent and the newer Interactions API.
We cover thinking levels, the old thinking budget, thought summaries, thought signatures in chats and tool calls, and a worked cost example. All facts were checked against the official docs on 5 December 2026.
- Use thinking_level: it is required for Gemini 4 and recommended for Gemini 3. Values are
minimal,low,medium,highandxhigh, but each model supports only some of them. - Defaults: Gemini 4 Neon and Hydrogen default to high and are the only models with
xhigh. Gemini 4 Carbon, Gemini 3.8 Flash and 3.6 Flash default to medium. - Thinking budget is legacy:
thinking_budgetis deprecated on Gemini 4. Sending it together withthinking_levelreturns a 400 error. - No full off switch: you cannot disable thinking on any Gemini 4 model. Use
minimalon 3.6 Flash or the Flash-Lite models, orthinking_budget=0on 2.5 Flash-Lite. - Billing: thinking tokens are billed at the output price, even though you only see a summary.
- Signatures: the SDK handles them for you. If you build history by hand, return every signature, or function calls fail with a 400.
What Gemini Thinking Is
A thinking model reasons internally before it writes the answer you see. This extra step helps with coding, maths, data analysis and multi-step agent work. It also costs tokens and adds latency.
Gemini uses dynamic thinking by default. The model decides how much to reason based on how hard the request looks. You can push it up or down with a few settings:
- thinking_level: a named depth such as
loworhigh. This is the main control on Gemini 4 and Gemini 3. - thinking_budget: a token number. This came with Gemini 2.5 and is now legacy.
- include_thoughts / thinking_summaries: asks for a readable summary of the reasoning.
- max_output_tokens: a hard cap on thinking plus answer together.
The raw thoughts are never returned. You get an optional summary and an encrypted thought signature that lets the model keep its reasoning across turns.
Note: If you use Claude or OpenAI too, the idea is the same as “effort” or “reasoning effort”. Our reasoning effort settings and API cost guide compares all three vendors side by side.
Thinking Levels per Model (Gemini 4 and 3.x)
This is the part most people get wrong. Not every model accepts every level, and the defaults differ. Here is the official table from the thinking docs, checked on 5 December 2026.
| Model ID | Default | Levels supported | Control |
|---|---|---|---|
gemini-4-carbon |
On (medium) | low, medium, high | thinking_level |
gemini-4-argon (deprecated) |
On (medium) | low, medium, high | thinking_level |
gemini-4-neon |
On (high) | low, medium, high, xhigh | thinking_level |
gemini-4-hydrogen |
On (high) | low, medium, high, xhigh | thinking_level |
gemini-3.8-flash |
On (medium) | low, medium, high | thinking_level |
gemini-3.6-flash |
On (medium) | minimal, low, medium, high | thinking_level |
gemini-3.5-flash-lite |
On (minimal) | minimal, low, medium, high | thinking_level |
gemini-3.1-pro-preview |
On (high) | low, medium, high | thinking_level |
gemini-3.1-flash-lite |
On (minimal) | minimal, low, medium, high | thinking_level |
gemini-3-flash-preview |
On (high) | minimal, low, medium, high | thinking_level |
gemini-2.5-flash-lite |
Off | budget 512 to 24,576 | thinking_budget |

What each level means
- minimal: near-off thinking and the lowest latency. Only on 3.6 Flash, the Flash-Lite models, 3 Flash Preview and Robotics ER 2. Not on Gemini 4 or 3.8 Flash.
- low: fewest tokens on Gemini 4. Good for fast chat and high-volume jobs, and still fine for simple agent tasks.
- medium: interactive coding, live UI work and quick tool calls.
- high: the recommended default on Neon and Hydrogen. It is the maximum depth on Carbon and all Gemini 3 models.
- xhigh: deepest reasoning, most tokens. Only on Neon and Hydrogen, for hard multi-step coding or agent problems.
low or medium if cost or speed matters, and try xhigh on Neon or Hydrogen only when high clearly fails. Google warns that xhigh can overthink simple prompts and use up max_output_tokens.Two recent changes matter here. Gemini 4 Argon is deprecated: from 15 December 2026 its requests route to Carbon at Carbon prices. Also, since 1 December 2026, calls to gemini-2.5-pro route to 3.8 Flash and calls to gemini-2.5-flash route to 3.5 Flash-Lite.
Can You Turn Thinking Off?
Only on some models. The docs are clear that the Gemini 4 family always thinks.
| Model | Can thinking be disabled? | Closest “off” setting |
|---|---|---|
| Gemini 4 Carbon, Argon, Neon, Hydrogen | No | thinking_level="low" |
| Gemini 3.8 Flash | No | thinking_level="low" |
| Gemini 3.6 Flash, 3 Flash Preview | No full off | thinking_level="minimal" |
| Gemini 3.5 and 3.1 Flash-Lite | No full off | minimal (already the default) |
| Gemini 3.1 Pro Preview | No | thinking_level="low" |
| Gemini 2.5 Flash-Lite | Yes (off by default) | thinking_budget=0 |
| Gemini 4 Live (Live API) | Fast mode by default | Omit thinking_level or set MINIMAL |
Even minimal is not a guarantee. Google says the model “likely will not think” but still can on a complex prompt, so you may see a few thinking tokens.
Setup Steps
You need Python 3.11 or newer, because google-genai 3.7.0 (released 2 December 2026, checked on PyPI) requires it. All examples below use that version.
- Create an API key. Open Google AI Studio, click Get API key and create one. Gemini 4 Hydrogen and the Flash models work on the free tier.
- Store the key. On macOS or Linux run
export GEMINI_API_KEY="your-key". In Windows PowerShell run$env:GEMINI_API_KEY="your-key". The SDK reads it automatically. - Install or upgrade the SDK. Run
pip install -U google-genai, then check withpip show google-genai. - Pick a model. Use
gemini-4-hydrogento start. It has a free tier and supports all four Gemini 4 levels. - Run a test. Save Example 1 as
thinking.pyand runpython thinking.py. You should see the answer plus a thinking token count.
New to the SDK? Start with our Gemini Interactions API tutorial, which covers clients, chaining and streaming.
Example 1: Set the Thinking Level
With generateContent, the level goes inside types.ThinkingConfig. This script also prints how many thinking tokens you were billed for.
from google import genai
from google.genai import types
client = genai.Client() # reads GEMINI_API_KEY
response = client.models.generate_content(
model="gemini-4-hydrogen",
contents="Provide a list of 3 famous physicists and their key contributions",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_level="low")
),
)
print(response.text)
usage = response.usage_metadata
print("Input tokens: ", usage.prompt_token_count)
print("Thought tokens: ", usage.thoughts_token_count)
print("Answer tokens: ", usage.candidates_token_count)
The same call with the Interactions API puts the level in a flat generation_config dict. Usage fields have different names here.
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="Audit this payment retry queue for race conditions and rewrite the lock logic.",
generation_config={"thinking_level": "xhigh"},
)
print(interaction.output_text)
print("Thought tokens:", interaction.usage.total_thought_tokens)
print("Output tokens: ", interaction.usage.total_output_tokens)
Tip: Google suggests testing your real prompts at every level with a generous max_output_tokens. Then pick the lowest level that still meets your quality bar.
Example 2: Thought Summaries
A thought summary is a short, readable version of the model’s reasoning. It helps you debug prompts. Summaries are available on the free and paid tiers, and the thinking level controls the raw thoughts, not the summary.
generateContent: include_thoughts
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-4-hydrogen",
contents="What is the sum of the first 50 prime numbers?",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(
include_thoughts=True,
thinking_level="medium",
)
),
)
for part in response.candidates[0].content.parts:
if not part.text:
continue
if part.thought:
print("THOUGHT SUMMARY:", part.text)
else:
print("ANSWER:", part.text)
Each part has a thought boolean. Summary parts have thought=True, and answer parts do not.
Interactions API: thinking_summaries
Here the reasoning comes back as separate thought steps in interaction.steps. Set "thinking_summaries": "auto" to fill them in.
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="What is the sum of the first 50 prime numbers?",
generation_config={"thinking_summaries": "auto"},
)
for step in interaction.steps:
if step.type == "thought":
for block in (step.summary or []):
if block.type == "text":
print("THOUGHT SUMMARY:", block.text)
elif step.type == "model_output":
for block in step.content:
if block.type == "text":
print("ANSWER:", block.text)
A thought step can hold only a signature with no summary. This happens on simple prompts, when summaries are set to "none", or for image content. Always guard against an empty summary, as the code above does.
Streaming thought summaries
Streaming shows the reasoning as it happens. In the Interactions API, watch for thought_summary deltas. The thought_signature delta arrives last, just before step.stop.
from google import genai
client = genai.Client()
stream = client.interactions.create(
model="gemini-4-hydrogen",
input="Alice, Bob and Carol live in red, green and blue houses. "
"Alice is not in red. Bob is not in green. Carol is not in red or green. "
"Who lives where?",
generation_config={"thinking_summaries": "auto"},
stream=True,
)
for event in stream:
if event.event_type == "step.delta":
if event.delta.type == "thought_summary":
print("[thinking]", event.delta.content.text, end="")
elif event.delta.type == "text" and event.delta.text:
print(event.delta.text, end="")
With generateContent, use client.models.generate_content_stream() with include_thoughts=True and check part.thought on every chunk.
Example 3: The Legacy Thinking Budget
The thinking_budget parameter sets a target number of thinking tokens. It came with Gemini 2.5. Today it only matters for Gemini 2.5 Flash-Lite and a few preview models.

On Gemini 4, a budget sent alone maps to the nearest level and returns a warning. Sending both fields returns a 400 error. For Gemini 4 and Gemini 3, always use thinking_level.
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-2.5-flash-lite",
contents="Provide a list of 3 famous physicists and their key contributions",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_budget=1024)
# Turn thinking off: ThinkingConfig(thinking_budget=0)
# Dynamic thinking: ThinkingConfig(thinking_budget=-1)
),
)
print(response.text)
print("Thought tokens:", response.usage_metadata.thoughts_token_count)
- Range on 2.5 Flash-Lite: 512 to 24,576 tokens. It does not think unless you set a budget.
- 0: turns thinking off where the model allows it.
- -1: dynamic thinking, where the model picks the budget.
- Not exact: the docs say the model may overflow or underflow the budget.
Thought Signatures in Multi-Turn Chats and Tool Calls
The Gemini API does not remember earlier turns on its own. A thought signature is an encrypted snapshot of the model’s reasoning. You send it back so the model can carry on where it left off.
The rules for generateContent
- Function calls (required): on Gemini 4 and Gemini 3, the first function call part in each step carries a signature. You must return it, or the request fails with a 400 error. This applies even at
minimalon Gemini 3 Flash. - Parallel calls: only the first
functionCallpart gets a signature. Send results back as FC1, FC2, FR1, FR2, not interleaved. - Sequential calls: each step has its own signature, and you return all of them for the current turn.
- Text replies (recommended): the last part may carry a signature. Leaving it out does not error, but quality can drop.
- Do not edit parts: never join two signed parts, and never merge a signed part with an unsigned one.
Warning: The SDK handles signatures automatically only if you append the full model response content to your history. If you copy just the text or rebuild parts yourself, the signature is lost.
Multi-turn chat: let the SDK do it
from google import genai
from google.genai import types
client = genai.Client()
chat = client.chats.create(
model="gemini-4-hydrogen",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_level="medium")
),
)
print(chat.send_message("Plan a 3-step study schedule for learning SQL.").text)
print(chat.send_message("Now shorten step 2 to one day.").text)
The chat object keeps every part, signatures included. Nothing else is needed.
Function calling with manual history
This is where signatures break most often. The fix is one line: append response.candidates[0].content as it is.
from google import genai
from google.genai import types
client = genai.Client()
MODEL = "gemini-4-hydrogen"
weather_declaration = {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name, e.g. Paris"}
},
"required": ["city"],
},
}
def get_weather(city: str) -> dict:
# Replace with a real weather API call
return {"city": city, "temp_c": 14, "rain_chance": "70%"}
config = types.GenerateContentConfig(
tools=[types.Tool(function_declarations=[weather_declaration])],
thinking_config=types.ThinkingConfig(thinking_level="medium"),
)
contents = [
types.Content(role="user", parts=[types.Part(text="Do I need an umbrella in Paris today?")])
]
response = client.models.generate_content(model=MODEL, contents=contents, config=config)
if response.function_calls:
call = response.function_calls[0]
model_content = response.candidates[0].content
print("Signature present:", any(p.thought_signature for p in model_content.parts))
# 1. Keep the model turn exactly as returned (this carries the signature)
contents.append(model_content)
# 2. Add the function result
result = get_weather(**call.args)
contents.append(types.Content(
role="user",
parts=[types.Part.from_function_response(name=call.name, response={"result": result})],
))
final = client.models.generate_content(model=MODEL, contents=contents, config=config)
print(final.text)
else:
print(response.text)
For the full tool loop, parallel calls and automatic function calling, see our Gemini function calling tutorial.
Signatures in the Interactions API
The Interactions API makes this much easier. Signatures only live on thought steps and built-in tool steps such as google_search_call. They never sit on your inputs, model outputs or normal function calls.
- Stateful mode (recommended): keep
store=True(the default) and passprevious_interaction_id. The server manages all thoughts and signatures for you. - Stateless mode: if you send the full history yourself, resend every
thoughtstep exactly as received. Do not remove or edit them, even when you switch models. - Built-in tools: Google Search call and result steps carry their own signatures. Resend those too in stateless mode.
Moving a conversation from another model that has no signatures? Google’s FAQ allows the dummy values context_engineering_is_the_way_to_go or skip_thought_signature_validator to skip validation. Google strongly discourages injecting custom function calls, so use this only when you must.
Interactions API vs generateContent Syntax
Google now calls the Interactions API the recommended interface for new projects, and labels generateContent as legacy but supported. Here is how each thinking setting maps across the two.
| Task | generateContent (Python) | Interactions API (Python) |
|---|---|---|
| Call | client.models.generate_content(model, contents, config) |
client.interactions.create(model, input, generation_config) |
| Set level | ThinkingConfig(thinking_level="low") |
{"thinking_level": "low"} |
| Get summaries | ThinkingConfig(include_thoughts=True) |
{"thinking_summaries": "auto"} |
| Read summaries | parts where part.thought is True |
steps where step.type == "thought" |
| Thinking tokens | usage_metadata.thoughts_token_count |
usage.total_thought_tokens |
| Answer tokens | usage_metadata.candidates_token_count |
usage.total_output_tokens |
| Signatures live on | any part (often functionCall or last part) |
thought steps and built-in tool steps only |
| Multi-turn | client.chats or full history |
previous_interaction_id |
| Hit the token cap | finish_reason: MAX_TOKENS |
status: "incomplete" |
Settings like generation_config apply to one interaction only. Send your thinking_level again on every chained turn that needs it.
Quick curl Test
This REST call asks for thought summaries through the Interactions endpoint. It is handy for checking a key or a model name outside Python.
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-hydrogen",
"input": "What is the sum of the first 50 prime numbers?",
"generation_config": {
"thinking_level": "medium",
"thinking_summaries": "auto"
}
}'
Look for total_thought_tokens inside the usage object of the reply.
How Thinking Tokens Are Billed (Worked Example)
The rule is simple: output price x (thinking tokens + answer tokens). Google bills the full thoughts the model generated, not the shorter summary you receive.
- Thinking tokens: billed at the model’s output rate.
- Thought summaries: you do not pay extra for the summary itself. You pay for the full thinking behind it.
- Signatures: sending them back in later turns adds to your billed input tokens.
- Cut-off answers: if
max_output_tokensstops the model mid-thought, you still pay for the thinking it did.
Current prices (Standard, paid tier)
| Model | Free tier | Input / 1M | Output incl. thinking / 1M |
|---|---|---|---|
| Gemini 4 Carbon | No | $4.00 | $20.00 |
| Gemini 4 Neon | No | $3.00 | $15.00 |
| Gemini 4 Hydrogen | Yes | $1.50 | $7.50 |
| Gemini 3.8 Flash | Yes | $0.75* | $3.75* |
| Gemini 3.6 Flash | Yes | $0.75* | $3.75* |
| Gemini 3.5 Flash-Lite | Yes | $0.30 | $2.50 |
| Gemini 2.5 Flash-Lite | Yes | $0.10 | $0.40 |
Prices from the official pricing page on 5 December 2026. *3.8 Flash and 3.6 Flash double to $1.50 / $7.50 on 1 January 2027. Carbon’s introductory price ended on 30 November 2026.
Worked example: low vs high on Hydrogen
Say a support bot sends 1,200 input tokens and gets a 300-token answer. The thinking counts below are example numbers to show the maths. Your real counts will vary, so read them from thoughts_token_count.
| Item | thinking_level=”high” | thinking_level=”low” |
|---|---|---|
| Thinking tokens (example) | 2,500 | 400 |
| Billed output (thinking + answer) | 2,800 | 700 |
| Output cost (x $7.50 / 1M) | $0.0210 | $0.00525 |
| Input cost (1,200 x $1.50 / 1M) | $0.0018 | $0.0018 |
| Per request | $0.0228 | $0.00705 |
| Per 10,000 requests | $228.00 | $70.50 |
In this example, thinking is 89% of the billed output at high. That is why the level matters more than the length of your answer. For free-tier limits and the Batch and Flex discounts, see our Gemini API pricing guide.
Token Limits
| Limit | Value (official docs) |
|---|---|
| Gemini 4 context window | 1,048,576 tokens shared by input, thinking and output |
| Default output cap per request (Gemini 4) | 65,536 tokens |
| Non-streaming REST on Carbon / Argon | 32,768 tokens per request |
| Long decode | Up to 1,048,576 tokens minus input, with max_output_tokens above the cap (SDK continues automatically, or use background=True in Interactions) |
| What max_output_tokens counts | Thinking tokens plus answer tokens |
| thinking_budget range (2.5 Flash-Lite) | 512 to 24,576, or 0 / -1 |
Do not set a tiny max_output_tokens to save money. The model may spend it all on thinking and return nothing. Lower thinking_level instead.
Troubleshooting: Common Problems and Fixes
| Problem or error | Cause | Fix |
|---|---|---|
400 when sending both thinking_budget and thinking_level |
Not allowed on Gemini 4 | Remove thinking_budget and keep the level |
| Warning that thinking_budget is deprecated | Budget sent alone to a Gemini 4 model | Switch to thinking_level |
400 / INVALID_ARGUMENT for minimal |
Gemini 4 and 3.8 Flash do not support it | Use low |
Rejected xhigh |
Only Neon and Hydrogen support it | Use high on Carbon and Gemini 3 |
| “Function call … is missing a thought_signature” | Model turn rebuilt by hand without its signature | Append response.candidates[0].content unchanged |
| 400 after parallel function calls | Results interleaved (FC1, FR1, FC2, FR2) | Send FC1, FC2, then FR1, FR2 |
Empty or cut answer, MAX_TOKENS or incomplete |
Thinking used up max_output_tokens |
Raise the cap or lower the level |
| No thought summary returned | Summaries off, or the prompt was too simple | Set include_thoughts=True or thinking_summaries="auto"; handle empty summaries |
| Bill higher than expected | Default high on Neon / Hydrogen, or Argon now routes to Carbon |
Log thinking tokens per call and set a lower level |
| Thinking settings ignored on later turns | generation_config is per interaction |
Send it on every chained turn |
For quota, 429 and 500-level errors that are not about thinking, see our Gemini API errors fix guide.
Frequently Asked Questions
What is the default thinking level for Gemini 4?
Gemini 4 Neon and Hydrogen default to high. Gemini 4 Carbon and the deprecated Argon default to medium, which is also the default on Gemini 3.8 Flash and 3.6 Flash.
Can I turn off thinking on Gemini 4 Hydrogen?
No. Google says thinking cannot be disabled on any Gemini 4 model. The lowest setting is thinking_level="low".
Should I use thinking_level or thinking_budget?
Use thinking_level for Gemini 4 and Gemini 3. The budget is deprecated on Gemini 4 and is only the main control on Gemini 2.5 Flash-Lite.
Do I pay for thought summaries?
You pay for the full thinking tokens at the output rate, not for the summary text. Turning summaries on does not change how much the model thinks.
Do I need to handle thought signatures myself?
Not if you use the SDK’s chat object, append full response content, or use the Interactions API in stateful mode. You only handle them when you edit history by hand or call the REST API directly.
Which models support xhigh?
Only gemini-4-neon and gemini-4-hydrogen. Google recommends it only for hard, multi-step coding and agent problems where high falls short.
Why is my answer empty when thinking is on?
The model probably used your whole max_output_tokens on thinking. Raise the limit or choose a lower thinking level.




