跳到正文
DEV Community· Mustafa·· 2 小時前AI 評分61

OpenAI 停用 GPT-4o、4.1 和 5-nano:如何找出程式碼庫中的所有模型 ID

OpenAI is retiring GPT-4o, 4.1 and 5-nano: how to find every model ID in your repo

AI 導讀

Mustafa 整理 OpenAI 多個模型 ID 的停用日期,並提供 GNU grep 命令搜尋程式碼庫中的舊 ID。時間表由 2026-10-23 延伸至 2027-4-1,並指出微調模型沿用基礎模型的停用安排。搜尋命令會列出匹配次數、檔案路徑及行號,但無法找出執行時拼接的 ID、資料庫中的 ID 或第三方 SDK 預設值。

正文

Mustafa

OpenAI's deprecations page has a busy few months coming up. Some model IDs already stopped working on Oct 23, 2026. More shut down on Dec 11, then Jan 14, then Apr 1. If a model string is hard-coded in a config file, a .env, or a test fixture, you won't find out until requests start failing.

Here are the dates that matter (checked against the page on Oct 31, 2026) and a free one-liner that finds them.

The dates

Shutdown Model IDs Replacement listed by OpenAI
Already gone (Oct 23, 2026) gpt-4.1-nano, gpt-4o-2024-05-13, gpt-4-turbo, gpt-3.5-turbo, o1, o3-mini, o4-mini gpt-5.6-luna / gpt-5.6-sol / gpt-5.6-terra
Dec 1, 2026 gpt-image-1-mini, gpt-image-1.5 gpt-image-2.5-sunburst or -flare
Dec 11, 2026 gpt-5, gpt-5-mini, gpt-5-nano, gpt-5-pro, o3, o3-pro gpt-5.6-sol / -terra / -luna
Jan 6, 2027 tts-1, tts-1-hd, gpt-4o-mini-tts gpt-realtime-2.1-mini
Jan 14, 2027 gpt-4o-2024-08-06, gpt-4o-2024-11-20, gpt-4o-mini-2024-07-18, gpt-4.1-2025-04-14, gpt-4.1-mini-2025-04-14 gpt-6-luna
Jan 20, 2027 gpt-realtime, gpt-audio, gpt-4o-realtime, gpt-4o-audio and mini variants gpt-realtime-2.1 / gpt-audio-1.5
Feb 26, 2027 whisper-1, gpt-4o-transcribe, gpt-4o-mini-transcribe gpt-live-transcribe or gpt-transcribe
Apr 1, 2027 gpt-5.4-nano, gpt-5.1, gpt-5.3-codex gpt-6-luna / gpt-6-sol

This is a summary. The page lists dated snapshots for most rows, so check it for the exact ID you use. OpenAI also notes that fine-tuned models follow their base model's schedule.

One catch: the bare aliases gpt-4o, gpt-4o-mini, gpt-4.1 and gpt-4.1-mini aren't rows on the page. They point at snapshots that are on it, so treat them as Jan 14 and confirm which snapshot your account resolves them to.

The one-liner

Run this from your repo root. It needs GNU grep (for -P; on macOS, brew install grep and use ggrep):

grep -rnIoP --exclude-dir={.git,node_modules,venv,.venv,dist,build} \
  '(?<![\w.-])(gpt-4o(-mini)?(-(2024-[0-9]{2}-[0-9]{2}|tts|realtime|audio|transcribe))?|gpt-4\.1(-mini|-nano)?(-2025-04-14)?|gpt-5(-mini|-nano|-pro)?(-20[0-9]{2}-[0-9]{2}-[0-9]{2})?|gpt-5\.4-nano|gpt-5\.1|o1|o3(-mini|-pro)?|o4-mini|gpt-3\.5-turbo|gpt-4-turbo|tts-1(-hd)?|whisper-1)(?![\w.-])' . \
  | sort | uniq -c | sort -rn

It covers .env, YAML and JSON as well as code, because -r reads every text file. The lookarounds stop it matching gpt-5 inside gpt-5.6-luna. You get count path:line:match, which is enough to open a ticket per service.

Watch out for false positives. o1 and o3 are short, so the regex can catch things that aren't model names. Read the matches before you change anything.

What grep can't see

  • IDs built at runtime, like f"gpt-{version}". Search for "gpt-" string fragments too.
  • IDs stored in a database or a feature flag service. Query those directly.
  • Third-party SDK defaults. A library may pick a model for you. Check its config.
  • Other repos. Infra-as-code, notebooks and Zapier-style automations often have their own copies.

A safe swap order

  1. Fix anything that's already broken first. Those calls are failing now.
  2. Change the model ID in one place (an env var or a config constant), not across 40 files.
  3. Run your evals or a small golden set on the replacement before you switch traffic. Newer models can behave differently on structured output and tool calls.
  4. Add a CI check so the old IDs don't come back in a copy-pasted snippet.

I packaged this into a small scanner that reads the dates from a JSON file, marks rows past their date as BROKEN NOW, writes a CSV/markdown swap list and can fail a CI job. If that saves you time, it's here. The grep above works fine on its own.

來源:DEV Community · dev.to