Metadata-Version: 2.5
Name: endofmodel
Version: 0.3.2
Summary: Know before your LLM model dies: warnings, CI checks and silent-redirect detection for deprecated OpenAI, Anthropic and Gemini models.
Project-URL: Homepage, https://github.com/Agentdrops/endofmodel
Project-URL: Issues, https://github.com/Agentdrops/endofmodel/issues
Project-URL: Changelog, https://github.com/Agentdrops/endofmodel/blob/main/CHANGELOG.md
Author: endofmodel contributors
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: anthropic,claude,deprecation,gemini,llm,llmops,mlops,model-retirement,openai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: anthropic>=0.30; extra == 'dev'
Requires-Dist: httpx>=0.23; extra == 'dev'
Requires-Dist: jsonschema>=4; extra == 'dev'
Requires-Dist: langchain-core>=0.2; extra == 'dev'
Requires-Dist: langchain-openai>=0.1; extra == 'dev'
Requires-Dist: litellm>=1.40; extra == 'dev'
Requires-Dist: openai>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Provides-Extra: guard
Requires-Dist: httpx>=0.23; extra == 'guard'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2; extra == 'langchain'
Provides-Extra: litellm
Requires-Dist: litellm>=1.40; extra == 'litellm'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/Agentdrops/endofmodel/main/docs/assets/banner.svg" alt="endofmodel: know before your LLM model dies" width="100%">
</p>

<p align="center">
  <a href="https://pypi.org/project/endofmodel/"><img src="https://img.shields.io/pypi/v/endofmodel.svg" alt="PyPI"></a>
  <a href="https://pypi.org/project/endofmodel/"><img src="https://img.shields.io/pypi/pyversions/endofmodel.svg" alt="Python versions"></a>
  <a href="https://github.com/Agentdrops/endofmodel/actions/workflows/ci.yml"><img src="https://github.com/Agentdrops/endofmodel/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  <a href="https://github.com/marketplace/actions/endofmodel-scan"><img src="https://img.shields.io/badge/Marketplace-endofmodel%20scan-blue?logo=github" alt="GitHub Marketplace"></a>
  <a href="https://github.com/Agentdrops/endofmodel/blob/main/LICENSE"><img src="https://img.shields.io/pypi/l/endofmodel.svg" alt="License"></a>
</p>

<p align="center">
  <a href="#quickstart"><b>Quickstart</b></a> ·
  <a href="#usage-guide"><b>Usage guide</b></a> ·
  <a href="#ci-gate"><b>CI gate</b></a> ·
  <a href="https://github.com/Agentdrops/endofmodel/tree/main/examples"><b>Examples</b></a> ·
  <a href="https://github.com/Agentdrops/endofmodel/blob/main/CHANGELOG.md"><b>Changelog</b></a>
</p>

Providers retire LLM models all the time. When it happens, your app either fails with a
confusing `404 model_not_found`, or keeps "working" while the provider quietly answers with a
different model. **endofmodel** warns you *before* that happens and tells you what to switch to.

- ⚠️ **Warns on live calls** to deprecated models: retirement date, days left, replacement.
- 🔀 **Catches silent redirects**: the model that answered isn't the one you asked for.
- 🔍 **Blocks retired models in CI**: PR annotations, SARIF, or a pre-commit hook.
- 📦 **Works offline**: the data ships inside the package. No API key, no network calls.
- 🧩 **Fits your stack**: OpenAI and Anthropic SDKs, **LiteLLM**, **LangChain**, **OpenRouter**.

<p align="center">
  <img src="https://raw.githubusercontent.com/Agentdrops/endofmodel/main/docs/assets/how-it-works.svg" alt="endofmodel catches old model IDs at four points: on commit, in pull requests, at startup and on every live API call, all from one built-in registry" width="100%">
</p>

## Contents

