Skip to main content

endofmodel

Know before your LLM model dies.

LLM providers retire models all the time. When it happens, your app either starts failing with a confusing 404 model_not_found, or worse, keeps "working" while the provider silently routes your requests to a different model. endofmodel tells you before that happens, and explains it clearly when it does.

  • ⚠️ Runtime warnings: every API call to a deprecated model logs a warning with the retirement date, days left, and the recommended replacement.
  • 🔀 Silent-redirect detection: flags when the model that answered is not the model you asked for.
  • 💥 Clear errors: turns an opaque 404 from a retired model into ModelRetiredError.
  • 🔍 CI gate: endofmodel scan finds model IDs in your code and fails the build if any are retired or retiring soon.
  • 📦 Offline and free: the registry ships inside the package. No API key, no network calls, and no dependencies for the core.

Covers OpenAI, Anthropic (Claude) and Google Gemini API today.

Install

pip install endofmodel            # check / scan / CLI (zero dependencies)
pip install "endofmodel[guard]"   # + runtime guard (httpx)
pip install "endofmodel[litellm]"   # + LiteLLM callback
pip install "endofmodel[langchain]" # + LangChain callback handler

30-second tour

Complete scripts for everything below (install line, imports, usage with the OpenAI, Anthropic and OpenRouter SDKs) are in examples/.

$ endofmodel check gpt-4o-2024-05-13 claude-opus-4-5-20251101
gpt-4o-2024-05-13 (openai) was retired on 2026-10-23 and no longer works -> use gpt-5.6-sol [...]
claude-opus-4-5-20251101 (anthropic) is deprecated and retires on 2027-01-22 (51 days left) -> use claude-opus-5-5 [...]

Warn on live API calls

from openai import OpenAI
import endofmodel

client = OpenAI(http_client=endofmodel.http_client())
client.chat.completions.create(model="gpt-4o-2024-08-06", messages=[...])
# DeprecatedModelWarning: endofmodel: gpt-4o-2024-08-06 (openai) is deprecated and
# retires on 2027-01-14 (43 days left) -> use gpt-6-luna [https://developers.openai.com/...]

The same works for Anthropic, and for async clients:

from anthropic import Anthropic, AsyncAnthropic

client = Anthropic(http_client=endofmodel.http_client())
aclient = AsyncAnthropic(http_client=endofmodel.async_http_client())

# or attach to a client you already have:
endofmodel.wrap(existing_client)

Each model is reported once per process, so your logs don't flood.

LiteLLM and LangChain

Frameworks that make the HTTP calls for you get a callback instead of an http_client:

# LiteLLM: covers every provider LiteLLM routes to, sync and async, and the Router
from endofmodel.integrations.litellm import install

install()
litellm.completion(model="openrouter/openai/gpt-5", messages=[...])
# DeprecatedModelWarning: endofmodel: openai/gpt-5 (via OpenRouter) is deprecated and
# retires on 2026-12-11 (9 days left) -> use gpt-6.2-sol

# LangChain: works with ChatOpenAI, ChatAnthropic, ChatGoogleGenerativeAI, ChatVertexAI, ...
from endofmodel.integrations.langchain import EndOfModelCallbackHandler

llm = ChatOpenAI(model="gpt-5-mini", callbacks=[EndOfModelCallbackHandler()])
chain.invoke(inputs, config={"callbacks": [EndOfModelCallbackHandler()]})  # whole chain

Both also flag silent redirects, and both detect OpenRouter so its own retirement dates apply. For the LiteLLM proxy, add callbacks: endofmodel.integrations.litellm.handler under litellm_settings in config.yaml.

Get alerts where you'll see them

@endofmodel.on_event
def alert(event):
    # event.kind: "deprecated" | "retired" | "redirected"
    send_to_slack(event.message)

Clear errors for retired models

with endofmodel.translate_errors():
    client.chat.completions.create(model="gpt-4-0613", messages=[...])
# endofmodel.ModelRetiredError: gpt-4-0613 (openai) was retired on 2026-10-23
# and no longer works -> use gpt-5.6-sol

Startup check

Models often live in .env files, databases or feature flags where no code scan can see them. Check them when your service boots:

