metergraph-core 0.8.31__tar.gz → 0.9.0__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.31/src/metergraph_core.egg-info → metergraph_core-0.9.0}/PKG-INFO +1 -1
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/pyproject.toml +1 -1
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/__init__.py +8 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/catalog.py +71 -2
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/data/prices.yaml +109 -1
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/loader.py +42 -1
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/models.py +17 -1
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/reliability.py +24 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0/src/metergraph_core.egg-info}/PKG-INFO +1 -1
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/MANIFEST.in +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/README.md +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/setup.cfg +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/billing.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/calls.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/catalog_delta.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/catalogs.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/data/models.yaml +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/data/sources.yaml +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/extractors.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/families.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/providers/__init__.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/providers/anthropic.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/providers/google.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/refresh.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/responses.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/retrieval.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core/sources.py +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core.egg-info/SOURCES.txt +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core.egg-info/dependency_links.txt +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core.egg-info/requires.txt +0 -0
- {metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metergraph-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
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
5
|
Author: Metergraph
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "metergraph-core"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.9.0"
|
|
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"
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"""Reusable MeterGraph catalog and deterministic token-cost pricing core."""
|
|
2
2
|
|
|
3
3
|
from .catalog import (
|
|
4
|
+
DECISION,
|
|
5
|
+
DEFAULT_MODEL_CLASS,
|
|
6
|
+
GENERATIVE,
|
|
7
|
+
MODEL_CLASSES,
|
|
4
8
|
CostComponents,
|
|
5
9
|
Alias,
|
|
6
10
|
CatalogSnapshot,
|
|
@@ -91,6 +95,10 @@ from .sources import (
|
|
|
91
95
|
)
|
|
92
96
|
|
|
93
97
|
__all__ = [
|
|
98
|
+
"DECISION",
|
|
99
|
+
"DEFAULT_MODEL_CLASS",
|
|
100
|
+
"GENERATIVE",
|
|
101
|
+
"MODEL_CLASSES",
|
|
94
102
|
"CatalogDelta",
|
|
95
103
|
"CATALOG_DELTA_SCHEMA_VERSION",
|
|
96
104
|
"CatalogDeltaConflict",
|
|
@@ -61,6 +61,8 @@ _DIRECT_CHANNEL_BY_PROVIDER = {
|
|
|
61
61
|
"mistral": "mistral-api",
|
|
62
62
|
"moonshotai": "moonshot-api",
|
|
63
63
|
"zai": "zai-api",
|
|
64
|
+
"typesafe": "typesafe-api",
|
|
65
|
+
"typesafe-ai": "typesafe-api",
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
|
|
@@ -111,6 +113,18 @@ MODEL_NOT_IN_EFFECT = "model_not_in_effect"
|
|
|
111
113
|
MODEL_NOT_IN_REGION = "model_not_in_region"
|
|
112
114
|
PRICE_NOT_IN_EFFECT = "price_not_in_effect"
|
|
113
115
|
|
|
116
|
+
# What kind of model a catalog entry prices. A ``generative`` model writes
|
|
117
|
+
# output (an LLM); a ``decision`` model answers typed questions and is billed
|
|
118
|
+
# on input only. An entry that states none is ``generative``. The set is
|
|
119
|
+
# closed: a value outside it is a catalog error, never a guess.
|
|
120
|
+
GENERATIVE = "generative"
|
|
121
|
+
DECISION = "decision"
|
|
122
|
+
MODEL_CLASSES = (GENERATIVE, DECISION)
|
|
123
|
+
DEFAULT_MODEL_CLASS = GENERATIVE
|
|
124
|
+
# A call with no recorded provider resolves through the aliases a catalog
|
|
125
|
+
# lists for a provider it cannot name.
|
|
126
|
+
_UNKNOWN_PROVIDER_KEY = "unknown"
|
|
127
|
+
|
|
114
128
|
|
|
115
129
|
def _bedrock_fallback_ids(model_key: str) -> tuple[tuple[str, bool], ...]:
|
|
116
130
|
"""Candidate ids for an unmatched Bedrock model, most specific first.
|
|
@@ -204,6 +218,8 @@ class Alias:
|
|
|
204
218
|
source_url: str | None = None
|
|
205
219
|
# Limits an identifier to matching regions; global matches every snapshot.
|
|
206
220
|
price_region: tuple[str, ...] = ()
|
|
221
|
+
# The class of the model this alias resolves to; see MODEL_CLASSES.
|
|
222
|
+
model_class: str = DEFAULT_MODEL_CLASS
|
|
207
223
|
|
|
208
224
|
|
|
209
225
|
def _crosses_price_region(alias: Alias) -> bool:
|
|
@@ -334,6 +350,9 @@ class CostResult:
|
|
|
334
350
|
# Why an unpriced result is unpriced, when the cause is a value the
|
|
335
351
|
# caller sent. Empty otherwise.
|
|
336
352
|
warnings: tuple["PricingWarning", ...] = ()
|
|
353
|
+
# The class of the resolved catalog entry (see MODEL_CLASSES), or None
|
|
354
|
+
# when no entry resolved.
|
|
355
|
+
model_class: str | None = None
|
|
337
356
|
|
|
338
357
|
@property
|
|
339
358
|
def model_id(self) -> str | None:
|
|
@@ -413,6 +432,8 @@ class ResolvedPrice:
|
|
|
413
432
|
rules: Mapping[str, Any]
|
|
414
433
|
# The last known price: it ended before the resolved time, unreplaced.
|
|
415
434
|
ended: bool = False
|
|
435
|
+
# The class of the resolved catalog entry; see MODEL_CLASSES.
|
|
436
|
+
model_class: str = DEFAULT_MODEL_CLASS
|
|
416
437
|
|
|
417
438
|
|
|
418
439
|
def _billed_terms(resolved: ResolvedPrice) -> tuple[Any, ...]:
|
|
@@ -589,10 +610,16 @@ def _price_tokens(
|
|
|
589
610
|
_cached_count(cache_write_1h_tokens, "cache_write_1h_tokens", reasons) or 0
|
|
590
611
|
)
|
|
591
612
|
cache_write_count = cache_write_5m_count + cache_write_1h_count
|
|
613
|
+
# A missing count is a reason only when its rate is not exactly zero,
|
|
614
|
+
# which is known once the effective rates are; its place among the
|
|
615
|
+
# reasons is kept so results read as they always have.
|
|
616
|
+
input_missing_at = output_missing_at = None
|
|
592
617
|
if input_count is None:
|
|
618
|
+
input_missing_at = len(reasons)
|
|
593
619
|
reasons.append("missing_input_tokens")
|
|
594
620
|
input_count = 0
|
|
595
621
|
if output_count is None:
|
|
622
|
+
output_missing_at = len(reasons)
|
|
596
623
|
reasons.append("missing_output_tokens")
|
|
597
624
|
output_count = 0
|
|
598
625
|
|
|
@@ -708,6 +735,24 @@ def _price_tokens(
|
|
|
708
735
|
input_multiplier *= off_peak
|
|
709
736
|
output_multiplier *= off_peak
|
|
710
737
|
|
|
738
|
+
# A usage component whose effective rate is exactly zero costs nothing
|
|
739
|
+
# whatever its count, so an absent count leaves the figure complete: a
|
|
740
|
+
# model billed on input alone is priced without output usage. An
|
|
741
|
+
# unknown rate (None) never qualifies. Missing input also keeps its
|
|
742
|
+
# reason when a long-context tier would read the count it lacks.
|
|
743
|
+
exempt = []
|
|
744
|
+
if output_missing_at is not None and output_rate is not None and output_rate == 0:
|
|
745
|
+
exempt.append(output_missing_at)
|
|
746
|
+
if (
|
|
747
|
+
input_missing_at is not None
|
|
748
|
+
and input_rate is not None
|
|
749
|
+
and input_rate == 0
|
|
750
|
+
and threshold is None
|
|
751
|
+
):
|
|
752
|
+
exempt.append(input_missing_at)
|
|
753
|
+
for index in sorted(exempt, reverse=True):
|
|
754
|
+
del reasons[index]
|
|
755
|
+
|
|
711
756
|
input_usd = output_usd = cache_read_usd = cache_write_usd = Decimal("0")
|
|
712
757
|
if input_rate is None:
|
|
713
758
|
if billable_input:
|
|
@@ -816,6 +861,7 @@ def _cost_result(
|
|
|
816
861
|
currency=resolved.price.currency,
|
|
817
862
|
effective_at=at,
|
|
818
863
|
missing_dimensions=missing,
|
|
864
|
+
model_class=resolved.model_class,
|
|
819
865
|
)
|
|
820
866
|
|
|
821
867
|
|
|
@@ -1017,6 +1063,7 @@ class CatalogSnapshot:
|
|
|
1017
1063
|
price=price,
|
|
1018
1064
|
rules=MappingProxyType({**price.rules, **alias.rules}),
|
|
1019
1065
|
ended=ended,
|
|
1066
|
+
model_class=alias.model_class,
|
|
1020
1067
|
)
|
|
1021
1068
|
|
|
1022
1069
|
def _lookup(
|
|
@@ -1033,7 +1080,13 @@ class CatalogSnapshot:
|
|
|
1033
1080
|
some region prices is unpriced with ``region`` missing.
|
|
1034
1081
|
"""
|
|
1035
1082
|
if channel is None or not str(channel).strip():
|
|
1036
|
-
|
|
1083
|
+
if provider is None or not str(provider).strip():
|
|
1084
|
+
# No recorded provider is as much as an unknown one: such a
|
|
1085
|
+
# call resolves only through the aliases listed for provider
|
|
1086
|
+
# "unknown", as in :meth:`cost`.
|
|
1087
|
+
channel = self._unknown_provider_channel(model, at)
|
|
1088
|
+
else:
|
|
1089
|
+
channel = direct_channel_for_provider(provider)
|
|
1037
1090
|
if channel is None:
|
|
1038
1091
|
return None, ("channel",)
|
|
1039
1092
|
stated = str(region or "").strip().lower() or None
|
|
@@ -1054,6 +1107,14 @@ class CatalogSnapshot:
|
|
|
1054
1107
|
return resolved, ("region",)
|
|
1055
1108
|
return resolved, ()
|
|
1056
1109
|
|
|
1110
|
+
def _unknown_provider_channel(self, model: Any, at: Any) -> str | None:
|
|
1111
|
+
"""The pricing channel of the alias listed for provider "unknown"
|
|
1112
|
+
that names ``model`` at ``at``, or None when there is none."""
|
|
1113
|
+
model_key = str(model or "").strip().lower()
|
|
1114
|
+
candidates = self._aliases.get((_UNKNOWN_PROVIDER_KEY, model_key), ())
|
|
1115
|
+
alias = self._alias_for(candidates, _coerce_datetime(at))
|
|
1116
|
+
return alias.pricing_channel if alias is not None else None
|
|
1117
|
+
|
|
1057
1118
|
def _explain(
|
|
1058
1119
|
self, *, model: Any, channel: Any, provider: Any, at: Any, region: Any
|
|
1059
1120
|
) -> tuple[PricingWarning, ...]:
|
|
@@ -1211,6 +1272,9 @@ class CatalogSnapshot:
|
|
|
1211
1272
|
) -> CostResult:
|
|
1212
1273
|
provider_key = str(provider or "").strip().lower()
|
|
1213
1274
|
provider_key = _PROVIDER_ALIASES.get(provider_key, provider_key)
|
|
1275
|
+
# No recorded provider is as much as an unknown one: such a call
|
|
1276
|
+
# resolves only through the aliases listed for provider "unknown".
|
|
1277
|
+
provider_key = provider_key or _UNKNOWN_PROVIDER_KEY
|
|
1214
1278
|
model_key = str(model or "").strip().lower()
|
|
1215
1279
|
when = _coerce_datetime(at)
|
|
1216
1280
|
candidates = self._aliases.get((provider_key, model_key), ())
|
|
@@ -1244,10 +1308,15 @@ class CatalogSnapshot:
|
|
|
1244
1308
|
None,
|
|
1245
1309
|
"unpriced",
|
|
1246
1310
|
("no_effective_price",),
|
|
1311
|
+
model_class=alias.model_class,
|
|
1247
1312
|
)
|
|
1248
1313
|
return _cost_result(
|
|
1249
1314
|
ResolvedPrice(
|
|
1250
|
-
alias.canonical_id,
|
|
1315
|
+
alias.canonical_id,
|
|
1316
|
+
price,
|
|
1317
|
+
{**price.rules, **alias.rules},
|
|
1318
|
+
ended=ended,
|
|
1319
|
+
model_class=alias.model_class,
|
|
1251
1320
|
),
|
|
1252
1321
|
at=when,
|
|
1253
1322
|
usage=ModelUsage(
|
|
@@ -6,7 +6,7 @@
|
|
|
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-22"
|
|
9
|
+
version: "2026-11-22.1"
|
|
10
10
|
currency: USD
|
|
11
11
|
pricing_verified_at: "2026-11-22"
|
|
12
12
|
models:
|
|
@@ -4058,19 +4058,127 @@ models:
|
|
|
4058
4058
|
|
|
4059
4059
|
- canonical_id: typesafe-ai/jev-1.13.0
|
|
4060
4060
|
publisher: typesafe-ai
|
|
4061
|
+
family: {id: typesafe-ai/jev, display_name: Jev}
|
|
4062
|
+
model_class: decision
|
|
4063
|
+
# A decision model: billed per input token, output is free. Its calls
|
|
4064
|
+
# usually report no output usage, which a zero output rate does not need.
|
|
4061
4065
|
aliases:
|
|
4062
4066
|
- {provider: typesafe-ai, alias: typesafe-ai/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4063
4067
|
- {provider: vercel, alias: typesafe-ai/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4064
4068
|
- {provider: unknown, alias: typesafe/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4065
4069
|
- {provider: unknown, alias: jev-1.13.0, channel: vercel-ai-gateway}
|
|
4070
|
+
- {provider: vercel, alias: typesafe/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4071
|
+
- {provider: vercel, alias: jev-1.13.0, channel: vercel-ai-gateway}
|
|
4072
|
+
- {provider: gateway, alias: typesafe-ai/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4073
|
+
- {provider: gateway, alias: typesafe/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4074
|
+
- {provider: gateway, alias: jev-1.13.0, channel: vercel-ai-gateway}
|
|
4075
|
+
- {provider: typesafe, alias: jev-1.13.0, channel: typesafe-api}
|
|
4076
|
+
- {provider: typesafe, alias: typesafe/jev-1.13.0, channel: typesafe-api}
|
|
4077
|
+
- {provider: typesafe, alias: typesafe-ai/jev-1.13.0, channel: typesafe-api}
|
|
4078
|
+
- {provider: typesafe-ai, alias: jev-1.13.0, channel: typesafe-api}
|
|
4079
|
+
- {provider: typesafe-ai, alias: typesafe/jev-1.13.0, channel: typesafe-api}
|
|
4080
|
+
- {provider: unknown, alias: typesafe-ai/jev-1.13.0, channel: vercel-ai-gateway}
|
|
4066
4081
|
prices:
|
|
4067
4082
|
# Vercel lists an input rate and no output fee for this decision model.
|
|
4068
4083
|
- channel: vercel-ai-gateway
|
|
4069
4084
|
region: global
|
|
4070
4085
|
effective_from: "2026-09-15"
|
|
4086
|
+
effective_to: "2026-11-21"
|
|
4071
4087
|
input_per_mtok: 0.04
|
|
4072
4088
|
output_per_mtok: 0
|
|
4073
4089
|
source_url: https://vercel.com/ai-gateway/models/jev-1.13.0
|
|
4090
|
+
- channel: vercel-ai-gateway
|
|
4091
|
+
region: global
|
|
4092
|
+
effective_from: "2026-11-21"
|
|
4093
|
+
input_per_mtok: 0.042
|
|
4094
|
+
output_per_mtok: 0
|
|
4095
|
+
source_url: https://vercel.com/ai-gateway/models/typesafe-ai/jev
|
|
4096
|
+
- channel: typesafe-api
|
|
4097
|
+
region: global
|
|
4098
|
+
effective_from: "2026-11-21"
|
|
4099
|
+
input_per_mtok: 0.042
|
|
4100
|
+
output_per_mtok: 0
|
|
4101
|
+
source_url: https://docs.typesafe.ai/models
|
|
4102
|
+
|
|
4103
|
+
- canonical_id: typesafe-ai/jev-1.14.0
|
|
4104
|
+
publisher: typesafe-ai
|
|
4105
|
+
family: {id: typesafe-ai/jev, display_name: Jev}
|
|
4106
|
+
model_class: decision
|
|
4107
|
+
aliases:
|
|
4108
|
+
- {provider: vercel, alias: typesafe-ai/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4109
|
+
- {provider: vercel, alias: typesafe/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4110
|
+
- {provider: vercel, alias: jev-1.14.0, channel: vercel-ai-gateway}
|
|
4111
|
+
- {provider: gateway, alias: typesafe-ai/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4112
|
+
- {provider: gateway, alias: typesafe/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4113
|
+
- {provider: gateway, alias: jev-1.14.0, channel: vercel-ai-gateway}
|
|
4114
|
+
- {provider: typesafe, alias: jev-1.14.0, channel: typesafe-api}
|
|
4115
|
+
- {provider: typesafe, alias: typesafe/jev-1.14.0, channel: typesafe-api}
|
|
4116
|
+
- {provider: typesafe, alias: typesafe-ai/jev-1.14.0, channel: typesafe-api}
|
|
4117
|
+
- {provider: typesafe-ai, alias: typesafe-ai/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4118
|
+
- {provider: typesafe-ai, alias: jev-1.14.0, channel: typesafe-api}
|
|
4119
|
+
- {provider: typesafe-ai, alias: typesafe/jev-1.14.0, channel: typesafe-api}
|
|
4120
|
+
- {provider: unknown, alias: typesafe-ai/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4121
|
+
- {provider: unknown, alias: typesafe/jev-1.14.0, channel: vercel-ai-gateway}
|
|
4122
|
+
- {provider: unknown, alias: jev-1.14.0, channel: vercel-ai-gateway}
|
|
4123
|
+
prices:
|
|
4124
|
+
- channel: vercel-ai-gateway
|
|
4125
|
+
region: global
|
|
4126
|
+
effective_from: "2026-11-21"
|
|
4127
|
+
input_per_mtok: 0.042
|
|
4128
|
+
output_per_mtok: 0
|
|
4129
|
+
source_url: https://vercel.com/ai-gateway/models/typesafe-ai/jev
|
|
4130
|
+
- channel: typesafe-api
|
|
4131
|
+
region: global
|
|
4132
|
+
effective_from: "2026-11-21"
|
|
4133
|
+
input_per_mtok: 0.042
|
|
4134
|
+
output_per_mtok: 0
|
|
4135
|
+
source_url: https://docs.typesafe.ai/models
|
|
4136
|
+
|
|
4137
|
+
- canonical_id: typesafe-ai/jev
|
|
4138
|
+
publisher: typesafe-ai
|
|
4139
|
+
family: {id: typesafe-ai/jev, display_name: Jev}
|
|
4140
|
+
model_class: decision
|
|
4141
|
+
# The version-neutral ids: the gateway's typesafe-ai/jev, and the
|
|
4142
|
+
# direct API's moving aliases. Every version is listed at one price.
|
|
4143
|
+
aliases:
|
|
4144
|
+
- {provider: vercel, alias: typesafe-ai/jev, channel: vercel-ai-gateway}
|
|
4145
|
+
- {provider: vercel, alias: typesafe/jev, channel: vercel-ai-gateway}
|
|
4146
|
+
- {provider: vercel, alias: jev, channel: vercel-ai-gateway}
|
|
4147
|
+
- {provider: vercel, alias: jev-latest, channel: vercel-ai-gateway}
|
|
4148
|
+
- {provider: vercel, alias: jev-preview, channel: vercel-ai-gateway}
|
|
4149
|
+
- {provider: gateway, alias: typesafe-ai/jev, channel: vercel-ai-gateway}
|
|
4150
|
+
- {provider: gateway, alias: typesafe/jev, channel: vercel-ai-gateway}
|
|
4151
|
+
- {provider: gateway, alias: jev, channel: vercel-ai-gateway}
|
|
4152
|
+
- {provider: gateway, alias: jev-latest, channel: vercel-ai-gateway}
|
|
4153
|
+
- {provider: gateway, alias: jev-preview, channel: vercel-ai-gateway}
|
|
4154
|
+
- {provider: typesafe, alias: jev, channel: typesafe-api}
|
|
4155
|
+
- {provider: typesafe, alias: jev-latest, channel: typesafe-api}
|
|
4156
|
+
- {provider: typesafe, alias: jev-preview, channel: typesafe-api}
|
|
4157
|
+
- {provider: typesafe, alias: typesafe/jev, channel: typesafe-api}
|
|
4158
|
+
- {provider: typesafe, alias: typesafe-ai/jev, channel: typesafe-api}
|
|
4159
|
+
- {provider: typesafe-ai, alias: typesafe-ai/jev, channel: vercel-ai-gateway}
|
|
4160
|
+
- {provider: typesafe-ai, alias: jev, channel: typesafe-api}
|
|
4161
|
+
- {provider: typesafe-ai, alias: jev-latest, channel: typesafe-api}
|
|
4162
|
+
- {provider: typesafe-ai, alias: jev-preview, channel: typesafe-api}
|
|
4163
|
+
- {provider: typesafe-ai, alias: typesafe/jev, channel: typesafe-api}
|
|
4164
|
+
- {provider: unknown, alias: typesafe-ai/jev, channel: vercel-ai-gateway}
|
|
4165
|
+
- {provider: unknown, alias: typesafe/jev, channel: vercel-ai-gateway}
|
|
4166
|
+
- {provider: unknown, alias: jev, channel: vercel-ai-gateway}
|
|
4167
|
+
- {provider: unknown, alias: jev-latest, channel: vercel-ai-gateway}
|
|
4168
|
+
- {provider: unknown, alias: jev-preview, channel: vercel-ai-gateway}
|
|
4169
|
+
prices:
|
|
4170
|
+
- channel: vercel-ai-gateway
|
|
4171
|
+
region: global
|
|
4172
|
+
effective_from: "2026-11-21"
|
|
4173
|
+
input_per_mtok: 0.042
|
|
4174
|
+
output_per_mtok: 0
|
|
4175
|
+
source_url: https://vercel.com/ai-gateway/models/typesafe-ai/jev
|
|
4176
|
+
- channel: typesafe-api
|
|
4177
|
+
region: global
|
|
4178
|
+
effective_from: "2026-11-21"
|
|
4179
|
+
input_per_mtok: 0.042
|
|
4180
|
+
output_per_mtok: 0
|
|
4181
|
+
source_url: https://docs.typesafe.ai/models
|
|
4074
4182
|
|
|
4075
4183
|
- canonical_id: thinkingmachines/inkling
|
|
4076
4184
|
publisher: thinkingmachines
|
|
@@ -14,6 +14,8 @@ from typing import Any, Mapping
|
|
|
14
14
|
import yaml
|
|
15
15
|
|
|
16
16
|
from .catalog import (
|
|
17
|
+
DEFAULT_MODEL_CLASS,
|
|
18
|
+
MODEL_CLASSES,
|
|
17
19
|
Alias,
|
|
18
20
|
PRICE_ENDED,
|
|
19
21
|
CatalogSnapshot,
|
|
@@ -48,6 +50,28 @@ def _freeze(value: Any) -> Any:
|
|
|
48
50
|
return value
|
|
49
51
|
|
|
50
52
|
|
|
53
|
+
def _model_class(entry: Mapping[str, Any], canonical: str) -> str:
|
|
54
|
+
"""An entry's ``model_class``: one of MODEL_CLASSES, ``generative`` when
|
|
55
|
+
absent. Any other value is refused rather than read as a default."""
|
|
56
|
+
if "model_class" not in entry:
|
|
57
|
+
return DEFAULT_MODEL_CLASS
|
|
58
|
+
value = entry["model_class"]
|
|
59
|
+
if not isinstance(value, str) or value not in MODEL_CLASSES:
|
|
60
|
+
raise CatalogError(
|
|
61
|
+
f"{canonical}: model_class must be one of {', '.join(MODEL_CLASSES)}, not {value!r}"
|
|
62
|
+
)
|
|
63
|
+
return value
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def parse_model_classes(document: Mapping[str, Any]) -> dict[str, str]:
|
|
67
|
+
"""Each model's class by canonical id, defaulted as :func:`_model_class`."""
|
|
68
|
+
return {
|
|
69
|
+
str(entry.get("canonical_id")): _model_class(entry, str(entry.get("canonical_id")))
|
|
70
|
+
for entry in document.get("models") or []
|
|
71
|
+
if entry.get("canonical_id")
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
51
75
|
def _canonical_index(document: dict[str, Any]) -> dict[tuple[str, str], str]:
|
|
52
76
|
"""Map every ``(provider, name)`` -- for each declared alias and, under the
|
|
53
77
|
providers that publish it, the canonical id itself -- to its canonical id,
|
|
@@ -93,6 +117,19 @@ class LoadedCatalog:
|
|
|
93
117
|
families: Mapping[str, ModelFamily] = field(
|
|
94
118
|
default_factory=lambda: MappingProxyType({})
|
|
95
119
|
)
|
|
120
|
+
# Each model's class by canonical id; see MODEL_CLASSES.
|
|
121
|
+
model_classes: Mapping[str, str] = field(
|
|
122
|
+
default_factory=lambda: MappingProxyType({})
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def model_class(self, canonical_id: Any) -> str | None:
|
|
126
|
+
"""The class the catalog declares for ``canonical_id``
|
|
127
|
+
(``generative`` when the entry states none), or None when no entry
|
|
128
|
+
has that canonical id. Aliases are not canonical ids: a priced
|
|
129
|
+
call's class is on its result, ``CostResult.model_class``."""
|
|
130
|
+
if not isinstance(canonical_id, str):
|
|
131
|
+
return None
|
|
132
|
+
return self.model_classes.get(canonical_id)
|
|
96
133
|
|
|
97
134
|
def model_family(self, canonical_id: Any) -> ModelFamily | None:
|
|
98
135
|
"""The product line the catalog declares for ``canonical_id``, or
|
|
@@ -188,7 +225,8 @@ class LoadedCatalog:
|
|
|
188
225
|
"""The price a call to ``model`` at ``at`` is billed at.
|
|
189
226
|
|
|
190
227
|
``channel`` is authoritative; without one, ``provider`` supplies its
|
|
191
|
-
direct channel
|
|
228
|
+
direct channel, and with neither the aliases listed for provider
|
|
229
|
+
``unknown`` do. ``region`` overrides the region the catalog was
|
|
192
230
|
loaded with. A result that depends on a dimension the caller left out
|
|
193
231
|
lists it in ``missing_dimensions``."""
|
|
194
232
|
when = _coerce_datetime(at)
|
|
@@ -353,6 +391,7 @@ def parse_catalog(
|
|
|
353
391
|
raise CatalogError(f"duplicate model entry {canonical!r}")
|
|
354
392
|
seen_models.add(canonical)
|
|
355
393
|
publisher = str(entry.get("publisher") or "").strip().lower() or None
|
|
394
|
+
model_class = _model_class(entry, canonical)
|
|
356
395
|
for alias in entry.get("aliases") or []:
|
|
357
396
|
provider = str(alias.get("provider") or "").lower()
|
|
358
397
|
name = str(alias.get("alias") or "").lower()
|
|
@@ -402,6 +441,7 @@ def parse_catalog(
|
|
|
402
441
|
price_region=_price_region(
|
|
403
442
|
alias.get("price_region"), model=f"{canonical} alias {name}"
|
|
404
443
|
),
|
|
444
|
+
model_class=model_class,
|
|
405
445
|
)
|
|
406
446
|
keys = [(provider, name)]
|
|
407
447
|
for synonym in _PROVIDER_SYNONYMS.get(provider, ()):
|
|
@@ -674,6 +714,7 @@ def _build_loaded_catalog(
|
|
|
674
714
|
retrieval=RetrievalCatalog(parse_retrieval(document)),
|
|
675
715
|
disputes=tuple(parse_disputes(document)),
|
|
676
716
|
families=MappingProxyType(families),
|
|
717
|
+
model_classes=MappingProxyType(parse_model_classes(document)),
|
|
677
718
|
)
|
|
678
719
|
|
|
679
720
|
|
|
@@ -12,7 +12,7 @@ from typing import Any, Iterable, Mapping
|
|
|
12
12
|
|
|
13
13
|
import yaml
|
|
14
14
|
|
|
15
|
-
from .catalog import _iso_text
|
|
15
|
+
from .catalog import DEFAULT_MODEL_CLASS, MODEL_CLASSES, _iso_text
|
|
16
16
|
from .loader import LoadedCatalog
|
|
17
17
|
|
|
18
18
|
|
|
@@ -176,6 +176,8 @@ class ModelDefinition:
|
|
|
176
176
|
training_policy_overrides: Mapping[str, Mapping[str, TrainingPolicy]] = field(
|
|
177
177
|
default_factory=lambda: _NO_POLICIES, hash=False
|
|
178
178
|
)
|
|
179
|
+
# The same closed set as a prices entry's ``model_class``.
|
|
180
|
+
model_class: str = DEFAULT_MODEL_CLASS
|
|
179
181
|
|
|
180
182
|
|
|
181
183
|
@dataclass(frozen=True, slots=True)
|
|
@@ -494,6 +496,12 @@ def parse_model_registry(document: Any) -> ModelRegistry:
|
|
|
494
496
|
f"{canonical_id}: publisher {publisher!r} does not match canonical id"
|
|
495
497
|
)
|
|
496
498
|
released = _optional_date(model.get("released"), f"{canonical_id}: released")
|
|
499
|
+
model_class = model.get("model_class", DEFAULT_MODEL_CLASS)
|
|
500
|
+
if not isinstance(model_class, str) or model_class not in MODEL_CLASSES:
|
|
501
|
+
raise ModelRegistryError(
|
|
502
|
+
f"{canonical_id}: model_class must be one of "
|
|
503
|
+
f"{', '.join(MODEL_CLASSES)}, not {model_class!r}"
|
|
504
|
+
)
|
|
497
505
|
_reject_misspelled_policy_fields(
|
|
498
506
|
model, "training_policy_overrides", canonical_id
|
|
499
507
|
)
|
|
@@ -587,6 +595,7 @@ def parse_model_registry(document: Any) -> ModelRegistry:
|
|
|
587
595
|
routes=tuple(model_routes),
|
|
588
596
|
released=released,
|
|
589
597
|
training_policy_overrides=training_policy_overrides,
|
|
598
|
+
model_class=model_class,
|
|
590
599
|
)
|
|
591
600
|
|
|
592
601
|
execution_profiles: dict[str, tuple[str, ...]] = {}
|
|
@@ -701,6 +710,13 @@ def validate_model_registry(
|
|
|
701
710
|
entry.get("canonical_id"): entry
|
|
702
711
|
for entry in catalog.document.get("models", [])
|
|
703
712
|
}
|
|
713
|
+
for model in registry.models.values():
|
|
714
|
+
declared = catalog.model_class(model.canonical_id)
|
|
715
|
+
if declared is not None and declared != model.model_class:
|
|
716
|
+
raise ModelRegistryError(
|
|
717
|
+
f"{model.canonical_id}: model_class {model.model_class!r} differs "
|
|
718
|
+
f"from the pricing catalog's {declared!r}"
|
|
719
|
+
)
|
|
704
720
|
for route in registry.routes.values():
|
|
705
721
|
catalog_model = catalog_models.get(route.canonical_id)
|
|
706
722
|
if catalog_model is None:
|
|
@@ -214,6 +214,11 @@ def classify_recorded_call(row: Mapping[str, Any]) -> ModelReliability:
|
|
|
214
214
|
if received is True or native.availability == 'available':
|
|
215
215
|
return ModelReliability(native.http_status_code, 'available',
|
|
216
216
|
signal if received is not False else None)
|
|
217
|
+
if (received is None and native.availability is None
|
|
218
|
+
and _succeeded_decision(row, error)):
|
|
219
|
+
# A recorded decision success is response evidence (see below),
|
|
220
|
+
# so the refusal signal it carries is kept.
|
|
221
|
+
return ModelReliability(native.http_status_code, 'available', signal)
|
|
217
222
|
return native
|
|
218
223
|
# Fresh response/finish/error observations are authoritative even if their
|
|
219
224
|
# refusal coverage is unknown. HTTP-only legacy rows retain compatibility.
|
|
@@ -234,4 +239,23 @@ def classify_recorded_call(row: Mapping[str, Any]) -> ModelReliability:
|
|
|
234
239
|
availability = native.availability
|
|
235
240
|
if availability in {'unavailable', 'excluded'}:
|
|
236
241
|
refused = None
|
|
242
|
+
if availability is None and _succeeded_decision(row, error):
|
|
243
|
+
# A decision model answers typed questions and reports no finish
|
|
244
|
+
# reason, so for it a recorded success is the response evidence a
|
|
245
|
+
# generative model's finish reason would be. Refusal stays unknown.
|
|
246
|
+
availability = 'available'
|
|
237
247
|
return ModelReliability(native.http_status_code, availability, refused)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
_SUCCESS_STATUSES = frozenset({'success', 'succeeded', 'ok', 'complete', 'completed'})
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def _succeeded_decision(row: Mapping[str, Any], error: Mapping[str, Any]) -> bool:
|
|
254
|
+
"""Whether ``row`` records a successful call to a decision-class model:
|
|
255
|
+
``model_class`` is ``decision``, ``status`` is a success value, and no
|
|
256
|
+
error flag or error type is recorded."""
|
|
257
|
+
status = row.get('status')
|
|
258
|
+
return (row.get('model_class') == 'decision'
|
|
259
|
+
and isinstance(status, str) and status.strip().lower() in _SUCCESS_STATUSES
|
|
260
|
+
and row.get('error') in (None, False, 0)
|
|
261
|
+
and not error)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metergraph-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
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
5
|
Author: Metergraph
|
|
6
6
|
License-Expression: Apache-2.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metergraph_core-0.8.31 → metergraph_core-0.9.0}/src/metergraph_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|