- [Quickstart](#quickstart)
- [Usage guide](#usage-guide)
  1. [Check a model](#1-check-a-model)
  2. [Warn on live API calls](#2-warn-on-live-api-calls) (OpenAI, Anthropic, LiteLLM, LangChain, OpenRouter)
  3. [Refuse to start with a dying model](#3-refuse-to-start-with-a-dying-model)
  4. [Send alerts and get clear errors](#4-send-alerts-and-get-clear-errors)
  5. [CI gate](#ci-gate) (CLI, GitHub Action, pre-commit, other CI)
- [Reference](#reference)
- [Where the data comes from](#where-the-data-comes-from)
- [FAQ](#faq)

## Quickstart

```bash
pip install endofmodel
```

Ask about any model ID:

```bash
endofmodel check gpt-4o-2024-05-13
```

Find every outdated model ID in your project (exit code 1 if something must change):

```bash
endofmodel scan .
```

Get a warning on every live call to a deprecated model:

```python
from openai import OpenAI
import endofmodel

client = OpenAI(http_client=endofmodel.http_client())  # pip install "endofmodel[guard]"
```

That's the whole setup. The rest of this page goes through each feature in detail.

## Usage guide

### Install

| Command | What you get |
|---|---|
| `pip install endofmodel` | `check`, `scan`, startup checks, CLI. **No dependencies.** |
| `pip install "endofmodel[guard]"` | + warnings on live OpenAI / Anthropic SDK calls |
| `pip install "endofmodel[litellm]"` | + LiteLLM callback |
| `pip install "endofmodel[langchain]"` | + LangChain callback |

Python 3.10 or newer.

### 1. Check a model

**From the terminal:**

<img src="https://raw.githubusercontent.com/Agentdrops/endofmodel/main/docs/assets/demo-check.svg" alt="endofmodel check output: gpt-4o-2024-05-13 is retired, use gpt-5.6-sol; claude-opus-4-5-20251101 is deprecated and retires 2027-01-22, use claude-opus-5-5; gpt-6-luna has no deprecation announced" width="100%">

```bash
endofmodel check gpt-5-mini claude-opus-4-5     # several at once; aliases work
endofmodel check anthropic/claude-opus-4.5 --provider openrouter
endofmodel list --upcoming 30                    # everything retiring in the next 30 days
endofmodel list --provider anthropic --json      # machine-readable
```

**From Python:**

```python
import endofmodel

s = endofmodel.check("gpt-5-mini")
s.status  # Status.DEPRECATED  (also ACTIVE, RETIRED, REDIRECTED)
s.retires_on  # datetime.date(2026, 12, 11)
s.days_left  # 8
s.replacement  # 'gpt-6.1-terra'
s.notice_url  # the provider's official deprecation notice
s.describe()  # one human-readable sentence, as printed by the CLI
```

A model that isn't in the registry comes back as `ACTIVE`: nothing has been announced for it.

### 2. Warn on live API calls

endofmodel only **watches** traffic. It never changes, delays or blocks a request. Each warning
is logged once per model per process.

<img src="https://raw.githubusercontent.com/Agentdrops/endofmodel/main/docs/assets/demo-guard.svg" alt="Warnings printed by an app using endofmodel: gpt-5-mini is deprecated and retires on 2026-12-11, use gpt-6.1-terra; requested gpt-4o but the provider answered with gpt-6.1-terra" width="100%">

**OpenAI and Anthropic SDKs.** Pass endofmodel's HTTP client when you create the client:

```python
from openai import OpenAI, AsyncOpenAI
from anthropic import Anthropic
import endofmodel

client = OpenAI(http_client=endofmodel.http_client())
client = Anthropic(http_client=endofmodel.http_client())
client = AsyncOpenAI(http_client=endofmodel.async_http_client())  # async clients

client = endofmodel.wrap(OpenAI())  # or attach to a client that already exists
```

You get three kinds of warning:

| Warning | When |
|---|---|
| `DeprecatedModelWarning` | You call a model that has a retirement date. |
| `RetiredModelWarning` | You call a model whose retirement date has passed. |
| `ModelRedirectedWarning` | The response came from a **different model** than the one you asked for. |

**LiteLLM.** LiteLLM makes the HTTP calls itself, so register the callback instead:

```python
from endofmodel.integrations.litellm import install

install()  # every litellm.completion() / acompletion() / Router call is now checked
```

**LangChain.** Add the callback handler to a model, a single call, or a whole chain:

```python
from langchain_openai import ChatOpenAI
from endofmodel.integrations.langchain import EndOfModelCallbackHandler

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

**OpenRouter.** OpenRouter can retire a model on a different day than its author, so it has its
own data. It's used automatically for calls to `openrouter.ai`, for `provider="openrouter"`, and
for LiteLLM-style IDs like `openrouter/openai/gpt-5`:

```python
client = OpenAI(base_url="https://openrouter.ai/api/v1", http_client=endofmodel.http_client())
```

### 3. Refuse to start with a dying model

Check the models in your config when the app boots, so a deploy fails loudly instead of
production failing quietly:

```python
import os
import endofmodel

endofmodel.assert_models_ok(
    [os.environ["CHAT_MODEL"], os.environ["SUMMARY_MODEL"]],
    fail_under_days=14,  # also fail if a model retires within 14 days
)
# raises ModelExpiringError listing each problem and its replacement
```

### 4. Send alerts and get clear errors

**Alerts.** Send every warning where your team will see it (Slack, Sentry, metrics...):

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

**Clear errors.** A retired model usually fails with a vague `404`. Turn it into an error that
says what happened and what to use instead:

```python
with endofmodel.translate_errors():
    client.chat.completions.create(model="gpt-4-0613", messages=[...])
# ModelRetiredError: gpt-4-0613 (openai) was retired on ... -> use gpt-5.6-sol
```

## CI gate

`endofmodel scan` finds model IDs in your code and config, and exits with code **1** if any are
retired or retire within `--fail-under-days` (default **30**).

<img src="https://raw.githubusercontent.com/Agentdrops/endofmodel/main/docs/assets/demo-scan.svg" alt="endofmodel scan output: app.py line 2 uses retired gpt-4o-2024-05-13; app.py line 3 uses claude-opus-4-5-20251101, retiring 2027-01-22; NOTES.md mentions gpt-4o-2024-05-13 in docs; scan failed with exit code 1" width="100%">

| Mark | Meaning | Fails the build? |
|---|---|---|
| `✖` | Retired, or retires within `--fail-under-days` | yes |
| `~` | Deprecated, retires later | no |
| `·` | Mentioned in docs (`.md`, `.txt`) | never |

It scans Python, JS/TS, Go, Ruby, Java, Kotlin, Rust, C#, PHP, shell, notebooks, and config
files (`.json`, `.yaml`, `.toml`, `.ini`, `.cfg`, `.env`), and skips `.git`, `node_modules`
and virtualenvs.

### GitHub Action

Findings show up as comments **on the exact lines** of the pull request:

```yaml
# .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.2
        with:
          fail-under-days: 30
```

To also get them as alerts in the **Security → Code scanning** tab, upload the SARIF report
(public repos, or private repos with GitHub Advanced Security):

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

| Input | Default | Description |
|---|---|---|
| `path` | `.` | Files or folders to scan, separated by spaces |
| `fail-under-days` | `30` | Fail if a model is retired or retires within this many days |
| `fail-on-findings` | `true` | Set to `false` to report without failing the job |
| `annotations` | `true` | Show findings as annotations on the PR diff |
| `sarif-file` | `endofmodel.sarif` | Where to write the SARIF report (empty to skip) |
| `upload-sarif` | `false` | Upload the report to GitHub code scanning |
| `version` | *(action's version)* | endofmodel version to install from PyPI |
| `python-version` | `3.12` | Python used to run endofmodel (your PATH is untouched) |

Outputs: `failed` (`"true"`/`"false"`), `findings` (count), `sarif-file` (path). A summary
of the scan is also added to the job summary page.

### pre-commit

Stop a retired model before it's committed:

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

### Other CI systems

The CLI works anywhere Python runs. Use the exit code to fail the job, and pick an output
format for your tools:

```bash
pip install endofmodel
endofmodel scan .                                          # text, exit 1 on failure
endofmodel scan . --format sarif -o endofmodel.sarif      # SARIF 2.1.0 for code-review tools
endofmodel scan . --format json                            # for your own scripts
```

[SARIF](https://sarifweb.azurewebsites.net/) is the standard format that most code-scanning
and review tools read.

## Reference

### CLI

| Command | Description |
|---|---|
| `endofmodel check MODEL [MODEL...]` | Look up model IDs. `--provider`, `--json` |
| `endofmodel list` | List the registry. `--provider`, `--upcoming DAYS`, `--json` |
| `endofmodel scan [PATH...]` | Scan files/folders. `--fail-under-days N`, `--format text\|json\|sarif\|github`, `-o FILE` |
| `endofmodel --version` | Print the installed version |

Exit codes for `scan`: `0` passed, `1` the gate failed, `2` usage error.

### Python API

| Function | Use it to |
|---|---|
| `check(model, provider=None)` | Get a `ModelStatus` for one model |
| `assert_models_ok(models, fail_under_days=0)` | Raise `ModelExpiringError` if any model is retired or retiring soon |
| `http_client()` / `async_http_client()` | Create an HTTP client that warns on live SDK calls |
| `wrap(client)` | Attach the same warnings to an existing OpenAI/Anthropic client |
| `on_event(fn)` | Run `fn(event)` on every new warning |
| `translate_errors(model=None)` | Turn a retired model's 404 into `ModelRetiredError` |
| `scan(path)` | Scan a file or folder from Python; returns findings |

### Configuration

| Environment variable | Effect |
|---|---|
| `ENDOFMODEL_REGISTRY_DIR` | Use a folder of registry JSON files instead of the built-in data |

## Where the data comes from

The registry is a set of JSON files in [`src/endofmodel/data/`](https://github.com/Agentdrops/endofmodel/tree/main/src/endofmodel/data), one per
provider:

| Provider | Source |
|---|---|
| OpenAI, Anthropic, Gemini | Copied by hand from each provider's official deprecation page |
| OpenRouter, Mistral, Z.ai, Moonshot, Microsoft, Upstage | Synced every week from OpenRouter's public model list. A bot opens a PR and a human reviews it before merging. |

Each entry links to the official notice, so you can always check the source.

## FAQ

**Does it send my prompts or model names anywhere?**
No. The data ships inside the package and every check runs locally. endofmodel makes no
network calls of its own.

**How do I get new deprecation dates?**
Upgrade the package: `pip install -U endofmodel`. To use your own or fresher data, point
`ENDOFMODEL_REGISTRY_DIR` at a folder of JSON files in the same format.

**Will it slow down my API calls?**
No. It reads the model name from the request and the response; the lookup is an in-memory
dictionary. It never retries, delays or blocks a call.

**A date is wrong, or a model is missing.**
Please open a PR: it's a one-line JSON edit. See [`CONTRIBUTING.md`](https://github.com/Agentdrops/endofmodel/blob/main/CONTRIBUTING.md).

**Azure OpenAI, Amazon Bedrock, Vertex AI?**
Not yet. They run their own retirement schedules, which are on the roadmap.

> Dates can change. Confirm against the linked notice before you migrate.

## More

- [`examples/`](https://github.com/Agentdrops/endofmodel/tree/main/examples): complete, runnable scripts for each feature
- [`CONTRIBUTING.md`](https://github.com/Agentdrops/endofmodel/blob/main/CONTRIBUTING.md): how to fix a date or add a model
- [`CHANGELOG.md`](https://github.com/Agentdrops/endofmodel/blob/main/CHANGELOG.md): what changed in each release

**Next up:** Azure OpenAI, Bedrock and Vertex AI schedules; automatic scraping of the
official deprecation pages; `endofmodel update` to fetch new data without upgrading.

## License

[Apache-2.0](https://github.com/Agentdrops/endofmodel/blob/main/LICENSE)
