Scan your repo for retiring Google image and TTS ids (Python)

A 30-line Python scanner that finds Imagen 4, Nano Banana and Gemini TTS preview ids in your files and prints the replacement Google names for each one.

4 min readSume
All posts

Run the script below from your repo root. It walks every text file and prints each Google image or TTS model id that Google's deprecations page lists for retirement, with the replacement Google names. The ids come from the rows read on October 7, 2026. It needs only the Python standard library.

The scanner

Pass a folder as the first argument, or run it with none to scan the current one. The pattern refuses a match that sits inside a longer id, so gemini-3.1-flash-image does not fire on gemini-3.1-flash-image-preview; each id is reported once under its own name.

import os
import re
import sys
NB, TTS = "gemini-nano-banana-2.1", "gemini-3.8-flash-tts / -lite-tts"
RETIRING = {
    "imagen-4.0-generate-001": NB,
    "imagen-4.0-ultra-generate-001": NB,
    "imagen-4.0-fast-generate-001": NB,
    "gemini-2.5-flash-image": "gemini-3.1-flash-lite-image",
    "gemini-3.1-flash-image": NB,
    "gemini-3.1-flash-image-preview": NB,
    "gemini-3-pro-image-preview": "gemini-3-pro-image",
    "gemini-3.1-flash-tts-preview": TTS,
    "gemini-2.5-flash-preview-tts": TTS,
    "gemini-2.5-pro-preview-tts": TTS,
}
ids = "|".join(map(re.escape, sorted(RETIRING, key=len, reverse=True)))
PATTERN = re.compile(rf"(?<![\w.-])({ids})(?![\w.-])")
root = sys.argv[1] if len(sys.argv) > 1 else "."
for folder, dirs, files in os.walk(root):
    dirs[:] = [d for d in dirs if d not in {".git", "node_modules", ".venv"}]
    for name in files:
        path = os.path.join(folder, name)
        try:
            with open(path, encoding="utf-8") as fh:
                for no, line in enumerate(fh, 1):
                    for m in PATTERN.finditer(line):
                        print(f"{path}:{no}: {m.group(1)} -> {RETIRING[m.group(1)]}")
        except (UnicodeDecodeError, OSError):
            pass

What the ids mean

The ids cover three groups. Two of the groups are on a clock.

Ids in the scanner and their dates on Google's deprecations page (read 2026-10-07)
Id groupDateStatus on Oct 7
imagen-4.0-*-generate-001Aug 17, 2026Already past
gemini-3.1-flash-image-preview, gemini-3-pro-image-previewJun 25, 2026Already past
gemini-3.1-flash-tts-preview, 2.5 TTS previewsNov 17, 2026Upcoming
gemini-2.5-flash-imageMar 15, 2027 (Oct 2, 2026 on the pricing page)Verify now
gemini-3.1-flash-imageNone announcedDeprecated Oct 6

After the scan

  • Fix the past-date ids first, since those calls should already fail.
  • Change the TTS ids before November 17 and listen to the output first.
  • Treat gemini-3.1-flash-image as a to-do, not an emergency: Google lists no shutdown date.
  • Also search environment files, CI settings and docs, which the walk includes only if they are text and not in the skipped folders.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume