Metadata-Version: 2.4
Name: llm-price-tracker
Version: 2026.6.121346
Summary: Fetch, normalise, snapshot, and diff official LLM API token pricing.
Project-URL: Homepage, https://pypi.org/project/llm-price-tracker/
Project-URL: Repository, https://github.com/evgeniievstafev/llm-price-tracker
Project-URL: Issues, https://github.com/evgeniievstafev/llm-price-tracker/issues
Author: Evgenii Evstafev
License: MIT License
        
        Copyright (c) 2026 Evgenii Evstafev
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ai,anthropic,llm,openai,pricing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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
Requires-Python: >=3.10
Requires-Dist: beautifulsoup4>=4.12
Requires-Dist: httpx>=0.27
Requires-Dist: lxml>=5.0
Requires-Dist: pydantic>=2.7
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: black>=24.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# llm-price-tracker

`llm-price-tracker` fetches official published API token prices for major LLM
providers, normalises them into one schema, and supports JSON snapshots and
snapshot diffs.

Prices are collected from official provider pages only. Provider page structures
can change without notice, so review fetched prices before using them for
production billing or customer-facing estimates.

## Supported providers

- OpenAI GPT API models: <https://developers.openai.com/api/docs/pricing>
- Anthropic Claude models: <https://docs.anthropic.com/en/docs/about-claude/pricing>
- Google Gemini models: <https://ai.google.dev/gemini-api/docs/pricing>
- Kimi / Moonshot AI models: <https://platform.kimi.ai/docs/pricing/chat>
- MiniMax models: <https://platform.minimax.io/docs/guides/pricing-paygo>
- Qwen / DashScope models: <https://www.alibabacloud.com/help/en/model-studio/models>

## Installation

```sh
pip install llm-price-tracker
```

For local development:

```sh
python3 -m pip install -e ".[dev]"
```

Python 3.10 or newer is required.

## Python usage

```python
from llm_price_tracker import (
    diff_snapshots,
    fetch_all_prices,
    fetch_provider_prices,
    load_snapshot,
    save_snapshot,
)

prices = fetch_all_prices()
openai_prices = fetch_provider_prices("openai")
save_snapshot(prices, "prices.json")

old = load_snapshot("prices-old.json")
new = load_snapshot("prices.json")
diff = diff_snapshots(old, new)
```

## CLI usage

```sh
llm-price-tracker list-providers
llm-price-tracker fetch --provider openai --output openai-prices.json
llm-price-tracker fetch --provider all --output prices.json
llm-price-tracker diff --old prices-old.json --new prices.json
llm-price-tracker diff --old prices-old.json --new prices.json --fail-on-change
```

The CLI exits non-zero when fetching, parsing, validation, or diff
`--fail-on-change` checks fail. Use `--ignore-errors` with `fetch --provider all`
to write successful providers while reporting skipped provider errors.

## Output schema

Snapshots are JSON arrays of `ModelPrice` objects. Decimal prices are serialized
as strings to avoid floating-point precision loss.

```json
[
  {
    "provider": "openai",
    "model": "gpt-4.1",
    "input_per_1m": "2.00",
    "output_per_1m": "8.00",
    "cached_input_per_1m": "0.50",
    "cache_write_5m_per_1m": null,
    "cache_write_1h_per_1m": null,
    "cache_storage_per_1m_hour": null,
    "currency": "USD",
    "unit": "1M tokens",
    "source_url": "https://openai.com/api/pricing/",
    "source_type": "html",
    "fetched_at": "2026-06-12T09:00:00Z",
    "modality": null,
    "billing_tier": null,
    "price_condition": null,
    "notes": null
  }
]
```

Some providers publish tiered or modality-specific prices. Those variants use
optional `modality`, `billing_tier`, and `price_condition` fields instead of
inventing new model names.

Provider adapters include lightweight required-model sanity checks for current
official pages. Those checks are adapter arguments so downstream users can
override them when providers rename, add, or deprecate models.

## Development

```sh
python3 -m pip install -e ".[dev]"
pytest
ruff check .
black --check .
```

Normal tests use saved fixtures and do not call live provider pages. Live tests,
when added, should be opt-in:

```sh
LLM_PRICE_TRACKER_LIVE_TESTS=1 pytest tests/live
```
