Skip to content

Menu

Build

Model deprecation and migration

Inventory your dependencies against the official deprecations page and complete a rollback-safe regression swap before shutdown or automatic routing takes effect.

min read
14
Level
Intermediate
Last verified

After this page, you can inventory the models your code and configuration depend on within half an hour, judge risk dates against the official deprecations page, and complete a rollback-safe “old to new” regression. It is for teams already calling the Gemini API in production.

Specific models, dates, and replacements change every week, so this page covers method only. Dates in the text are examples shown by the official pages when checked on 2026-11-24; reopen the deprecations page before relying on them.

The official deprecations page defines its terms: deprecation is the announcement that support is ending and the model will be shut down soon, and shutdown is when the model is fully turned off and the endpoint is unavailable. The shutdown dates in the table are the earliest possible dates; Google will give the exact date in advance.

There is a third outcome: automatic routing. On the day of checking, the deprecations page stated for several older models that from a given date, API requests sent to them are routed to a named replacement model and billed at the replacement model’s rates. Requests do not fail, but behavior, latency, output format, and the bill may all change. Some models are already unselectable in AI Studio while the API endpoint still exists, and they may be routed the same way.

As of 2026-11-24 the deprecations page had such an example: the 2.5 Pro and Flash models route to newer models from 2026-12-01 and are billed at the new model’s rates, with a link to the matching migration guide. Dates like this may have passed by the time you read this page; the deprecations page governs.

“It will route automatically” does not mean “nothing to do.” Your structured-output schema, sampling parameters, thinking settings, and caching usage may all be incompatible with the replacement model.

Inventory: find every place a model is used

Section titled “Inventory: find every place a model is used”

Model IDs are not only in calling code. Search your own repository first (run the command only in your own directory):

终端窗口
grep -rn --include='*.py' --include='*.ts' --include='*.js' --include='*.yaml' --include='*.yml' --include='*.json' --include='*.env*' --include='*.md' "gemini-" .

Then check these easily missed places and record the results in a list:

Location Why it is easy to miss
Environment variables and deployment config Code uses GEMINI_MODEL, but the actual value lives on the deployment platform
Batch jobs and scheduled tasks The model ID was written at creation; changing code does not change submitted jobs
Evaluation sets and prompt-library metadata They record “tested on which model,” which needs retesting after a switch
Caching and embedding pipelines Caches are tied to a model; after changing an embedding model, vectors need rebuilding, as per the official notes
Docs, internal tutorials, copied examples New teammates copy them

List columns: location, model code, purpose, owner, matching deprecations-page entry, risk date.

Look it up: deprecations page, upgrade targets, and migration guides

Section titled “Look it up: deprecations page, upgrade targets, and migration guides”

Check in this order:

  1. The deprecations page: whether each model code you use has an entry, whether it is deprecation, shutdown, or automatic routing, and the date.
  2. The model-choice page’s “upgrade from earlier models” section: Google’s recommended upgrade target and matching migration guide.
  3. The migration guide: each target model’s what’s new page has a migration section; go through it item by item.

When you open a migration guide, focus on these kinds of change (both guides had related items on the day of checking):

  • Thinking settings: a budget-style parameter replaced by a level parameter, with different levels supported per model and some levels returning errors;
  • Sampling parameters: some new models no longer accept or will ignore temperature and similar parameters, and out-of-range values may return 400 directly;
  • Caching: some new models do not support explicit caching, only implicit caching;
  • How output limits and the context window are counted;
  • How multi-turn state and thought signatures are preserved;
  • Declaration requirements for function calling and structured output;
  • Billing basis: thinking tokens and internal tool instructions are also counted.

These are only categories; the actual values differ for every model, so follow the guide and do not judge from last generation’s experience.

Minimal example: extract the model ID and run the same evaluation set twice

Section titled “Minimal example: extract the model ID and run the same evaluation set twice”

