After checking the Sonnet 4.5 retirement date in the official table, the first thing I did was grep my repository for claude-sonnet-4-5.
What came back was tags, URL slugs and old article text. Not one line that actually calls the API. As an indie developer running a few sites and apps on my own, I've learned that the call I don't remember writing is the one that worries me most. That didn't settle my nerves, though, because grep can't see the calls that aren't written in code: environment variables, scripts on another machine, no-code integrations, an old key I'd forgotten was still live.
I first wrote this piece on October 18, with 43 days to go. The retirement date, November 30, has now passed, and as of December 2 calls to the old ID really do come back as 404s. Some of you finished in time; some of you found out from an error alert at the start of the week. Either way, the core of the work is the same: stop hunting for strings and count from the side of what actually ran. I've kept the pre-retirement inventory and added a triage table for calls that break after retirement, a small wrapper that records the caller the moment a 404 arrives, and a note on the next deadline.
The dates and replacements (as of December 2026, checked against the official table)
These are the rows on the official model deprecations page that matter here. Please re-check the live table before you act on any of them.
| Model ID | Status | Retirement | Recommended replacement |
|---|---|---|---|
claude-sonnet-4-5-20250929 | Retired (Nov 30) | 2026-11-30 | claude-sonnet-5-5 |
claude-opus-4-5-20251101 | Deprecated (announced) | 2027-01-22 | claude-opus-5-5 |
claude-haiku-4-5-20251001 | Active | Not announced (its "not sooner than" date, 2026-10-15, has passed) | Not announced |
Back in October, the Opus 4.5 row only carried a "Not sooner than" date — the earliest it could possibly go. A formal notice has since landed, and the date is now January 22, 2027. Sonnet 4.5 also went from announcement to retirement in 61 days, and the docs promise at least 60 days' notice for publicly released models. So I keep rows without a date in the inventory too, as "a notice could land any day."
One more caveat: these dates apply to Anthropic-operated platforms (the Claude API, Claude Platform on AWS, the Anthropic-managed Google Cloud offering, Microsoft Foundry). Amazon Bedrock and the Google-managed Google Cloud offering keep their own schedules. In fact, the official page notes that Sonnet 4.5 is still available as a deprecated model on Amazon Bedrock (bedrock-runtime). If you call through Bedrock, check its table instead.
grep only tells you what is written
I split the inventory into two tools:
- Code side: count model IDs left in config files and scripts (what is written)
- Usage side: export a CSV from the Console's Usage page and look at volume per key and per model (what actually ran)
The official steps are simple: open Usage in the Console, click Export, and read the downloaded CSV for a per-key, per-model breakdown. A line in code that never moved a token can wait. A key that moved tokens but appears nowhere in code is the first thing to find an owner for.
Where I tripped first was the code-side count. Matching anything that starts with claude- across the whole repository pulled in model names inside articles and returned 417 hits. A big number makes it feel like plenty is left. Looking back, I was the one handing my calm — and my worry — over to the size of a number. Doubt the kinds of strings before you trust the count — that became the first line of the script's spec.
One script for both counts
The script walks a directory, counts model IDs, and annotates the ones with a date with their deadline and replacement. --code restricts it to code and config extensions. Pass --csv with a Usage export and it groups by the column whose header contains model and sums every numeric column. For retirement day I updated the table inside it, and it now flags undated aliases such as claude-sonnet-4-5 as well as the dated IDs.
I deliberately didn't hard-code column names. I haven't been able to confirm the Console CSV's headers — the docs only say the export breaks usage down by API key and model, without naming columns. So the script looks for a header containing model, and if it finds none it prints the headers and stops.
#!/usr/bin/env python3
"""model_inventory.py — コード内のモデル ID と、Console の Usage CSV を同じ表で突き合わせる。
使い方: python3 model_inventory.py <ディレクトリ> [--code] [--csv usage.csv]
--code 設定・コードの拡張子だけを見る(記事本文やタグの文字列を拾わない)
"""
import csv, re, sys, pathlib, collections
# 公式 model-deprecations の「Model status」表(2026-12-02 再確認)から、期限のあるものだけ
RETIRE = {
"claude-sonnet-4-5-20250929": ("2026-11-30 退役", "claude-sonnet-5-5"),
"claude-sonnet-4-5": ("2026-11-30 退役", "claude-sonnet-5-5"),
"claude-opus-4-5-20251101": ("2027-01-22", "claude-opus-5-5"),
"claude-opus-4-5": ("2027-01-22", "claude-opus-5-5"),
}
SKIP_DIRS = {".git", "node_modules", ".next", "dist", "build", "__pycache__", "generated"}
CODE_EXT = {".py", ".js", ".mjs", ".ts", ".tsx", ".sh", ".yaml", ".yml", ".toml", ".env", ".cfg", ".ini"}
SKIP_EXT = {".png", ".jpg", ".jpeg", ".gif", ".webp", ".pdf", ".zip", ".lock", ".woff", ".woff2"}
# 数字で終わる ID だけを拾う。slug(claude-opus-4-6-release など)を巻き込まない
ID_RE = re.compile(
r"claude-(?:(?:sonnet|opus|haiku|fable|mythos)-\d+(?:-\d+)?(?:-\d{8})?"
r"|3-(?:5-haiku|haiku|7-sonnet)-\d{8})(?![A-Za-z0-9]|-[A-Za-z0-9])"
)
def scan(root, code_only=False):
hits = collections.defaultdict(list)
for p in pathlib.Path(root).rglob("*"):
if not p.is_file() or p.suffix.lower() in SKIP_EXT:
continue
if any(part in SKIP_DIRS for part in p.parts):
continue
if code_only and p.suffix.lower() not in CODE_EXT and p.name != ".env":
continue
try:
text = p.read_text(encoding="utf-8")
except (UnicodeDecodeError, OSError):
continue
for n, line in enumerate(text.splitlines(), 1):
for m in ID_RE.findall(line):
hits[m].append(f"{p}:{n}")
return hits
def read_usage(path):
"""model を含む見出しの列でグループ化し、数値列を合計する。列名は固定しない。"""
with open(path, newline="", encoding="utf-8-sig") as f:
rows = list(csv.DictReader(f))
if not rows:
return {}
cols = rows[0].keys()
mcol = next((c for c in cols if "model" in c.lower()), None)
if mcol is None:
sys.exit("model を含む列が見つかりません: " + ", ".join(cols))
numeric = [c for c in cols if c != mcol and all(_num(r[c]) is not None for r in rows if r[c] != "")]
out = collections.defaultdict(lambda: collections.Counter())
for r in rows:
for c in numeric:
v = _num(r[c])
if v is not None:
out[r[mcol]][c] += v
return out
def _num(s):
try:
return float(str(s).replace(",", ""))
except ValueError:
return None
def main():
args = sys.argv[1:]
root = args[0] if args else "."
csv_path = args[args.index("--csv") + 1] if "--csv" in args else None
hits = scan(root, code_only="--code" in args)
print(f"== コード内のモデル ID({root})")
for mid in sorted(hits, key=lambda k: (k not in RETIRE, k)):
note = ""
if mid in RETIRE:
d, to = RETIRE[mid]
note = f" ← 期限 {d} / 置き換え先 {to}"
print(f"{len(hits[mid]):4d} {mid}{note}")
if mid in RETIRE:
for loc in hits[mid][:5]:
print(f" {loc}")
if csv_path:
print(f"\n== Usage CSV({csv_path})")
for model, cnt in read_usage(csv_path).items():
flag = " ← 期限あり" if model in RETIRE else ""
print(model + flag)
for c, v in cnt.items():
print(f" {c}: {v:,.0f}")
if __name__ == "__main__":
main()The model-ID regex has a quirk worth knowing. To keep URL slugs like claude-sonnet-4-6-vs-... out, a lookahead refuses any match followed by an alphanumeric or a hyphen-plus-alphanumeric. My first version was looser, and claude-sonnet-4 showed up four times on its own — backtracking had let just the prefix match.
What it printed
I ran it against this site's repository (Next.js), code and config only. It needs nothing beyond the Python 3 standard library.
python3 model_inventory.py ~/repos/claudelab.net --codeIt printed the header line and nothing else. There isn't a single line in this repository that calls the Claude API. Drop --code and the same directory yields 22 hits for claude-opus-4-5 and 24 for the dated claude-opus-4-5-20251101 — every one of them text inside articles. A large count and a needed migration are two different things.
To check the CSV path, I wrote a small sample by hand (not a real Console export; I made up the column names). It imagines the week before retirement, mixing keys that had moved with keys that hadn't.
date,api_key,model,input_tokens,output_tokens
2026-11-27,key_wallpaper_batch,claude-sonnet-4-5-20250929,400000,70000
2026-11-27,key_wallpaper_batch,claude-sonnet-5-5,1300000,220000
2026-11-28,key_translate,claude-opus-4-5-20251101,150000,30000
2026-11-28,key_store_reply,claude-sonnet-4-5,90000,16000
2026-11-29,key_translate,claude-haiku-4-5-20251001,910000,150000python3 model_inventory.py ~/repos/claudelab.net --code --csv usage_sample.csv== Usage CSV(usage_sample.csv)
claude-sonnet-4-5-20250929 ← 期限あり
input_tokens: 400,000
output_tokens: 70,000
claude-sonnet-5-5
input_tokens: 1,300,000
output_tokens: 220,000
claude-opus-4-5-20251101 ← 期限あり
input_tokens: 150,000
output_tokens: 30,000
claude-sonnet-4-5 ← 期限あり
input_tokens: 90,000
output_tokens: 16,000
claude-haiku-4-5-20251001
input_tokens: 910,000
output_tokens: 150,000(The script's labels are in Japanese; 期限あり means "has a deadline.") The numbers are invented. Three things are worth noticing. The same key (key_wallpaper_batch) shows both old and new IDs, which means only some of its paths were migrated. The undated claude-sonnet-4-5 gets flagged too. And Haiku 4.5 gets no flag, because no date has been announced for it. If your real CSV uses different headers, the only line to touch is the "model" in c.lower() check inside read_usage.
Triage for calls that broke after retirement
Now that the date has passed, you may well find a failing call before you finish the inventory. The model deprecations page states that, on the Claude API, the Messages API returns a 404 not_found_error for a retired model (checked in December 2026). In October I wrote that I couldn't confirm this; you can rely on it now.
A 404 not_found_error doesn't only mean retirement, though. A misspelled model ID returns the same type. The table starts by separating "retired, misspelled, or a different route."
| Symptom | Likely cause | How to check | Fix |
|---|---|---|---|
From Nov 30, one batch job or integration starts failing with 404 not_found_error | That path names claude-sonnet-4-5-20250929 or claude-sonnet-4-5 | Log the error body and the request's model on the same line and see whether it's the old ID | Switch to claude-sonnet-5-5, checking the migration guide's argument changes first |
You switched to the new ID but the 404 not_found_error continues | A misspelled ID (for example claude-sonnet-5.5 with a dot) | Compare the model name in the error body, character by character, with the official model list | Use the hyphenated official ID (claude-sonnet-5-5) |
| Code is fixed, but Usage still shows the old ID | A script on another machine, a CI variable, an old copy of .env | Find the API key on the old-ID rows in the Usage CSV and trace where that key was issued | Fix the caller, then disable keys nobody uses |
| Calls through Bedrock still work | Bedrock keeps its own retirement schedule | Read Bedrock's model lifecycle table | Plan for Bedrock's date separately; it may not be the same day |
| The error is gone after switching IDs, but output length or shape changed | Different defaults in the new model (thinking, stop_reason, and so on) | Run the same request on old and new and compare | Adjust max_tokens and downstream parsing to the new behavior |
| After switching IDs, you get a 400 | An argument the new model doesn't accept | Read which argument the error body names | Remove it or rewrite it the new way |
The second row is the one I watch most closely. Even if the code scan is empty, an old ID in the Usage CSV means something, somewhere, is still calling it. After retirement those calls simply turn into failures; they don't quietly disappear.
When pulling post-retirement errors out of your own logs, counting model ID and response together is the fastest route. Log formats vary, so this example assumes JSON Lines:
# assumes each line of logs/*.jsonl carries "model" and "status" (or "error")
grep -h 'claude-sonnet-4-5' logs/*.jsonl \
| python3 -c 'import sys,json,collections
c=collections.Counter()
for l in sys.stdin:
try: r=json.loads(l)
except ValueError: continue
c[(r.get("model"), r.get("status") or (r.get("error") or {}).get("type"))]+=1
for k,v in c.most_common(): print(v, *k)'The first column is the count, followed by model ID and response kind. If the response kind flips to not_found_error on November 30, that path is still calling the old ID.
A wrapper that writes down the caller the moment a 404 arrives
If your logs aren't consistent enough for that, it's faster to catch the stragglers going forward. What tripped me up first was that my 404 logs never said which script, for which job, made the call. I had the model ID but no owner.
This wrapper catches only NotFoundError from the Python SDK (anthropic package), appends one JSON Lines record with the model ID, a purpose label and the calling file and line, and then re-raises. Nothing is swallowed, so your existing error handling keeps working.
# retired_guard.py — on 404 not_found_error, record the caller, then re-raise
import json, time, inspect
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from the environment
def create(purpose: str, **kwargs):
try:
return client.messages.create(**kwargs)
except anthropic.NotFoundError as e:
caller = inspect.stack()[1]
with open("model_404.jsonl", "a", encoding="utf-8") as f:
f.write(json.dumps({
"at": time.strftime("%Y-%m-%dT%H:%M:%S"),
"purpose": purpose,
"model": kwargs.get("model"),
"caller": f"{caller.filename}:{caller.lineno}",
"status": e.status_code,
"body": e.body,
}, ensure_ascii=False) + "\n")
raise
if __name__ == "__main__":
create("store_reply", model="claude-sonnet-4-5", max_tokens=64,
messages=[{"role": "user", "content": "ping"}])Making purpose a required argument is the point. A model ID alone can't tell you which of three scripts sharing it just failed. With a purpose label you can line it up against the API key rows in the Usage CSV and reach the owner in one pass. Run it with the old ID and model_404.jsonl gains a line, then the original exception prints (body is the error body exactly as the SDK received it).
Where to write the ID — a comparison
Choosing a way of writing the ID that spares you a repeat hunt next time saves more effort than the swap itself.
| Approach | Strength | Weakness | Fits when |
|---|---|---|---|
Hard-coded (model="claude-sonnet-5-5") | Obvious at a glance | More callers means more hunting at the next deadline | Throwaway scripts |
| One environment variable or config file | One-line swap | Per-machine copies drift out of date | Several scripts sharing one model |
A table keyed by purpose ("translate" → ID) | Each purpose can move to a different model | Takes a little setup | Distinct jobs like translation, summaries, review replies |
My own rule: once a model has more than three callers, move to the purpose table. With two or fewer, hard-coding reads better and a table is overkill. Whatever you choose, the thing to trust last is not your code but the rows in the Usage CSV.
Common misunderstandings
"Haiku 4.5 stops on the same day." It doesn't. As of December 2026, claude-haiku-4-5-20251001 is still Active with no retirement date announced. The "not sooner than" date it carried in October has passed, though, so a notice could arrive at any time.
"Bedrock and Google Cloud stop on the same date." The dates in the official table are for Anthropic-operated platforms. Amazon Bedrock and the Google-managed Google Cloud offering keep their own schedules, and Sonnet 4.5 remains as a deprecated model on Bedrock (bedrock-runtime) after its retirement elsewhere. Check the table for every path you use.
"A 404 means a bad endpoint or API key." A call to a retired model is also a 404 not_found_error. A bad key returns 401 authentication_error, so look at the error type first; if it's a 404, suspect the request's model.
"If grep finds nothing, the migration is done." That's where this article started. grep shows you written strings; only the Usage CSV shows you who owns the tokens that flowed.
After you find a row: the order I follow
I don't stop at swapping strings. The order:
- From the Usage CSV, identify which keys actually send
claude-sonnet-4-5-20250929orclaude-sonnet-4-5traffic, and write down who owns each and what it's for. - Find the caller. If the code-side scan doesn't turn it up, open environment variables, CI variables and any no-code integration settings in turn.
- Before replacing the ID, check the migration guide for argument differences (budget_tokens, prefill,
tool_choiceand the like — the ones that return 400 are in "Before Sonnet 4.5 retires, one script to find the arguments that will return a 400"). - Check the places where answers change without any error ("Five Days Before Sonnet 4.5 Retires: Compare the Three Things That Change Without an Error While the Old Model Still Answers").
- A week after the switch, export the CSV again and confirm the old ID's row hasn't grown.
Step 5 is there because "done" is easy to declare too early. If an old copy of a config lives on another machine, the old ID will start flowing again. Re-reading one export catches that kind of miss, so I'd rather spend the few minutes.
The next snag: Opus 4.5 on January 22, 2027
Right after the Sonnet 4.5 work, the next thing you're likely to hit is the Opus 4.5 deadline — 51 days out as of December 2 (announced November 23, replacement claude-opus-5-5, and the undated claude-opus-4-5 is included). The script's RETIRE table already includes claude-opus-4-5-20251101 and claude-opus-4-5, so the CSV you just exported will flag those rows as-is.
Before any bulk replace, checking against the model IDs your local CLI or library already knows about keeps you from swapping in an ID that doesn't exist. I wrote that up in "Read the Catalog Your CLI Already Ships Before Bulk-Replacing Model IDs". If you use only the claude.ai chat and not the API, "A Retirement Notice Landed This Morning: Three Screens to Open Before You Change Anything" is probably closer to what you need.
Next step
Today, export one CSV from the Console's Usage page. Sort by the model column and look only for rows starting with claude-sonnet-4-5 on recent dates. If they're there, today's job is to write down the owner and purpose of each API key involved — nothing more.
What you're looking for isn't a string; it's the owner of the tokens that flowed. Even past the retirement date, that's the order I intend to keep.