endofmodel.assert_models_ok(
    [os.environ["CHAT_MODEL"], os.environ["EMBED_MODEL"]],
    fail_under_days=14,
)  # raises ModelExpiringError if any are retired or retire within 14 days

CI gate

endofmodel scan ./src --fail-under-days 30
✖ app/llm.py:12:15  gpt-4o-2024-05-13  retired 2026-10-23 -> gpt-5.6-sol
! app/summarize.py:8:20  gpt-5-mini  retires 2026-12-11 (9d) -> gpt-6.1-terra
· README.md:40:3  gpt-4  retired 2026-10-23 -> gpt-5.6-sol [docs]

3 finding(s): 1 retired, 1 critical, 1 info
FAILED: retired models or models retiring within 30 days.

Exit code is 1 when the gate fails, so CI blocks the merge. Mentions in .md/.txt files are reported but never fail the build. scan takes several files or folders, and --format json | sarif | github (with -o FILE) for machine-readable output.

GitHub Action

Findings show up as annotations on the exact lines of the pull request, plus a summary on the run page:

# .github/workflows/endofmodel.yml
name: endofmodel
on: [pull_request]
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Agentdrops/endofmodel@v0.3.0
        with:
          path: .                 # files or folders, space-separated
          fail-under-days: 30

To get the findings as code scanning alerts as well (a Security tab, alerts on PRs, dismiss/track per alert), upload the SARIF report. This needs code scanning: public repos, or GitHub Advanced Security on private ones.

    permissions:
      contents: read
      security-events: write
    steps:
      - uses: actions/checkout@v4
      - uses: Agentdrops/endofmodel@v0.3.0
        with:
          upload-sarif: true

Inputs: path, fail-under-days, fail-on-findings (false = report only), annotations, sarif-file, upload-sarif, version, python-version. Outputs: failed, findings, sarif-file. The action runs endofmodel in its own virtualenv and doesn't touch your Python. Other CI systems: pipx run endofmodel scan . --format sarif -o endofmodel.sarif.

pre-commit

Stop a retired model from being committed in the first place:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/Agentdrops/endofmodel
    rev: v0.3.0
    hooks:
      - id: endofmodel
        # args: [--fail-under-days, "14"]

Only the staged files are scanned, so it's fast.

List what's retiring soon

endofmodel list --upcoming 60
endofmodel list --provider anthropic --json

How it works

registry (JSON, shipped in the package)
        │
   check(model) ──► ModelStatus(status, retires_on, days_left, replacement, ...)
        │
 ┌──────┼───────────────┬──────────────────┐
 runtime guard      scan (CI)         assert_models_ok
 (httpx hooks)     static search       (startup)
        │
 warnings · logging · on_event callbacks

The runtime guard hooks into httpx, the HTTP library the OpenAI and Anthropic SDKs use, instead of patching SDK methods. That way it keeps working when the SDKs change. Hooks never raise exceptions inside the SDK; they only warn, log and emit events.

Silent redirects. After a successful non-streaming call, the guard compares the model you requested with the model reported in the response (model for OpenAI/Anthropic, modelVersion for Gemini). Dated snapshots (gpt-4o → gpt-4o-2024-08-06) and *-latest aliases are not treated as redirects.

The registry

Data lives in src/endofmodel/data/, one JSON file per provider, validated against schema.json. Each entry records the model IDs, deprecation date, retirement date, replacement, and (when the provider says so) the model requests get redirected to.

OpenAI, Anthropic and Gemini are curated by hand from the official deprecation pages. Other providers (Mistral, Z.ai, Moonshot, Microsoft, Upstage, …) are generated from the OpenRouter models API: a weekly GitHub Action (sync-models.yml) runs scripts/sync_openrouter.py and opens a PR with new or changed retirement dates. It never edits the hand-curated files; it lists where they disagree with OpenRouter in the PR description instead. Generated entries accept both the bare ID (glm-4.5) and the OpenRouter ID (z-ai/glm-4.5).

Calling models through OpenRouter