Goal: run the same synthetic evaluation set against the old model and the candidate new model and compare key assertions. All model IDs come from environment variables.

First prepare eval-cases.json (synthetic data):

[
{"id": "c1", "input": "Rewrite \"Order A-100 has shipped\" in a support-agent tone, within 20 characters.", "must_include": ["A-100"]},
{"id": "c2", "input": "List three refund reasons, one per line, without numbering.", "must_include": []}
]

The script:

import json
import os
from google import genai
client = genai.Client() # reads the GEMINI_API_KEY environment variable
cases = json.load(open("eval-cases.json", encoding="utf-8"))
models = {"old": os.environ["GEMINI_MODEL_OLD"], "new": os.environ["GEMINI_MODEL_NEW"]}
for label, model in models.items():
passed = 0
for case in cases:
result = client.interactions.create(model=model, input=case["input"])
text = result.output_text
ok = all(token in text for token in case["must_include"])
passed += ok
print({"model_label": label, "case": case["id"], "ok": ok, "chars": len(text)})
print({"model_label": label, "passed": passed, "total": len(cases)})

Expected: each label prints a result per case and a pass count. This is only a deterministic check (whether keywords appear) and does not replace semantic review. This example was not run with a real key; to connect a real evaluation, replace the cases with your own redacted samples and keep the output as evidence.

After the evaluation passes, write a record, put it in the team docs, and create a new one for each migration:

# Migration decision record: support Q&A service
- Date: YYYY-MM-DD; owner: ____
- Trigger: the deprecations page shows `<old model code>` will route automatically to `<new model code>` from YYYY-MM-DD and be billed at the new model's rates
- Official basis: deprecations page (checked YYYY-MM-DD), model-choice upgrade-target table, matching migration-guide section
- Scope: live requests (yes/no), batch jobs (yes/no), caching (yes/no), evaluation sets (yes/no)
- Parameter changes: thinking level ____; sampling parameters ____; caching method ____; output limit ____
- Regression result: N cases, M passed; failures and handling ____
- Cost change: per the official pricing page that day, estimate ____ (write source and date, not on this page)
- Rollout and rollback: rollout percentage ____; rollback method ____ (set the environment variable back to the old value, provided the old model is still available)
- Completion criteria and review date: ____

Make the rollback plan realistic: if the old model will route automatically or shut down on a given date, “set it back to the old value” works only before that date.

Counterexample:

Start changing things only on the day an error appears; or assume “it will route automatically anyway, so no need to act.”

Rewrite:

  • Open an entry as soon as a model you use appears on the deprecations page, and keep at least one full regression cycle;
  • For models that will be routed automatically, switch proactively to an explicit new model code and run evaluation and cost estimates on the new model;
  • Do not rely on a “latest” alias for stability; see Models and quotas.
  • The model code in every location is inventoried, with an owner;
  • Each entry is checked against the deprecations page and the model-choice upgrade targets;
  • Parameter changes in the migration guide are handled one by one, and rejected parameters are no longer sent;
  • The structured output schema is re-verified on the new model;
  • The caching strategy and hit observation are retested;
  • Batch jobs, scheduled tasks, and deployment environment variables are updated;
  • Limits and prices are reassessed for the new model;
  • Regression passes, rollout is done, and the rollback plan is executable;
  • Recent changes are reviewed in What’s new.
Symptom Order of handling
Output format changes abruptly after routing takes effect Switch to an explicit new model code immediately and run the evaluation; check structured output and thinking settings
The new model returns 400 Check the migration guide; it is usually a removed or out-of-range parameter
The bill spikes Compare against “billed at the replacement model’s rates” on the deprecations page, and check that day’s prices and thinking-token usage on the pricing page
Rollback to the old model fails The old model may be shut down or routed; fix the issue on the new model instead of relying on rollback
A batch job still uses the old model Recreate the job and confirm nothing is submitted twice; see Batch and service tiers