
Migrate to Gemini 3.7 Flash: The minimal Thinking Trap
Summary
Preflight your configs for gemini-3.7-flash: 5 breaking changes, a validator, real cost math.
Google shipped Gemini 3.7 Flash on August 13, 2026, three weeks after 3.6 Flash and, oddly, before Gemini 3.5 Pro. It went straight to GA. The benchmark jumps are not subtle: DeepSWE v1.1 went from 49.0% to 65.3%, AutomationBench from 17.0% to 30.4%, FrontierCode 1.1 Main from 34.4% to 43.6%. Google also cut the introductory price to $0.75 per million input tokens and $3.75 per million output, half what 3.6 Flash originally cost.
So everybody is swapping their model string. And a lot of them are getting a 400 back.
The reason is small and easy to miss. Gemini 3.7 Flash supports three thinking levels: low, medium, high. Gemini 3.6 Flash supported four. The one that vanished is minimal — the exact level you picked for your cheap, high-volume classifier calls. It does not degrade gracefully. It returns an error. And because minimal was the right answer on 3.6, the calls most likely to break are the ones you run most often.
This guide walks through every breaking change between 3.6 and 3.7 Flash, then builds a preflight validator that finds them across your codebase before you deploy. You end up with a script you can drop into CI, a patched config for every call site, and honest arithmetic on what thinking_level costs you per month.
What actually changed
Google's migration checklist for 3.7 Flash lists five things to fix. Only one of them is new to 3.7; the rest are Gemini 3.x-wide changes that bite anyone still carrying 3.5-era or 2.5-era config objects around.
| Config field | Status on gemini-3.7-flash | What to do |
|---|---|---|
| thinking_level: 'minimal' | Rejected — only low, medium, high | Use 'low'; it is the nearest level |
| thinking_budget: <int> | Not a Gemini 3.x field | Replace with the thinking_level enum |
| temperature / top_p / top_k | Unsupported sampling params | Delete them |
| candidate_count | Unsupported in Gemini 3.x | Ask for variants in the prompt |
| Prefilled model turn | Rejected by turn validation | Drop the prefill |
Two more things are worth knowing even though they are not errors. The default thinking level on 3.7 Flash is medium, so a config that simply omits thinking_level is silently choosing the middle of the cost curve. And multi-turn state is now expected to run server-side through previous_interaction_id rather than you replaying history yourself.
Capabilities that did not change: 1,048,576 input tokens, 65,536 output tokens, and the same built-in tool suite as 3.6 Flash — Google Search, Maps grounding, code execution, URL context, file search, structured outputs, function calling, and computer use in preview. There is no image generation, no audio generation, and no Live API support on this model.
Prerequisites
- Python 3.10 or newer
- A Gemini API key from AI Studio, exported as
GEMINI_API_KEY pip install google-genai- An existing codebase that calls a Gemini 3.x model — the validator is most useful when pointed at real config objects
Everything below uses the Interactions API (client.interactions.create), which went GA earlier this year and is what Google now recommends for new work. If you are still on generateContent, the breaking changes are identical; only the call shape differs.
Step 1: Confirm the model answers at all
Start with the smallest possible request. If this fails, the problem is your key or your SDK version, not the migration.
from google import genai
client = genai.Client() # reads GEMINI_API_KEY from the environment
interaction = client.interactions.create(
model="gemini-3.7-flash",
input="In one sentence: what is a thought signature?",
)
print(interaction.output_text)
print("usage:", interaction.usage.total_input_tokens,
"in /", interaction.usage.total_output_tokens,
"out /", interaction.usage.total_thought_tokens, "thought")
Note that third usage counter. total_thought_tokens is reported separately from output tokens but is billed at the output rate. On a reasoning model this is usually the single largest line on your invoice, and it is invisible if you only log total_output_tokens.
Step 2: Reproduce the minimal trap
Now the actual failure. This config is a straight copy of a perfectly valid 3.6 Flash call:
# Valid on gemini-3.6-flash. Fails on gemini-3.7-flash.
interaction = client.interactions.create(
model="gemini-3.7-flash",
input="Classify this ticket as bug, feature, or question: 'Export button spins forever'",
generation_config={
"thinking_level": "minimal", # <-- 3.6 accepted this
"temperature": 0.0, # <-- so did 3.5
},
)
Two separate problems in four lines. The temperature field was dropped across Gemini 3.x, and minimal is not in 3.7 Flash's enum. The fix is unglamorous:
interaction = client.interactions.create(
model="gemini-3.7-flash",
input="Classify this ticket as bug, feature, or question: 'Export button spins forever'",
generation_config={
"thinking_level": "low", # nearest supported level
},
)
print(interaction.output_text)
# -> Bug
Do not reach for medium here out of caution. On a one-token classification, medium can generate a couple of thousand thought tokens for an answer that does not need them, and you pay output rates for every one. low is the honest replacement for minimal.
Here is the level table, straight from the thinking docs, so you can see exactly which models kept minimal:
| Model | Default | Levels supported |
|---|---|---|
| gemini-3.7-flash | medium | low, medium, high |
| gemini-3.6-flash | medium | minimal, low, medium, high |
| gemini-3.5-flash | medium | minimal, low, medium, high |
| gemini-3.1-pro-preview | high | low, medium, high |
| gemini-3-pro-preview | high | low, high |
Step 3: Build the preflight validator
Finding these by grepping for minimal works until someone builds a config dict from a settings file. A better move is a small function that takes a call site's model, config, and contents, and returns both a list of findings and a patched config you can diff against the original.
Save this as preflight.py:
"""preflight.py - static audit of Gemini configs before you flip to 3.7 Flash."""
from dataclasses import dataclass, field
# thinking_level support, per ai.google.dev/gemini-api/docs/thinking
THINKING_LEVELS = {
"gemini-3.7-flash": {"low", "medium", "high"},
"gemini-3.6-flash": {"minimal", "low", "medium", "high"},
"gemini-3.5-flash": {"minimal", "low", "medium", "high"},
"gemini-3.1-pro-preview": {"low", "medium", "high"},
"gemini-3-pro-preview": {"low", "high"},
}
# Dropped across Gemini 3.x. Value = what to do instead.
REMOVED_KEYS = {
"temperature": "delete it; Gemini 3.x ignores sampling params and rejects the field",
"top_p": "delete it",
"top_k": "delete it",
"candidate_count": "delete it; ask for n variants in the prompt instead",
"thinking_budget": "replace with thinking_level ('low' | 'medium' | 'high')",
}
def budget_to_level(budget: int) -> str:
"""Rough mapping from the old integer budget to the new enum."""
if budget <= 1024:
return "low"
if budget <= 8192:
return "medium"
return "high"
@dataclass
class Finding:
severity: str # "error" blocks the request, "warn" is a silent behaviour change
where: str
message: str
fix: str
@dataclass
class Report:
call_site: str
findings: list = field(default_factory=list)
patched_config: dict = field(default_factory=dict)
@property
def blocking(self) -> bool:
return any(f.severity == "error" for f in self.findings)
Now the audit itself. It walks the removed keys first, then checks the thinking level against the target model's enum, then looks for a trailing prefilled model turn.
def preflight(call_site: str, model: str, generation_config: dict,
contents: list | None = None,
target: str = "gemini-3.7-flash") -> Report:
"""Audit one call site against the target model. Returns findings + patched config."""
rep = Report(call_site=call_site)
cfg = dict(generation_config or {})
allowed = THINKING_LEVELS.get(target, {"low", "medium", "high"})
# 1. Removed keys.
for key, advice in REMOVED_KEYS.items():
if key in cfg:
if key == "thinking_budget":
level = budget_to_level(int(cfg.pop(key)))
cfg.setdefault("thinking_level", level)
rep.findings.append(Finding(
"error", key,
f"thinking_budget is not a Gemini 3.x field (was {generation_config[key]})",
f"{advice} -> mapped to thinking_level='{level}'"))
else:
cfg.pop(key)
rep.findings.append(Finding(
"error", key, f"{key} is not supported on {target}", advice))
# 2. The minimal trap: legal on 3.6, a hard error on 3.7.
level = cfg.get("thinking_level")
if level is not None and level not in allowed:
old_ok = level in THINKING_LEVELS.get(model, set())
note = f"'{level}' was valid on {model} but " if old_ok else ""
cfg["thinking_level"] = "low" if level == "minimal" else "medium"
rep.findings.append(Finding(
"error", "thinking_level",
f"{note}{target} only accepts {sorted(allowed)}",
f"'{level}' -> '{cfg['thinking_level']}' (nearest supported level)"))
# 3. Prefilled model turns are rejected by turn validation.
for i, turn in enumerate(contents or []):
if turn.get("role") == "model" and i == len(contents) - 1:
rep.findings.append(Finding(
"error", f"contents[{i}]", "trailing prefilled model turn",
"drop the prefill; move the constraint into the prompt "
"or use structured outputs"))
# 4. Silent behaviour changes worth knowing about.
if "thinking_level" not in cfg:
rep.findings.append(Finding(
"warn", "thinking_level",
f"unset, so {target} defaults to 'medium'",
"set it explicitly so a future default change cannot move your bill"))
if cfg.get("thinking_summaries") in (None, "none") and level in (None, "high"):
rep.findings.append(Finding(
"warn", "thinking_summaries",
"you pay for thought tokens but never see them",
"set thinking_summaries='auto' while you tune, then turn it off"))
rep.patched_config = cfg
return rep
And a renderer so CI output is readable:
def render(reports: list) -> None:
errs = sum(1 for r in reports for f in r.findings if f.severity == "error")
warns = sum(1 for r in reports for f in r.findings if f.severity == "warn")
for rep in reports:
flag = "BLOCKED" if rep.blocking else "ok"
print(f"\n{rep.call_site} [{flag}]")
for f in rep.findings:
tag = "E" if f.severity == "error" else "W"
print(f" {tag} {f.where}: {f.message}")
print(f" -> {f.fix}")
print(f" patched: {rep.patched_config}")
print(f"\n{len(reports)} call sites | {errs} blocking | {warns} advisory")
Step 4: Run it against real call sites
Feed it the configs from your codebase. Four representative ones, including a clean control so you can tell the validator is not just flagging everything:
if __name__ == "__main__":
CALL_SITES = [
("agents/triage.py:41", "gemini-3.6-flash",
{"thinking_level": "minimal", "temperature": 0.2}, None),
("agents/planner.py:88", "gemini-3.5-flash",
{"thinking_budget": 16000, "top_p": 0.95, "candidate_count": 2}, None),
("web/summarize.py:12", "gemini-3.6-flash",
{"thinking_level": "high"},
[{"role": "user", "parts": ["summarize"]},
{"role": "model", "parts": ["Summary:"]}]),
("jobs/nightly.py:7", "gemini-3.6-flash",
{"thinking_level": "medium"}, None),
]
render([preflight(site, model, cfg, contents)
for site, model, cfg, contents in CALL_SITES])
Running python3 preflight.py gives you this, verbatim:
agents/triage.py:41 [BLOCKED]
E temperature: temperature is not supported on gemini-3.7-flash
-> delete it; Gemini 3.x ignores sampling params and rejects the field
E thinking_level: 'minimal' was valid on gemini-3.6-flash but gemini-3.7-flash only accepts ['high', 'low', 'medium']
-> 'minimal' -> 'low' (nearest supported level)
patched: {'thinking_level': 'low'}
agents/planner.py:88 [BLOCKED]
E top_p: top_p is not supported on gemini-3.7-flash
-> delete it
E candidate_count: candidate_count is not supported on gemini-3.7-flash
-> delete it; ask for n variants in the prompt instead
E thinking_budget: thinking_budget is not a Gemini 3.x field (was 16000)
-> replace with thinking_level ('low' | 'medium' | 'high') -> mapped to thinking_level='high'
W thinking_summaries: you pay for thought tokens but never see them
-> set thinking_summaries='auto' while you tune, then turn it off
patched: {'thinking_level': 'high'}
web/summarize.py:12 [BLOCKED]
E contents[1]: trailing prefilled model turn
-> drop the prefill; put the constraint in the prompt or use structured outputs
W thinking_summaries: you pay for thought tokens but never see them
-> set thinking_summaries='auto' while you tune, then turn it off
patched: {'thinking_level': 'high'}
jobs/nightly.py:7 [ok]
patched: {'thinking_level': 'medium'}
4 call sites | 6 blocking | 2 advisory
Three of four call sites would have failed in production. The patched line is the payload: paste it back into the call site and you are done. Wire this into CI by exiting non-zero when any report is blocking.
Step 5: Watch the model think, then stop paying for it
Once the configs are clean, tune the level. You cannot do that blind, so turn thought summaries on temporarily. Summaries are off by default; thinking_summaries: 'auto' surfaces them as dedicated thought steps in the response.
from google import genai
client = genai.Client()
PROMPT = ("A retry loop in our payment worker occasionally double-charges. "
"The lock is acquired after the idempotency check. What is the race?")
for level in ("low", "medium", "high"):
interaction = client.interactions.create(
model="gemini-3.7-flash",
input=PROMPT,
generation_config={
"thinking_level": level,
"thinking_summaries": "auto",
},
)
summaries = [s for s in interaction.steps if s.type == "thought"]
u = interaction.usage
print(f"{level:<7} thought={u.total_thought_tokens:<6} "
f"output={u.total_output_tokens:<6} thought_steps={len(summaries)}")
Two things to handle in real code. A thought step always carries a signature but its summary may be empty — on simple prompts the model does not reason enough to produce one, and image latents may have no text summary at all. Always guard on if step.summary. Second, summaries are a debugging aid, not a production feature: you pay for the full thought tokens either way, so leaving them on just adds bytes to your response.
For streaming, thought content arrives as step.delta events with delta.type == 'thought_summary', and the signature lands in the final delta before step.stop. That ordering matters if you are buffering.
Worked example: what the level actually costs
Concrete scenario. A nightly triage agent reads 200 GitHub issues a day, feeds each one about 12,000 tokens of repo context, and writes an 800-token verdict. The only variable is thinking_level.
"""cost.py - what a thinking_level choice actually costs on gemini-3.7-flash."""
INTRO = (0.75, 3.75) # $/1M in, $/1M out - through 2026-12-31
STANDARD = (1.50, 7.50) # $/1M in, $/1M out - from 2027-01-01
def daily_cost(runs, input_tok, output_tok, thought_tok, rates):
"""Thought tokens bill at the output rate. That is the whole trick."""
in_rate, out_rate = rates
billed_in = runs * input_tok
billed_out = runs * (output_tok + thought_tok)
return billed_in / 1e6 * in_rate + billed_out / 1e6 * out_rate
RUNS, INPUT, OUTPUT = 200, 12_000, 800
print(f"{'thinking_level':<16}{'thought tok':>12}{'$/day intro':>14}"
f"{'$/mo intro':>12}{'$/mo 2027':>12}")
for level, thought in [("low", 400), ("medium", 1_500), ("high", 6_000)]:
d_intro = daily_cost(RUNS, INPUT, OUTPUT, thought, INTRO)
d_std = daily_cost(RUNS, INPUT, OUTPUT, thought, STANDARD)
print(f"{level:<16}{thought:>12,}{d_intro:>14.2f}"
f"{d_intro * 30:>12.2f}{d_std * 30:>12.2f}")
Output:
thinking_level thought tok $/day intro $/mo intro $/mo 2027
low 400 2.70 81.00 162.00
medium 1,500 3.52 105.75 211.50
high 6,000 6.90 207.00 414.00
The thought-token figures are placeholders — measure your own with the loop from Step 5 and substitute them. The shape of the result is what matters. Going from low to high on this workload roughly triples the bill, and none of that increase shows up in your output-token dashboard unless you are specifically logging total_thought_tokens.
The right-hand column is the part people forget. Introductory pricing expires December 31, 2026. On January 1, 2027 both input and output rates double, and every number in that table doubles with them. If you are sizing a budget for next year, size it off the standard rates.
Pitfalls
- Falling back to 'medium' instead of 'low'. When a
minimalcall errors, the reflex is to pick the default. On short classification work that can multiply thought tokens by five for no accuracy gain.lowis the correct migration target forminimal. - Mapping thinking_budget by intuition. The old field was an integer token ceiling; the new one is a three-value enum. There is no exact conversion. Pick a mapping, write it down (the
budget_to_levelfunction above is a reasonable default), and re-measure — do not assume a 16,000-token budget andhighproduce comparable behaviour. - Leaving thought signatures out of stateless history. If you manage conversation state yourself, you must resend every
thoughtblock exactly as received, including when you switch models mid-session. Stripping them to save bytes breaks reasoning continuity. Usingstore: truewithprevious_interaction_idavoids the problem entirely, because the server holds the state. - Assuming a summary is always present. A thought step guarantees a
signature, not asummary. Code that doesstep.summary[0].textunguarded will crash on simple prompts. - Keeping prefilled model turns. Prefilling an assistant response to force a format was a common 2.5-era trick. Gemini 3.x turn validation rejects it. Use structured outputs instead.
- Malformed_Function_Call from pre-tool text. If your agent emits prose before a tool call and you start seeing this error after the switch, it is the known pre-tool-text issue, not your schema. Google documents workarounds on the function calling page.
- Expecting parity on non-text output. 3.7 Flash does not do image generation, audio generation, or the Live API. If your 3.6 pipeline branched into any of those, those branches need a different model.
Quick reference
| Item | Value |
|---|---|
| Model ID | gemini-3.7-flash |
| Status | GA, released 2026-08-13 |
| Context / output | 1,048,576 in / 65,536 out |
| thinking_level | low, medium, high (default medium) |
| Removed vs 3.6 | minimal thinking level |
| Removed across 3.x | temperature, top_p, top_k, candidate_count, thinking_budget |
| Intro price | $0.75 / $3.75 per 1M, through 2026-12-31 |
| Standard price | $1.50 / $7.50 per 1M, from 2027-01-01 |
| Thought tokens | usage.total_thought_tokens, billed at output rate |
| Summaries | generation_config['thinking_summaries'] = 'auto' |
| Multi-turn | store: true + previous_interaction_id |
| Not supported | image gen, audio gen, Live API |
Next steps
- Point
preflight.pyat your real config objects and add a non-zero exit on blocking findings so CI catches the next model bump. - Run the Step 5 loop on your ten highest-volume prompts and replace the placeholder thought-token counts in
cost.pywith measured values. - Move any hand-rolled conversation history to
store: trueandprevious_interaction_idso the server handles thought signatures for you. - If you use a coding agent that supports skills, Google ships a
gemini-interactions-apiskill that will do a first pass at the migration for you. - Read the primary sources before trusting any of this: the 3.7 Flash migration guide, the thinking docs, and the model card page.
Comments
Be the first to comment
Found this useful?
Get new AI guides for builders by email. Free.
Join 3,604 newsletter subscribers.