OpenRouter can stop serving a model on a different day than its author, and some variants (like openai/gpt-5-image) only exist there. openrouter.json tracks OpenRouter's own schedule. You get it when:

  • the runtime guard sees a request to openrouter.ai (point the OpenAI SDK's base_url at OpenRouter and pass http_client=endofmodel.http_client() as usual);
  • you pass provider="openrouter" (check("openai/gpt-5", provider="openrouter"), or endofmodel check openai/gpt-5 --provider openrouter);
  • the model uses the LiteLLM form openrouter/openai/gpt-5.
$ endofmodel check openai/gpt-5 --provider openrouter
openai/gpt-5 (via OpenRouter) is deprecated and retires on 2026-12-11 (9 days left) -> use gpt-6.2-sol [https://openrouter.ai/openai/gpt-5]

If OpenRouter has no date for a model, the author's schedule applies. OpenRouter's IDs don't always match the author's: Anthropic IDs are matched through derived aliases (claude-opus-4-5-20251101 also answers to claude-opus-4-5 and OpenRouter's claude-opus-4.5), and OpenAI and Gemini IDs match after removing the prefix. Other OpenRouter-sourced providers (mistral.json, zai.json, …) use OpenRouter's spelling for the bare ID, which may not equal the provider's native API ID. Replacements come from the author's entry, because OpenRouter doesn't publish them. Without a provider hint, openai/gpt-5 means OpenAI's own schedule; IDs only OpenRouter knows are still found.

To use fresher or private data without waiting for a release, point ENDOFMODEL_REGISTRY_DIR at a folder of JSON files in the same format. Entries there override the bundled ones.

Disclaimer: dates come from the providers' public deprecation pages and can change. Always confirm against the linked notice before migrating. Dates for OpenRouter-sourced providers are when OpenRouter stops serving the model, which can differ from the provider's own API. Platforms like Azure OpenAI, Amazon Bedrock and Vertex AI run their own retirement schedules, which this release does not cover yet.

Roadmap

  • v0.1: registry (OpenAI, Anthropic, Gemini), check, runtime guard, redirect detection, scan, CLI
  • v0.2: weekly GitHub Action that syncs expiry dates from OpenRouter and opens registry PRs
  • v0.2: scrape official provider deprecation pages for OpenAI / Anthropic / Gemini
  • v0.3: Azure OpenAI, Amazon Bedrock, Vertex AI, Groq
  • v0.2: LangChain and LiteLLM callbacks
  • v0.3: GitHub Action (PR annotations, SARIF / code scanning) and pre-commit hook
  • v0.4: google-genai SDK adapter, Slack & OpenTelemetry notifiers
  • v0.5: optional endofmodel update to fetch the latest registry (cached)

Contributing

Updating a date or adding a model is the most valuable contribution, and it only takes a JSON edit. See CONTRIBUTING.md.

License

Apache-2.0. Free for personal and commercial use.

Metadata

Release files for endofmodel 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for endofmodel 0.3.0
File Size Uploaded Provenance Actions
endofmodel-0.3.0.tar.gz 43.6 kB With provenance Details for endofmodel-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for endofmodel 0.3.0
File Interpreter ABI Platform Actions
endofmodel-0.3.0-py3-none-any.whl Python 3 none any Details for endofmodel-0.3.0-py3-none-any.whl

Total release size: 81.6 kB

Release files / endofmodel-0.3.0.tar.gz

Download URL endofmodel-0.3.0.tar.gz
Size 43.6 kB
Tags Source
SHA-256 checksum
How to use checksums
92f1ef6d04e90c59c6fbef8875c725b38e85341e710e4c38527960aef6b409d1
BLAKE2b-256 checksum
How to use checksums
af3250c6a0758a319bfa8842325ee932148ec768d6508a443002b8f23aa9c0e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / endofmodel-0.3.0-py3-none-any.whl

Download URL endofmodel-0.3.0-py3-none-any.whl
Size 38.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0419d33aaa2a62cb0ca67c1850f4b742692a56488012e9312e79207f01c51e2
BLAKE2b-256 checksum
How to use checksums
c6acbcf8aadde0930be8b9794a5617307de5daec8312c8b034f81baefb1ba60f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for endofmodel 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for endofmodel-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page