metergraph-core 0.8.28__tar.gz → 0.8.30__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metergraph_core-0.8.30/PKG-INFO +136 -0
- metergraph_core-0.8.30/README.md +106 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/pyproject.toml +1 -1
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/__init__.py +2 -0
- metergraph_core-0.8.30/src/metergraph_core/catalogs.py +121 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/data/models.yaml +24 -1
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/data/prices.yaml +76 -3
- metergraph_core-0.8.30/src/metergraph_core.egg-info/PKG-INFO +136 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core.egg-info/SOURCES.txt +1 -0
- metergraph_core-0.8.28/PKG-INFO +0 -847
- metergraph_core-0.8.28/README.md +0 -817
- metergraph_core-0.8.28/src/metergraph_core.egg-info/PKG-INFO +0 -847
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/MANIFEST.in +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/setup.cfg +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/billing.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/calls.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/catalog.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/catalog_delta.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/data/sources.yaml +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/extractors.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/families.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/loader.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/models.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/providers/__init__.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/providers/anthropic.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/providers/google.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/refresh.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/reliability.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/responses.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/retrieval.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core/sources.py +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core.egg-info/dependency_links.txt +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core.egg-info/requires.txt +0 -0
- {metergraph_core-0.8.28 → metergraph_core-0.8.30}/src/metergraph_core.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: metergraph-core
|
|
3
|
+
Version: 0.8.30
|
|
4
|
+
Summary: Open, effective-dated LLM pricing catalog and deterministic cost calculator for popular models across major providers and gateways, including OpenAI, Anthropic, Google Gemini, AWS Bedrock, OpenRouter, Vercel AI Gateway, and more.
|
|
5
|
+
Author: Metergraph
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/metergraph/metergraph
|
|
8
|
+
Project-URL: Documentation, https://github.com/metergraph/metergraph/tree/main/core#readme
|
|
9
|
+
Project-URL: Source, https://github.com/metergraph/metergraph/tree/main/core
|
|
10
|
+
Project-URL: Issues, https://github.com/metergraph/metergraph/issues
|
|
11
|
+
Project-URL: Release notes, https://github.com/metergraph/metergraph/releases
|
|
12
|
+
Keywords: llm,pricing,cost,token-pricing,model-catalog,llm-pricing,model-pricing,token-cost,cost-calculation,openai,anthropic,gemini,bedrock,openrouter,vercel-ai-gateway,finops
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
30
|
+
|
|
31
|
+
# metergraph-core
|
|
32
|
+
|
|
33
|
+
Calculate the cost of an LLM call from its model, provider, tokens, region, and
|
|
34
|
+
date. `metergraph-core` ships an open, effective-dated model pricing catalog and
|
|
35
|
+
a deterministic Python cost engine.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
python -m pip install metergraph-core
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Use `calculate_cost()` when you already have token counts:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from metergraph_core import ModelUsage, load_catalog
|
|
49
|
+
|
|
50
|
+
catalog = load_catalog(region="global")
|
|
51
|
+
result = catalog.calculate_cost(
|
|
52
|
+
model="gpt-5.4-mini",
|
|
53
|
+
provider="openai",
|
|
54
|
+
at="2026-08-17T00:00:00Z",
|
|
55
|
+
usage=ModelUsage(input_tokens=1000, output_tokens=200),
|
|
56
|
+
)
|
|
57
|
+
print(result.status, result.cost, result.currency)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The result identifies the applied model and price. Check `status` before using
|
|
61
|
+
its cost as a complete total: missing usage or unsupported rates can make a
|
|
62
|
+
result `partial` or `unpriced`.
|
|
63
|
+
|
|
64
|
+
## Choose the API for your input
|
|
65
|
+
|
|
66
|
+
| You have… | Start with… |
|
|
67
|
+
|---|---|
|
|
68
|
+
| Token counts and a model | `catalog.calculate_cost(..., usage=ModelUsage(...))` |
|
|
69
|
+
| A provider SDK response | `price_call_from_response(provider, response)` for token costs and supported retrieval fees |
|
|
70
|
+
| A normalized SDK or relay record | `price_call_from_record(record)` |
|
|
71
|
+
| Request handlers that need ready-to-use pricing data | `Catalogs`, with one instance shared across handlers |
|
|
72
|
+
| Model identities, executable routes, or candidate lists | `load_model_registry()` |
|
|
73
|
+
|
|
74
|
+
For price lookup, token-only response pricing, missing-data rules, gateway
|
|
75
|
+
billing evidence, and model metadata, see the
|
|
76
|
+
[pricing and model reference](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md).
|
|
77
|
+
|
|
78
|
+
## Serving real-time requests
|
|
79
|
+
|
|
80
|
+
Prepare catalogs once before accepting traffic. Request handlers then call
|
|
81
|
+
`catalogs.current()` and use the same pricing methods shown above. Choose one
|
|
82
|
+
of the following lifecycle options.
|
|
83
|
+
|
|
84
|
+
### Let the catalog own its refresh thread
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from metergraph_core import Catalogs
|
|
88
|
+
|
|
89
|
+
catalogs = Catalogs(region="global", refresh_seconds=300)
|
|
90
|
+
catalogs.start()
|
|
91
|
+
try:
|
|
92
|
+
print(catalogs.current().version)
|
|
93
|
+
finally:
|
|
94
|
+
catalogs.stop()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Use your own scheduler or threads
|
|
98
|
+
|
|
99
|
+
`prepare()` and `refresh()` are synchronous and create no threads. Prepare
|
|
100
|
+
before serving; run refreshes outside request handlers. This example schedules
|
|
101
|
+
one refresh on an executor owned by the application:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
105
|
+
from metergraph_core import Catalogs
|
|
106
|
+
|
|
107
|
+
catalogs = Catalogs(region="global")
|
|
108
|
+
catalogs.prepare()
|
|
109
|
+
try:
|
|
110
|
+
with ThreadPoolExecutor(max_workers=1) as executor:
|
|
111
|
+
refresh = executor.submit(catalogs.refresh)
|
|
112
|
+
print(catalogs.current().version)
|
|
113
|
+
refresh.result()
|
|
114
|
+
finally:
|
|
115
|
+
catalogs.stop()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Both options enable prepared-only reads. Without either option, `current()`
|
|
119
|
+
loads and refreshes on demand. The default source is the bundled catalog;
|
|
120
|
+
custom loaders can supply changing data. See the
|
|
121
|
+
[lifecycle contract](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md#catalog-lifecycle)
|
|
122
|
+
for refresh failures, custom sources, read-only values, and shutdown behavior.
|
|
123
|
+
|
|
124
|
+
## Reference and contributions
|
|
125
|
+
|
|
126
|
+
- [Pricing and model reference](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md):
|
|
127
|
+
loading, regional and dated prices, provider responses, retrieval fees,
|
|
128
|
+
model families, routes, training policy, billing evidence, and reliability.
|
|
129
|
+
- [Catalog maintenance](https://github.com/metergraph/metergraph/blob/main/core/docs/catalog-maintenance.md):
|
|
130
|
+
data files and versions, official sources, reviewed deltas, refresh tooling,
|
|
131
|
+
and provider contributions.
|
|
132
|
+
- [Public API exports](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md#public-api).
|
|
133
|
+
|
|
134
|
+
Core contains the shared datasets and pricing rules for
|
|
135
|
+
[Metergraph](https://github.com/metergraph/metergraph). Core does not own HTTP routes, database access,
|
|
136
|
+
authentication, ingestion, or dashboards; these belong to the applications using it.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# metergraph-core
|
|
2
|
+
|
|
3
|
+
Calculate the cost of an LLM call from its model, provider, tokens, region, and
|
|
4
|
+
date. `metergraph-core` ships an open, effective-dated model pricing catalog and
|
|
5
|
+
a deterministic Python cost engine.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
python -m pip install metergraph-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Use `calculate_cost()` when you already have token counts:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from metergraph_core import ModelUsage, load_catalog
|
|
19
|
+
|
|
20
|
+
catalog = load_catalog(region="global")
|
|
21
|
+
result = catalog.calculate_cost(
|
|
22
|
+
model="gpt-5.4-mini",
|
|
23
|
+
provider="openai",
|
|
24
|
+
at="2026-08-17T00:00:00Z",
|
|
25
|
+
usage=ModelUsage(input_tokens=1000, output_tokens=200),
|
|
26
|
+
)
|
|
27
|
+
print(result.status, result.cost, result.currency)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The result identifies the applied model and price. Check `status` before using
|
|
31
|
+
its cost as a complete total: missing usage or unsupported rates can make a
|
|
32
|
+
result `partial` or `unpriced`.
|
|
33
|
+
|
|
34
|
+
## Choose the API for your input
|
|
35
|
+
|
|
36
|
+
| You have… | Start with… |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Token counts and a model | `catalog.calculate_cost(..., usage=ModelUsage(...))` |
|
|
39
|
+
| A provider SDK response | `price_call_from_response(provider, response)` for token costs and supported retrieval fees |
|
|
40
|
+
| A normalized SDK or relay record | `price_call_from_record(record)` |
|
|
41
|
+
| Request handlers that need ready-to-use pricing data | `Catalogs`, with one instance shared across handlers |
|
|
42
|
+
| Model identities, executable routes, or candidate lists | `load_model_registry()` |
|
|
43
|
+
|
|
44
|
+
For price lookup, token-only response pricing, missing-data rules, gateway
|
|
45
|
+
billing evidence, and model metadata, see the
|
|
46
|
+
[pricing and model reference](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md).
|
|
47
|
+
|
|
48
|
+
## Serving real-time requests
|
|
49
|
+
|
|
50
|
+
Prepare catalogs once before accepting traffic. Request handlers then call
|
|
51
|
+
`catalogs.current()` and use the same pricing methods shown above. Choose one
|
|
52
|
+
of the following lifecycle options.
|
|
53
|
+
|
|
54
|
+
### Let the catalog own its refresh thread
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from metergraph_core import Catalogs
|
|
58
|
+
|
|
59
|
+
catalogs = Catalogs(region="global", refresh_seconds=300)
|
|
60
|
+
catalogs.start()
|
|
61
|
+
try:
|
|
62
|
+
print(catalogs.current().version)
|
|
63
|
+
finally:
|
|
64
|
+
catalogs.stop()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Use your own scheduler or threads
|
|
68
|
+
|
|
69
|
+
`prepare()` and `refresh()` are synchronous and create no threads. Prepare
|
|
70
|
+
before serving; run refreshes outside request handlers. This example schedules
|
|
71
|
+
one refresh on an executor owned by the application:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
75
|
+
from metergraph_core import Catalogs
|
|
76
|
+
|
|
77
|
+
catalogs = Catalogs(region="global")
|
|
78
|
+
catalogs.prepare()
|
|
79
|
+
try:
|
|
80
|
+
with ThreadPoolExecutor(max_workers=1) as executor:
|
|
81
|
+
refresh = executor.submit(catalogs.refresh)
|
|
82
|
+
print(catalogs.current().version)
|
|
83
|
+
refresh.result()
|
|
84
|
+
finally:
|
|
85
|
+
catalogs.stop()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Both options enable prepared-only reads. Without either option, `current()`
|
|
89
|
+
loads and refreshes on demand. The default source is the bundled catalog;
|
|
90
|
+
custom loaders can supply changing data. See the
|
|
91
|
+
[lifecycle contract](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md#catalog-lifecycle)
|
|
92
|
+
for refresh failures, custom sources, read-only values, and shutdown behavior.
|
|
93
|
+
|
|
94
|
+
## Reference and contributions
|
|
95
|
+
|
|
96
|
+
- [Pricing and model reference](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md):
|
|
97
|
+
loading, regional and dated prices, provider responses, retrieval fees,
|
|
98
|
+
model families, routes, training policy, billing evidence, and reliability.
|
|
99
|
+
- [Catalog maintenance](https://github.com/metergraph/metergraph/blob/main/core/docs/catalog-maintenance.md):
|
|
100
|
+
data files and versions, official sources, reviewed deltas, refresh tooling,
|
|
101
|
+
and provider contributions.
|
|
102
|
+
- [Public API exports](https://github.com/metergraph/metergraph/blob/main/core/docs/usage.md#public-api).
|
|
103
|
+
|
|
104
|
+
Core contains the shared datasets and pricing rules for
|
|
105
|
+
[Metergraph](https://github.com/metergraph/metergraph). Core does not own HTTP routes, database access,
|
|
106
|
+
authentication, ingestion, or dashboards; these belong to the applications using it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "metergraph-core"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.30"
|
|
4
4
|
description = "Open, effective-dated LLM pricing catalog and deterministic cost calculator for popular models across major providers and gateways, including OpenAI, Anthropic, Google Gemini, AWS Bedrock, OpenRouter, Vercel AI Gateway, and more."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -31,6 +31,7 @@ from .loader import (
|
|
|
31
31
|
parse_catalog,
|
|
32
32
|
parse_retrieval,
|
|
33
33
|
)
|
|
34
|
+
from .catalogs import Catalogs
|
|
34
35
|
from .models import (
|
|
35
36
|
TRAINING_ON_CUSTOMER_DATA,
|
|
36
37
|
EffectiveTrainingPolicy,
|
|
@@ -150,6 +151,7 @@ __all__ = [
|
|
|
150
151
|
"counts_cache_read_in_input",
|
|
151
152
|
"direct_channel_for_provider",
|
|
152
153
|
"normalize_provider",
|
|
154
|
+
"Catalogs",
|
|
153
155
|
"load_catalog",
|
|
154
156
|
"load_catalog_document",
|
|
155
157
|
"load_model_registry",
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Prepared pricing catalogs with an optional background refresher."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import threading
|
|
5
|
+
import time
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from typing import Generic, TypeVar, cast
|
|
8
|
+
|
|
9
|
+
from .loader import load_catalog
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
log = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Catalogs(Generic[T]):
|
|
16
|
+
"""Serve one prepared catalog value, retaining it across refresh failures.
|
|
17
|
+
|
|
18
|
+
The default loader builds the bundled catalog for ``region``. A custom
|
|
19
|
+
loader must return a complete value that readers treat as read-only.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
*,
|
|
25
|
+
region: str = "global",
|
|
26
|
+
loader: Callable[[], T] | None = None,
|
|
27
|
+
initial: T | None = None,
|
|
28
|
+
refresh_seconds: float = 300,
|
|
29
|
+
monotonic: Callable[[], float] = time.monotonic,
|
|
30
|
+
) -> None:
|
|
31
|
+
if refresh_seconds <= 0:
|
|
32
|
+
raise ValueError("refresh_seconds must be positive")
|
|
33
|
+
self._loader = loader or cast(Callable[[], T], lambda: load_catalog(region=region))
|
|
34
|
+
self._interval = refresh_seconds
|
|
35
|
+
self._monotonic = monotonic
|
|
36
|
+
self._lock = threading.Lock()
|
|
37
|
+
self._loading = threading.Lock()
|
|
38
|
+
self._lifecycle = threading.RLock()
|
|
39
|
+
self._value: T | None = initial
|
|
40
|
+
self._next_refresh = 0.0
|
|
41
|
+
self._prepared = False
|
|
42
|
+
self._worker: threading.Thread | None = None
|
|
43
|
+
self._stopped = threading.Event()
|
|
44
|
+
|
|
45
|
+
def current(self) -> T:
|
|
46
|
+
"""Read prepared data, or load on demand when no lifecycle is active."""
|
|
47
|
+
with self._lock:
|
|
48
|
+
if self._value is not None and (
|
|
49
|
+
self._prepared
|
|
50
|
+
or self._monotonic() < self._next_refresh
|
|
51
|
+
or self._loading.locked()
|
|
52
|
+
):
|
|
53
|
+
return self._value
|
|
54
|
+
return self._reload(force=False)
|
|
55
|
+
|
|
56
|
+
def _reload(self, *, force: bool) -> T:
|
|
57
|
+
with self._loading:
|
|
58
|
+
with self._lock:
|
|
59
|
+
previous = self._value
|
|
60
|
+
if not force and previous is not None and (
|
|
61
|
+
self._prepared or self._monotonic() < self._next_refresh
|
|
62
|
+
):
|
|
63
|
+
return previous
|
|
64
|
+
try:
|
|
65
|
+
value = self._loader()
|
|
66
|
+
except Exception:
|
|
67
|
+
with self._lock:
|
|
68
|
+
self._next_refresh = self._monotonic() + self._interval
|
|
69
|
+
if force or previous is None:
|
|
70
|
+
raise
|
|
71
|
+
log.warning("catalog refresh failed; keeping prepared data", exc_info=True)
|
|
72
|
+
return previous
|
|
73
|
+
with self._lock:
|
|
74
|
+
self._value = value
|
|
75
|
+
self._next_refresh = self._monotonic() + self._interval
|
|
76
|
+
return value
|
|
77
|
+
|
|
78
|
+
def prepare(self) -> T:
|
|
79
|
+
"""Load if needed and enable prepared-only reads. Starts no thread."""
|
|
80
|
+
with self._lifecycle:
|
|
81
|
+
value = self._reload(force=False)
|
|
82
|
+
with self._lock:
|
|
83
|
+
self._prepared = True
|
|
84
|
+
return value
|
|
85
|
+
|
|
86
|
+
def refresh(self) -> T:
|
|
87
|
+
"""Synchronously publish a complete replacement; raise on failure."""
|
|
88
|
+
return self._reload(force=True)
|
|
89
|
+
|
|
90
|
+
def start(self) -> T:
|
|
91
|
+
"""Prepare before returning and start one owned refresh thread."""
|
|
92
|
+
with self._lifecycle:
|
|
93
|
+
value = self.prepare()
|
|
94
|
+
if self._worker is None:
|
|
95
|
+
self._stopped.clear()
|
|
96
|
+
self._worker = threading.Thread(
|
|
97
|
+
target=self._run, name="pricing-catalog-refresh", daemon=True
|
|
98
|
+
)
|
|
99
|
+
self._worker.start()
|
|
100
|
+
return value
|
|
101
|
+
|
|
102
|
+
def _run(self) -> None:
|
|
103
|
+
while not self._stopped.wait(self._interval):
|
|
104
|
+
try:
|
|
105
|
+
self.refresh()
|
|
106
|
+
except Exception:
|
|
107
|
+
log.warning("catalog refresh failed; keeping prepared data", exc_info=True)
|
|
108
|
+
|
|
109
|
+
def stop(self) -> None:
|
|
110
|
+
"""Join owned background work, retain data, and restore on-demand reads.
|
|
111
|
+
|
|
112
|
+
Caller-scheduled refreshes remain the caller's responsibility. A custom
|
|
113
|
+
loader must bound its I/O so an owned refresh can finish during shutdown.
|
|
114
|
+
"""
|
|
115
|
+
with self._lifecycle:
|
|
116
|
+
if self._worker is not None:
|
|
117
|
+
self._stopped.set()
|
|
118
|
+
self._worker.join()
|
|
119
|
+
self._worker = None
|
|
120
|
+
with self._lock:
|
|
121
|
+
self._prepared = False
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
version: '2026-11-
|
|
1
|
+
version: '2026-11-20'
|
|
2
2
|
# Training use of customer inputs and outputs under each serving provider's
|
|
3
3
|
# default terms. A pair left out resolves to unknown. A gateway or cloud host
|
|
4
4
|
# follows its own terms, never the model publisher's. No policy verifies an
|
|
@@ -666,6 +666,13 @@ models:
|
|
|
666
666
|
publisher: openai
|
|
667
667
|
released: '2026-03-05' # https://en.wikipedia.org/wiki/GPT-5.4
|
|
668
668
|
routes:
|
|
669
|
+
- key: default:openai/gpt-5.4
|
|
670
|
+
id: openai/gpt-5.4
|
|
671
|
+
provider: vercel
|
|
672
|
+
model_id: openai/gpt-5.4
|
|
673
|
+
pricing_channel: vercel-ai-gateway
|
|
674
|
+
execution_profiles:
|
|
675
|
+
- default
|
|
669
676
|
- key: default:openai:gpt-5.4
|
|
670
677
|
id: openai:gpt-5.4
|
|
671
678
|
provider: openai
|
|
@@ -1046,6 +1053,18 @@ models:
|
|
|
1046
1053
|
pricing_channel: vercel-ai-gateway
|
|
1047
1054
|
execution_profiles:
|
|
1048
1055
|
- default
|
|
1056
|
+
- canonical_id: google/gemini-4-neon
|
|
1057
|
+
display_name: Gemini 4 Neon
|
|
1058
|
+
publisher: google
|
|
1059
|
+
released: '2026-11-18' # https://vercel.com/changelog/gemini-4-neon-now-available-on-ai-gateway
|
|
1060
|
+
routes:
|
|
1061
|
+
- key: default:google/gemini-4-neon
|
|
1062
|
+
id: google/gemini-4-neon
|
|
1063
|
+
provider: vercel
|
|
1064
|
+
model_id: google/gemini-4-neon
|
|
1065
|
+
pricing_channel: vercel-ai-gateway
|
|
1066
|
+
execution_profiles:
|
|
1067
|
+
- default
|
|
1049
1068
|
- canonical_id: google/gemini-4-hydrogen
|
|
1050
1069
|
display_name: Gemini 4 Hydrogen
|
|
1051
1070
|
publisher: google
|
|
@@ -1200,6 +1219,8 @@ execution_profiles:
|
|
|
1200
1219
|
- default:openai/gpt-6.2-astra
|
|
1201
1220
|
- default:openai:gpt-6.2-sol
|
|
1202
1221
|
- default:openai:gpt-6.2-astra
|
|
1222
|
+
- default:openai/gpt-5.4
|
|
1223
|
+
- default:google/gemini-4-neon
|
|
1203
1224
|
|
|
1204
1225
|
- id: bedrock
|
|
1205
1226
|
routes:
|
|
@@ -1282,6 +1303,8 @@ offer_groups:
|
|
|
1282
1303
|
- default:alibaba/qwen4-max
|
|
1283
1304
|
- default:openai/gpt-6.2-sol
|
|
1284
1305
|
- default:openai/gpt-6.2-astra
|
|
1306
|
+
- default:openai/gpt-5.4
|
|
1307
|
+
- default:google/gemini-4-neon
|
|
1285
1308
|
- id: fireworks
|
|
1286
1309
|
credential: FIREWORKS_API_KEY
|
|
1287
1310
|
routes:
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
#
|
|
7
7
|
# Community updates welcome: add an alias or price entry with its provider
|
|
8
8
|
# source_url and open a PR. CI validates structure and date overlaps.
|
|
9
|
-
version: "2026-11-
|
|
9
|
+
version: "2026-11-20"
|
|
10
10
|
currency: USD
|
|
11
|
-
pricing_verified_at: "2026-11-
|
|
11
|
+
pricing_verified_at: "2026-11-20"
|
|
12
12
|
models:
|
|
13
13
|
- canonical_id: openai/gpt-6-sol
|
|
14
14
|
publisher: openai
|
|
@@ -2218,6 +2218,7 @@ models:
|
|
|
2218
2218
|
- canonical_id: google/gemini-4-argon
|
|
2219
2219
|
publisher: google
|
|
2220
2220
|
aliases:
|
|
2221
|
+
- {provider: vertex-ai, alias: gemini-4-argon, channel: google-vertex-ai}
|
|
2221
2222
|
- {provider: google, alias: gemini-4-argon, channel: google-api}
|
|
2222
2223
|
- {provider: google, alias: models/gemini-4-argon, channel: google-api}
|
|
2223
2224
|
- {provider: litellm, alias: gemini-4-argon, channel: google-api}
|
|
@@ -2229,6 +2230,28 @@ models:
|
|
|
2229
2230
|
channel: vercel-ai-gateway
|
|
2230
2231
|
rules: {input_includes_cache_read: true}
|
|
2231
2232
|
prices:
|
|
2233
|
+
# Introductory net prices include Google's 50% promotional credits.
|
|
2234
|
+
- channel: google-vertex-ai
|
|
2235
|
+
region: global
|
|
2236
|
+
effective_from: "2026-10-13"
|
|
2237
|
+
effective_to: "2026-12-01"
|
|
2238
|
+
input_per_mtok: 2.00
|
|
2239
|
+
output_per_mtok: 10.00
|
|
2240
|
+
cache_read_per_mtok: 0.10
|
|
2241
|
+
batch_input_per_mtok: 1.00
|
|
2242
|
+
batch_output_per_mtok: 5.00
|
|
2243
|
+
batch_cache_read_per_mtok: 0.05
|
|
2244
|
+
source_url: https://cloud.google.com/model-garden/pricing
|
|
2245
|
+
- channel: google-vertex-ai
|
|
2246
|
+
region: global
|
|
2247
|
+
effective_from: "2026-12-01"
|
|
2248
|
+
input_per_mtok: 4.00
|
|
2249
|
+
output_per_mtok: 20.00
|
|
2250
|
+
cache_read_per_mtok: 0.20
|
|
2251
|
+
batch_input_per_mtok: 2.00
|
|
2252
|
+
batch_output_per_mtok: 10.00
|
|
2253
|
+
batch_cache_read_per_mtok: 0.10
|
|
2254
|
+
source_url: https://cloud.google.com/model-garden/pricing
|
|
2232
2255
|
- channel: google-api
|
|
2233
2256
|
region: global
|
|
2234
2257
|
effective_from: "2026-10-13"
|
|
@@ -2409,6 +2432,7 @@ models:
|
|
|
2409
2432
|
- channel: google-api
|
|
2410
2433
|
region: global
|
|
2411
2434
|
effective_from: "2025-06-17"
|
|
2435
|
+
effective_to: "2026-12-01"
|
|
2412
2436
|
input_per_mtok: 1.25
|
|
2413
2437
|
output_per_mtok: 10.00
|
|
2414
2438
|
cache_read_per_mtok: 0.125
|
|
@@ -2417,6 +2441,26 @@ models:
|
|
|
2417
2441
|
rules:
|
|
2418
2442
|
long_context: {threshold: 200000, input_multiplier: 2, output_multiplier: 1.5}
|
|
2419
2443
|
source_url: https://ai.google.dev/gemini-api/docs/pricing
|
|
2444
|
+
# Routed to gemini-3.8-flash; mirrors its google-api rows.
|
|
2445
|
+
- channel: google-api
|
|
2446
|
+
region: global
|
|
2447
|
+
effective_from: "2026-12-01"
|
|
2448
|
+
effective_to: "2027-01-01"
|
|
2449
|
+
input_per_mtok: 0.75
|
|
2450
|
+
output_per_mtok: 3.75
|
|
2451
|
+
cache_read_per_mtok: 0.075
|
|
2452
|
+
batch_input_per_mtok: 0.375
|
|
2453
|
+
batch_output_per_mtok: 1.875
|
|
2454
|
+
source_url: https://aistudio.google.com/docs/changelog
|
|
2455
|
+
- channel: google-api
|
|
2456
|
+
region: global
|
|
2457
|
+
effective_from: "2027-01-01"
|
|
2458
|
+
input_per_mtok: 1.50
|
|
2459
|
+
output_per_mtok: 7.50
|
|
2460
|
+
cache_read_per_mtok: 0.15
|
|
2461
|
+
batch_input_per_mtok: 0.75
|
|
2462
|
+
batch_output_per_mtok: 3.75
|
|
2463
|
+
source_url: https://aistudio.google.com/docs/changelog
|
|
2420
2464
|
|
|
2421
2465
|
- channel: vercel-ai-gateway
|
|
2422
2466
|
region: global
|
|
@@ -8403,6 +8447,7 @@ models:
|
|
|
8403
8447
|
rules:
|
|
8404
8448
|
input_includes_cache_read: true
|
|
8405
8449
|
input_includes_cache_write: true
|
|
8450
|
+
- {provider: meta, alias: muse-spark-1.2-contributor, channel: meta-api, rules: {input_includes_cache_read: true}}
|
|
8406
8451
|
prices:
|
|
8407
8452
|
- channel: vercel-ai-gateway
|
|
8408
8453
|
region: global
|
|
@@ -8411,6 +8456,14 @@ models:
|
|
|
8411
8456
|
output_per_mtok: 0.2
|
|
8412
8457
|
cache_read_per_mtok: 0.002
|
|
8413
8458
|
source_url: https://ai-gateway.vercel.sh/v1/models
|
|
8459
|
+
# First verified Meta API rate, not its launch date.
|
|
8460
|
+
- channel: meta-api
|
|
8461
|
+
region: global
|
|
8462
|
+
effective_from: "2026-11-20"
|
|
8463
|
+
input_per_mtok: 0.10
|
|
8464
|
+
output_per_mtok: 0.20
|
|
8465
|
+
cache_read_per_mtok: 0.002
|
|
8466
|
+
source_url: https://dev.meta.ai/docs/pricing-rate-limits
|
|
8414
8467
|
|
|
8415
8468
|
- canonical_id: meta/muse-spark-1.3-contributor
|
|
8416
8469
|
publisher: meta
|
|
@@ -8421,6 +8474,7 @@ models:
|
|
|
8421
8474
|
rules:
|
|
8422
8475
|
input_includes_cache_read: true
|
|
8423
8476
|
input_includes_cache_write: true
|
|
8477
|
+
- {provider: meta, alias: muse-spark-1.3-contributor, channel: meta-api, rules: {input_includes_cache_read: true}}
|
|
8424
8478
|
prices:
|
|
8425
8479
|
- channel: vercel-ai-gateway
|
|
8426
8480
|
region: global
|
|
@@ -8429,6 +8483,14 @@ models:
|
|
|
8429
8483
|
output_per_mtok: 0.2
|
|
8430
8484
|
cache_read_per_mtok: 0.002
|
|
8431
8485
|
source_url: https://ai-gateway.vercel.sh/v1/models
|
|
8486
|
+
# First verified Meta API rate, not its launch date.
|
|
8487
|
+
- channel: meta-api
|
|
8488
|
+
region: global
|
|
8489
|
+
effective_from: "2026-11-20"
|
|
8490
|
+
input_per_mtok: 0.10
|
|
8491
|
+
output_per_mtok: 0.20
|
|
8492
|
+
cache_read_per_mtok: 0.002
|
|
8493
|
+
source_url: https://dev.meta.ai/docs/pricing-rate-limits
|
|
8432
8494
|
|
|
8433
8495
|
- canonical_id: minimax/minimax-m2
|
|
8434
8496
|
publisher: minimax
|
|
@@ -13890,6 +13952,7 @@ models:
|
|
|
13890
13952
|
- canonical_id: google/gemini-4-hydrogen
|
|
13891
13953
|
publisher: google
|
|
13892
13954
|
aliases:
|
|
13955
|
+
- {provider: vertex-ai, alias: gemini-4-hydrogen, channel: google-vertex-ai}
|
|
13893
13956
|
- {provider: google, alias: gemini-4-hydrogen, channel: google-api}
|
|
13894
13957
|
- {provider: google, alias: models/gemini-4-hydrogen, channel: google-api}
|
|
13895
13958
|
- {provider: litellm, alias: gemini-4-hydrogen, channel: google-api}
|
|
@@ -13905,6 +13968,16 @@ models:
|
|
|
13905
13968
|
channel: vercel-ai-gateway
|
|
13906
13969
|
rules: {input_includes_cache_read: true}
|
|
13907
13970
|
prices:
|
|
13971
|
+
- channel: google-vertex-ai
|
|
13972
|
+
region: global
|
|
13973
|
+
effective_from: "2026-11-12"
|
|
13974
|
+
input_per_mtok: 1.50
|
|
13975
|
+
output_per_mtok: 7.50
|
|
13976
|
+
cache_read_per_mtok: 0.075
|
|
13977
|
+
batch_input_per_mtok: 0.75
|
|
13978
|
+
batch_output_per_mtok: 3.75
|
|
13979
|
+
batch_cache_read_per_mtok: 0.0375
|
|
13980
|
+
source_url: https://cloud.google.com/model-garden/pricing
|
|
13908
13981
|
- channel: google-api
|
|
13909
13982
|
region: global
|
|
13910
13983
|
effective_from: "2026-11-12"
|
|
@@ -14005,7 +14078,7 @@ retrieval:
|
|
|
14005
14078
|
per_1k_usd: 14.00
|
|
14006
14079
|
effective_from: "2026-08-26"
|
|
14007
14080
|
source_url: https://ai.google.dev/gemini-api/docs/pricing
|
|
14008
|
-
# Gemini 3 on Vertex
|
|
14081
|
+
# Gemini 3 and 4 on Vertex are charged per grounding query after 5,000 free a
|
|
14009
14082
|
# month. Gemini 2.5 and 2.0 are charged per grounded prompt and are not
|
|
14010
14083
|
# represented.
|
|
14011
14084
|
- channel: google-vertex-ai
|