# Find and replace retiring OpenAI models in your code before they stop working

> OpenAI shut down gpt-4, gpt-3.5-turbo, o1, o3-mini, o4-mini, gpt-4.1-nano and gpt-image-1 on Oct 23, 2026. Scan your code, check your account, and swap in the replacements.

Level: Intermediate
Tool: ChatGPT
Category: Building
Time: About 20 minutes
Checked: 2026-11-10
Tools: [OpenAI deprecations page](https://developers.openai.com/api/docs/deprecations), [OpenAI API reference: List models](https://developers.openai.com/api/reference/resources/models/methods/list), [OpenAI models](https://developers.openai.com/api/docs/models)
HTML page: https://easyaihowtos.com/guides/find-and-replace-retiring-openai-models

OpenAI shut down a batch of older API models on **October 23, 2026**, including `gpt-4`, `gpt-4-turbo`, `gpt-3.5-turbo`, `o1`, `o3-mini`, `o4-mini`, `gpt-4.1-nano`, and `gpt-image-1`. If your code still names one of them, those requests now fail. This guide gives you a short script that finds every retiring model name in your code, checks your account with `GET /v1/models`, and lists OpenAI's recommended replacement for each, so you can fix them all in one pass.

Prefer to watch? Catch the [quick video on YouTube](https://youtube.com/shorts/2anYpI23hLg).

New to the OpenAI API? Start with [Call the OpenAI Responses API in Python](/guides/call-the-openai-responses-api-in-python).

## What you need

- A project that calls the OpenAI API (any language: the scan reads Python, JavaScript, TypeScript, Go, Java, config files, and .env files)
- Python 3.8 or newer to run the checker script (it uses only the standard library, so there's nothing to install)
- Optional: your OpenAI API key, if you also want to ask your account which models are retiring
- Tests, or at least a few sample requests, to check the new model's answers

## Steps

### 1. Know what's shutting down, and when

OpenAI regularly **retires** (shuts down) older models. After a model's **shutdown date**, requests that name it fail with an error instead of an answer. So if your code, a config file, or an environment variable still says `gpt-4`, that feature stops working.

A batch of older models shut down on **October 23, 2026**. Here they are with the replacements OpenAI's deprecations page recommends:

| Model name in your code | Use instead |
| --- | --- |
| `gpt-3.5-turbo`, `gpt-3.5-turbo-0125` | `gpt-5.6-terra` |
| `gpt-4`, `gpt-4-0613`, `gpt-4-1106-preview` | `gpt-5.6-sol` |
| `gpt-4-turbo`, `gpt-4-turbo-2024-04-09` | `gpt-5.6-sol` |
| `gpt-4o-2024-05-13` (only this dated snapshot) | `gpt-5.6-sol` |
| `o1`, `o1-2024-12-17` | `gpt-5.6-sol` |
| `o1-pro`, `o1-pro-2025-03-19` | `gpt-5.6-sol` with `reasoning.mode: pro` |
| `o3-mini`, `o3-mini-2025-01-31` | `gpt-5.6-sol` |
| `o4-mini`, `o4-mini-2025-04-16` | `gpt-5.6-terra` |
| `gpt-4.1-nano`, `gpt-4.1-nano-2025-04-14` | `gpt-5.6-luna` |
| `gpt-image-1` | `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` (listed at shutdown; current models are `gpt-image-2.6-sunburst` or `gpt-image-2.6-flare`) |

Fine-tuned models built on `gpt-3.5-turbo`, `gpt-4`, `gpt-4.1-nano`, `o4-mini`, `babbage-002`, and `davinci-002` shut down the same day.

More are coming. Plain `gpt-4o`, `gpt-4o-mini`, `gpt-4.1`, and `gpt-4.1-mini` still work, but their snapshots shut down on **January 14, 2027** (replacement: `gpt-6-luna`). Older GPT-5 and o3 snapshots go on **December 11, 2026**, `gpt-image-1-mini`, `gpt-image-1.5`, and `chatgpt-image-latest` on **December 1, 2026** (replacement: `gpt-image-2.6-sunburst` or `gpt-image-2.6-flare`), and `gpt-image-2` and `gpt-image-2-2026-04-21` on **February 10, 2027** (same 2.6 replacements). Fix them all in one pass.

**Terms:** a **snapshot** is a dated, frozen version of a model, like `gpt-4o-2024-08-06`. An **alias** is the short name, like `gpt-4o`, that points to a snapshot. Each model's page lists its default snapshot.

### 2. Save the checker script

This script does two things. It reads every code and config file in a folder and flags model names on OpenAI's retirement list. With `--api`, it also asks your account which models have a shutdown date.

The list inside it was copied from OpenAI's deprecations page on Nov 10, 2026. When OpenAI announces new retirements, add them to the `add(...)` lines.

Save it as `check_models.py`, anywhere outside the project you're checking:
```python
"""Flag retiring OpenAI model names in your code (and, optionally, your account).

Usage:
  python check_models.py path/to/your/project
  python check_models.py path/to/your/project --api   # also asks GET /v1/models
"""
import json, os, re, sys, urllib.request
from datetime import date
from pathlib import Path

SOURCE = "https://developers.openai.com/api/docs/deprecations"  # copied 2026-11-10
# model name: (shutdown date, recommended replacement on that page)
RETIRING = {}
def add(day, names, replacement):
    for n in names.split():
        RETIRING[n] = (day, replacement)

# Shuts down October 23, 2026
add("2026-10-23", "gpt-3.5-turbo gpt-3.5-turbo-0125 gpt-3.5-turbo-completions", "gpt-5.6-terra")
add("2026-10-23", "gpt-4 gpt-4-0613 gpt-4-0613-completions gpt-4-completions "
                  "gpt-4-1106-preview gpt-4-turbo gpt-4-turbo-2024-04-09 "
                  "gpt-4-turbo-completions gpt-4o-2024-05-13 o1 o1-2024-12-17 "
                  "o3-mini o3-mini-2025-01-31", "gpt-5.6-sol")
add("2026-10-23", "o1-pro o1-pro-2025-03-19", "gpt-5.6-sol (reasoning.mode: pro)")
add("2026-10-23", "o4-mini o4-mini-2025-04-16", "gpt-5.6-terra")
add("2026-10-23", "gpt-4.1-nano gpt-4.1-nano-2025-04-14", "gpt-5.6-luna")
add("2026-10-23", "gpt-image-1", "gpt-image-2.6-sunburst or gpt-image-2.6-flare")
# Shuts down December 1, 2026
add("2026-12-01", "gpt-image-1-mini gpt-image-1.5 gpt-image-1.5-2025-12-16 chatgpt-image-latest",
    "gpt-image-2.6-sunburst or gpt-image-2.6-flare")
# Shuts down February 10, 2027
add("2027-02-10", "gpt-image-2 gpt-image-2-2026-04-21",
    "gpt-image-2.6-sunburst or gpt-image-2.6-flare")
# Shuts down December 11, 2026 (the short names point to these snapshots today)
add("2026-12-11", "gpt-5 gpt-5-2025-08-07 o3 o3-2025-04-16", "gpt-5.6-sol")
add("2026-12-11", "gpt-5-mini gpt-5-mini-2025-08-07", "gpt-5.6-terra")
add("2026-12-11", "gpt-5-nano gpt-5-nano-2025-08-07", "gpt-5.6-luna")
add("2026-12-11", "gpt-5-pro gpt-5-pro-2025-10-06 o3-pro o3-pro-2025-06-10",
    "gpt-5.6-sol (reasoning.mode: pro)")
# Shuts down January 6, 2027
add("2027-01-06", "tts-1 tts-1-hd gpt-4o-mini-tts-2025-03-20 gpt-4o-mini-tts-2025-12-15",
    "gpt-realtime-2.1-mini")
# Shuts down January 14, 2027 (the short names point to these snapshots today)
add("2027-01-14", "gpt-4o gpt-4o-2024-08-06 gpt-4o-2024-11-20 gpt-4o-mini "
                  "gpt-4o-mini-2024-07-18 gpt-4.1 gpt-4.1-2025-04-14 gpt-4.1-mini "
                  "gpt-4.1-mini-2025-04-14", "gpt-6-luna")
# Shuts down February 26, 2027
add("2027-02-26", "whisper-1 gpt-4o-transcribe gpt-4o-mini-transcribe "
                  "gpt-4o-transcribe-diarize", "gpt-live-transcribe or gpt-transcribe")
# Shuts down April 1, 2027
add("2027-04-01", "gpt-5.1", "gpt-6-sol")
add("2027-04-01", "gpt-5.3-codex gpt-5.4-nano", "gpt-6-luna")
# Already shut down
add("2026-09-28", "gpt-3.5-turbo-instruct gpt-3.5-turbo-1106 babbage-002 davinci-002",
    "gpt-5.6-terra")
add("2026-05-12", "dall-e-2 dall-e-3", "a current gpt-image model")

TOKEN = re.compile(r"(?<![\w.:-])(ft:[\w.:-]+|[a-z0-9][a-z0-9.-]*[a-z0-9])(?![\w-])")
SKIP_DIRS = {".git", "node_modules", ".venv", "venv", "__pycache__", "dist", "build", ".next"}
EXTS = {".py", ".js", ".ts", ".tsx", ".jsx", ".mjs", ".java", ".go", ".rb", ".php",
        ".cs", ".rs", ".json", ".yaml", ".yml", ".toml", ".env", ".ini", ".cfg", ".sh"}

def lookup(name):
    if name.startswith("ft:"):            # fine-tuned: ft:BASE:org::id
        name = name.split(":")[1]          # follows its base model's date
    return RETIRING.get(name)

def scan(root):
    hits = []
    for path in Path(root).rglob("*"):
        if any(p in SKIP_DIRS for p in path.parts) or not path.is_file():
            continue
        if path.suffix not in EXTS and not path.name.startswith(".env"):
            continue
        try:
            lines = path.read_text(errors="ignore").splitlines()
        except OSError:
            continue
        for n, line in enumerate(lines, 1):
            for name in TOKEN.findall(line):
                if lookup(name):
                    hits.append((lookup(name)[0], str(path), n, name))
    return hits

def account_models():
    base = os.environ.get("OPENAI_BASE_URL", "https://api.openai.com/v1")
    req = urllib.request.Request(base.rstrip("/") + "/models",
        headers={"Authorization": "Bearer " + os.environ["OPENAI_API_KEY"]})
    with urllib.request.urlopen(req) as r:
        return {m["id"]: m.get("shutdown_date") for m in json.load(r)["data"]}

def main():
    if len(sys.argv) < 2:
        sys.exit(__doc__)
    today = date.today().isoformat()
    hits = sorted(scan(sys.argv[1]))
    api = account_models() if "--api" in sys.argv else {}
    for day, path, n, name in hits:
        live = api.get(name.split(":")[1] if name.startswith("ft:") else name)
        if live:
            day = live                     # trust the API's date when it has one
        status = ("SHUT DOWN" if day < today else
                  "SHUTS DOWN TODAY" if day == today else "retires")
        print(f"{path}:{n}  {name}  {status} {day} -> use {lookup(name)[1]}")
    if api:
        print("\nModels on your account with an announced shutdown date:")
        for mid, day in sorted(api.items(), key=lambda kv: str(kv[1])):
            if day:
                print(f"  {mid}  {day}")
    print(f"\n{len(hits)} line(s) to fix. List copied from {SOURCE}")
    sys.exit(1 if hits else 0)

if __name__ == "__main__":
    main()
```
It matches whole model names, so `gpt-4o` isn't mistaken for `gpt-4`. It also catches fine-tuned names like `ft:gpt-3.5-turbo-0125:your-org::abc123` and checks them against their base model.

### 3. Scan your project

Point the script at your project folder:
```bash
python3 check_models.py ~/code/my-app
```
You get one line for each place a retiring model appears, soonest date first:
```text
my-app/.env:1  o4-mini  SHUTS DOWN TODAY 2026-10-23 -> use gpt-5.6-terra
my-app/src/app.py:1  gpt-4  SHUTS DOWN TODAY 2026-10-23 -> use gpt-5.6-sol
my-app/src/app.py:3  gpt-4o-mini  retires 2027-01-14 -> use gpt-6-luna
```
It exits with code 1 when it finds anything, so you can also run it in CI (your automatic checks on each pull request) to stop old names from sneaking back in.

It skips `node_modules`, virtual environments, and build folders. Also check the places it can't see: your hosting dashboard's environment variables, database rows that store a model name, and no-code tools like Zapier or Make.

### 4. Ask your account which models are retiring (optional)

OpenAI's **List models** endpoint, `GET /v1/models`, returns every model your account can use. Each one can have a `shutdown_date` field: a date like `"2026-10-23"`, or `null` if no shutdown has been announced. OpenAI's deprecations page recommends this endpoint to watch for shutdowns from code.

Set your key and add `--api`:
```bash
export OPENAI_API_KEY="your-key-here"
python3 check_models.py ~/code/my-app --api
```
Now the script uses the date the API reports when there is one, then lists every model on your account with a shutdown date. To see the raw data yourself:
```bash
curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"
```
The endpoint lists models that are *currently available*, so a model that has already shut down may simply be missing. That's why the script keeps its own list too.

### 5. Swap in the replacements

For each flagged line, replace the old name with the one after `use`. Better still, keep the model name in one place, like an environment variable or a single constant, so the next swap is a one-line change:
```python
import os
MODEL = os.environ.get("OPENAI_MODEL", "gpt-5.6-sol")
```
Two things to watch:
- **Image code:** retiring GPT Image models have two suggested replacements, `gpt-image-2.6-sunburst` or `gpt-image-2.6-flare`. Try both on a few of your own prompts. Our [GPT Image 1.5 deprecation guide](/guides/switch-from-gpt-image-1-5-to-gpt-image-2-5) walks through the switch.
- **Fine-tuned models:** you can't move a fine-tune to a new base model. OpenAI has also limited who can start new fine-tuning jobs, so check the self-serve fine-tuning section of the deprecations page before you plan to retrain.

If you'd rather have a coding assistant like Codex or Claude Code do the edits, paste the script's output with the prompt below.

Prompt:

```
Below is a list of files and line numbers where my code uses OpenAI models that are retiring, with the replacement OpenAI recommends for each.

[paste the output of check_models.py]

Please:
1. Replace each old model name with its listed replacement. Don't change anything else on those lines.
2. If the same model name appears in several places, suggest moving it into one constant or environment variable.
3. Don't guess at other API changes. If you think a call needs other changes for the new model, list them for me to check in OpenAI's docs instead of editing them.
4. Tell me which tests to run.
```

### 6. Test before you ship

A newer model is usually better, but it isn't identical. Its answers can be longer or shorter, formatted differently, or priced differently. Before you deploy:
1. Run your tests, or send 5 to 10 real requests you know the right answer to.
2. Compare the answers with what you got before. Check anything your code parses, like JSON fields.
3. Check the new model's page for which endpoints and settings it supports, and the pricing page for cost.
4. Run `check_models.py` again until it reports `0 line(s) to fix`.

If you have evals, now is the time to run them. Our [Write evals for an LLM app](/guides/write-evals-for-an-llm-app) guide shows how.

## Tips

- Check the deprecations page once a month or so. OpenAI emails customers who are actively using a model when it's deprecated, but that email may go to whoever owns the account, not you.
- Generally available models get at least 6 months' notice. Preview models (with preview in the name) can be retired with as little as 2 weeks' notice, so avoid them for anything important.
- Don't paste your API key into a chat or commit it to Git. Set it in your terminal as shown, or in your host's secret settings.
- Audio code needs a look too: tts-1 and tts-1-hd shut down Jan 6, 2027, and whisper-1 and the gpt-4o transcribe models on Feb 26, 2027. They're in the script's list.
- **Part of the Before it retires series:** [Move your custom GPT to a ChatGPT plugin](/guides/move-your-custom-gpt-to-a-chatgpt-plugin), [Move your Agent Builder workflow to the Agents SDK](/guides/move-your-agent-builder-workflow-to-the-agents-sdk), [Turn your Gemini Gems into skills before Nov 17](/guides/turn-your-gemini-gems-into-skills), [Move your OpenAI Evals to Promptfoo before Nov 30](/guides/move-your-openai-evals-to-promptfoo), and [Upgrade to Claude SDK 2.0: fix the new 400 errors](/guides/upgrade-to-claude-sdk-2-fix-400-errors), [Switch from GPT Image 1.5 to GPT Image 2.6](/guides/switch-from-gpt-image-1-5-to-gpt-image-2-5) (Dec 1).

## FAQ

### What happens if I miss the date?

Requests that name a shut-down model fail with an error instead of returning an answer, so that feature stops working until you change the model name. Some teams can buy dedicated capacity for continued access after a shutdown. OpenAI says to contact its sales team about that.

### Does this affect ChatGPT itself?

No. This is about the OpenAI **API**, the paid developer service your code calls. If you only use the ChatGPT app or website, you don't need to change anything.

### Does my plain gpt-4o still work?

Yes, for now. Only the dated snapshot `gpt-4o-2024-05-13` shut down on Oct 23, 2026. The `gpt-4o` alias points to `gpt-4o-2024-08-06`, and that snapshot shuts down on Jan 14, 2027. Plan the move to `gpt-6-luna` now.

### Is the shutdown_date field reliable?

It's documented in OpenAI's API reference for List models and Retrieve a model. It's optional, so a model without the field, or with `null`, simply has no announced shutdown. Treat the deprecations page as the full list, since a model that's already gone won't show up in your account's model list.

### Which replacement should I pick when there are two?

Test both on your own requests, and compare quality and price. OpenAI's models page describes each model.

---

This guide is from Easy AI How-To (https://easyaihowtos.com). It is independent of the tools named above. Screens and free-plan limits change, so check the date before you rely on a button name.
