metergraph-core 0.5.0__tar.gz → 0.5.2__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.
Files changed (24) hide show
  1. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/PKG-INFO +49 -18
  2. metergraph_core-0.5.0/src/metergraph_core.egg-info/PKG-INFO → metergraph_core-0.5.2/README.md +29 -28
  3. metergraph_core-0.5.2/pyproject.toml +62 -0
  4. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/data/prices.yaml +10 -2
  5. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/extractors.py +23 -6
  6. metergraph_core-0.5.0/README.md → metergraph_core-0.5.2/src/metergraph_core.egg-info/PKG-INFO +59 -16
  7. metergraph_core-0.5.0/pyproject.toml +0 -23
  8. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/MANIFEST.in +0 -0
  9. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/setup.cfg +0 -0
  10. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/__init__.py +0 -0
  11. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/billing.py +0 -0
  12. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/catalog.py +0 -0
  13. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/catalog_delta.py +0 -0
  14. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/data/models.yaml +0 -0
  15. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/data/sources.yaml +0 -0
  16. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/loader.py +0 -0
  17. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/models.py +0 -0
  18. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/refresh.py +0 -0
  19. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/retrieval.py +0 -0
  20. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core/sources.py +0 -0
  21. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core.egg-info/SOURCES.txt +0 -0
  22. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core.egg-info/dependency_links.txt +0 -0
  23. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core.egg-info/requires.txt +0 -0
  24. {metergraph_core-0.5.0 → metergraph_core-0.5.2}/src/metergraph_core.egg-info/top_level.txt +0 -0
@@ -1,8 +1,26 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph-core
3
- Version: 0.5.0
4
- Summary: Reusable MeterGraph catalog and deterministic billing engine
3
+ Version: 0.5.2
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
5
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
6
24
  Requires-Python: >=3.10
7
25
  Description-Content-Type: text/markdown
8
26
  Requires-Dist: pyyaml>=6.0
@@ -12,22 +30,9 @@ Requires-Dist: pytest>=8; extra == "dev"
12
30
 
13
31
  # metergraph-core
14
32
 
15
- Reusable model registry, price catalog, and deterministic billing engine for
16
- MeterGraph.
17
-
18
- `metergraph-core` owns two separate public datasets. `models.yaml` records
19
- canonical model identity, customer-facing names, executable provider routes,
20
- and the ordered candidate fields MeterGraph products offer. `prices.yaml`
21
- records effective-dated rates and billing rules. Core parses and validates both
22
- datasets, resolves provider aliases and routes, calculates deterministic costs,
23
- and selects a qualified gateway-reported charge or catalog estimate as the
24
- effective call cost. A third dataset, `sources.yaml`, registers the official
25
- pricing sources that keep `prices.yaml` current; see
26
- [Source registry](#source-registry).
27
-
28
- It does not own HTTP routes, database access, migrations, authentication,
29
- tenancy, ingest, dashboard code, or any hosted-only concern, and it never reads
30
- server environment variables.
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.
31
36
 
32
37
  ## Install
33
38
 
@@ -53,6 +58,32 @@ result = catalog.snapshot.cost(
53
58
  print(result.canonical_model, result.price_id, result.cost_usd, result.status)
54
59
  ```
55
60
 
61
+ The result names the canonical model and the catalog price row it was billed
62
+ at, so every cost traces back to an effective-dated rate.
63
+
64
+ ## Package scope
65
+
66
+ `metergraph-core` is the reusable model registry, price catalog, and
67
+ deterministic billing engine for
68
+ [Metergraph](https://github.com/metergraph/metergraph), which attributes LLM
69
+ cost to the function, agent, and workflow that made each call.
70
+
71
+ It owns two separate public datasets. `models.yaml` records
72
+ canonical model identity, customer-facing names, executable provider routes,
73
+ and the ordered candidate fields MeterGraph products offer. `prices.yaml`
74
+ records effective-dated rates and billing rules. Core parses and validates both
75
+ datasets, resolves provider aliases and routes, calculates deterministic costs,
76
+ and selects a qualified gateway-reported charge or catalog estimate as the
77
+ effective call cost. A third dataset, `sources.yaml`, registers the official
78
+ pricing sources that keep `prices.yaml` current; see
79
+ [Source registry](#source-registry).
80
+
81
+ It does not own HTTP routes, database access, migrations, authentication,
82
+ tenancy, ingest, dashboard code, or any hosted-only concern, and it never reads
83
+ server environment variables.
84
+
85
+ ## Loading catalogs
86
+
56
87
  `load_catalog()` loads the catalog bundled in the installed package. Pass an
57
88
  explicit `path` for tests or a self-hosted catalog replacement. The returned
58
89
  `LoadedCatalog` exposes the declared catalog `version`, the SHA-256
@@ -1,33 +1,8 @@
1
- Metadata-Version: 2.4
2
- Name: metergraph-core
3
- Version: 0.5.0
4
- Summary: Reusable MeterGraph catalog and deterministic billing engine
5
- License-Expression: Apache-2.0
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
- Requires-Dist: pyyaml>=6.0
9
- Provides-Extra: dev
10
- Requires-Dist: build>=1.2; extra == "dev"
11
- Requires-Dist: pytest>=8; extra == "dev"
12
-
13
1
  # metergraph-core
14
2
 
15
- Reusable model registry, price catalog, and deterministic billing engine for
16
- MeterGraph.
17
-
18
- `metergraph-core` owns two separate public datasets. `models.yaml` records
19
- canonical model identity, customer-facing names, executable provider routes,
20
- and the ordered candidate fields MeterGraph products offer. `prices.yaml`
21
- records effective-dated rates and billing rules. Core parses and validates both
22
- datasets, resolves provider aliases and routes, calculates deterministic costs,
23
- and selects a qualified gateway-reported charge or catalog estimate as the
24
- effective call cost. A third dataset, `sources.yaml`, registers the official
25
- pricing sources that keep `prices.yaml` current; see
26
- [Source registry](#source-registry).
27
-
28
- It does not own HTTP routes, database access, migrations, authentication,
29
- tenancy, ingest, dashboard code, or any hosted-only concern, and it never reads
30
- server environment variables.
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.
31
6
 
32
7
  ## Install
33
8
 
@@ -53,6 +28,32 @@ result = catalog.snapshot.cost(
53
28
  print(result.canonical_model, result.price_id, result.cost_usd, result.status)
54
29
  ```
55
30
 
31
+ The result names the canonical model and the catalog price row it was billed
32
+ at, so every cost traces back to an effective-dated rate.
33
+
34
+ ## Package scope
35
+
36
+ `metergraph-core` is the reusable model registry, price catalog, and
37
+ deterministic billing engine for
38
+ [Metergraph](https://github.com/metergraph/metergraph), which attributes LLM
39
+ cost to the function, agent, and workflow that made each call.
40
+
41
+ It owns two separate public datasets. `models.yaml` records
42
+ canonical model identity, customer-facing names, executable provider routes,
43
+ and the ordered candidate fields MeterGraph products offer. `prices.yaml`
44
+ records effective-dated rates and billing rules. Core parses and validates both
45
+ datasets, resolves provider aliases and routes, calculates deterministic costs,
46
+ and selects a qualified gateway-reported charge or catalog estimate as the
47
+ effective call cost. A third dataset, `sources.yaml`, registers the official
48
+ pricing sources that keep `prices.yaml` current; see
49
+ [Source registry](#source-registry).
50
+
51
+ It does not own HTTP routes, database access, migrations, authentication,
52
+ tenancy, ingest, dashboard code, or any hosted-only concern, and it never reads
53
+ server environment variables.
54
+
55
+ ## Loading catalogs
56
+
56
57
  `load_catalog()` loads the catalog bundled in the installed package. Pass an
57
58
  explicit `path` for tests or a self-hosted catalog replacement. The returned
58
59
  `LoadedCatalog` exposes the declared catalog `version`, the SHA-256
@@ -0,0 +1,62 @@
1
+ [project]
2
+ name = "metergraph-core"
3
+ version = "0.5.2"
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
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ authors = [{ name = "Metergraph" }]
8
+ requires-python = ">=3.10"
9
+ keywords = [
10
+ "llm",
11
+ "pricing",
12
+ "cost",
13
+ "token-pricing",
14
+ "model-catalog",
15
+ "llm-pricing",
16
+ "model-pricing",
17
+ "token-cost",
18
+ "cost-calculation",
19
+ "openai",
20
+ "anthropic",
21
+ "gemini",
22
+ "bedrock",
23
+ "openrouter",
24
+ "vercel-ai-gateway",
25
+ "finops",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 4 - Beta",
29
+ "Intended Audience :: Developers",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3 :: Only",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
38
+ "Topic :: Software Development :: Libraries :: Python Modules",
39
+ ]
40
+ dependencies = [
41
+ "pyyaml>=6.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/metergraph/metergraph"
46
+ Documentation = "https://github.com/metergraph/metergraph/tree/main/core#readme"
47
+ Source = "https://github.com/metergraph/metergraph/tree/main/core"
48
+ Issues = "https://github.com/metergraph/metergraph/issues"
49
+ "Release notes" = "https://github.com/metergraph/metergraph/releases"
50
+
51
+ [project.optional-dependencies]
52
+ dev = ["build>=1.2", "pytest>=8"]
53
+
54
+ [build-system]
55
+ requires = ["setuptools>=68"]
56
+ build-backend = "setuptools.build_meta"
57
+
58
+ [tool.setuptools.packages.find]
59
+ where = ["src"]
60
+
61
+ [tool.setuptools.package-data]
62
+ metergraph_core = ["data/models.yaml", "data/prices.yaml", "data/sources.yaml"]
@@ -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-10-20"
9
+ version: "2026-10-21"
10
10
  currency: USD
11
- pricing_verified_at: "2026-10-20"
11
+ pricing_verified_at: "2026-10-21"
12
12
  models:
13
13
  - canonical_id: openai/gpt-6-sol
14
14
  publisher: openai
@@ -2980,6 +2980,7 @@ models:
2980
2980
  channel: vercel-ai-gateway
2981
2981
  rules:
2982
2982
  input_includes_cache_read: true
2983
+ - {provider: meta, alias: muse-spark-1.3, channel: meta-api, rules: {input_includes_cache_read: true}}
2983
2984
  prices:
2984
2985
  - channel: vercel-ai-gateway
2985
2986
  region: global
@@ -2988,6 +2989,13 @@ models:
2988
2989
  output_per_mtok: 4.25
2989
2990
  cache_read_per_mtok: 0.15
2990
2991
  source_url: https://ai-gateway.vercel.sh/v1/models
2992
+ - channel: meta-api
2993
+ region: global
2994
+ effective_from: "2026-09-11"
2995
+ input_per_mtok: 1.25
2996
+ output_per_mtok: 4.25
2997
+ cache_read_per_mtok: 0.15
2998
+ source_url: https://vercel.com/ai-gateway/models/muse-spark-1.3
2991
2999
 
2992
3000
  - canonical_id: thinkingmachines/inkling
2993
3001
  publisher: thinkingmachines
@@ -192,27 +192,44 @@ def parse_anthropic(html_text: str, *, duplicates: list[str] | None = None) -> T
192
192
 
193
193
 
194
194
  _GOOGLE_LABELS = ("Input price", "Output price", "Context caching price")
195
+ _GOOGLE_ID = re.compile(r"[a-z0-9][a-z0-9.-]*")
196
+
197
+
198
+ def _google_ids(cells: list[str]) -> list[str]:
199
+ """The model ids ending a block's heading: one id, or several joined by
200
+ "and" when a variant shares the model's prices. A lowercase cell not
201
+ joined by "and" is not an id."""
202
+ ids: list[str] = []
203
+ end = len(cells)
204
+ while end and cells[end - 1] != "and" and _GOOGLE_ID.fullmatch(cells[end - 1]):
205
+ ids.insert(0, cells[end - 1])
206
+ if end < 2 or cells[end - 2] != "and":
207
+ break
208
+ end -= 2
209
+ return ids
195
210
 
196
211
 
197
212
  def parse_google(html_text: str, *, duplicates: list[str] | None = None) -> Table:
198
213
  """The Gemini API page: each model's id precedes its "Try it" link, and
199
214
  its paid-tier prices follow. Where a price is dated the first amount is
200
- the one in effect; per-image output is not a token rate."""
215
+ the one in effect; per-image output is not a token rate. A label may name
216
+ the media it covers, as in "Input price (text, image, video)"."""
201
217
  parts = page_text(html_text).split("Try it in Google AI Studio")
202
218
  tier = r"(?:Free of charge \| |Not available \| )?([^|]*\$[^|]*)"
203
219
  table: Table = {}
204
220
  for before, block in zip(parts, parts[1:]):
205
- cells = [c.strip() for c in before.split("|") if c.strip()]
206
- if not cells or not re.fullmatch(r"[a-z0-9][a-z0-9.-]*", cells[-1]):
221
+ ids = _google_ids([c.strip() for c in before.split("|") if c.strip()])
222
+ if not ids:
207
223
  continue
208
- inp = re.search(r"Input price \| " + tier, block)
224
+ inp = re.search(r"Input price[^|]*\| " + tier, block)
209
225
  out = re.search(r"Output price[^|]*\| " + tier, block)
210
226
  if not (inp and out):
211
227
  continue
212
- cache = re.search(r"Context caching price \| " + tier, block)
228
+ cache = re.search(r"Context caching price[^|]*\| " + tier, block)
213
229
  output = None if "per image" in out.group(1) else dollars(out.group(1))
214
230
  rates = {"input": dollars(inp.group(1)), "output": output, "cache_read": dollars(cache.group(1)) if cache else None}
215
- _keep_first(table, cells[-1], {k: v for k, v in rates.items() if v is not None}, duplicates)
231
+ for model_id in ids:
232
+ _keep_first(table, model_id, {k: v for k, v in rates.items() if v is not None}, duplicates)
216
233
  return table
217
234
 
218
235
 
@@ -1,21 +1,38 @@
1
- # metergraph-core
2
-
3
- Reusable model registry, price catalog, and deterministic billing engine for
4
- MeterGraph.
1
+ Metadata-Version: 2.4
2
+ Name: metergraph-core
3
+ Version: 0.5.2
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"
5
30
 
6
- `metergraph-core` owns two separate public datasets. `models.yaml` records
7
- canonical model identity, customer-facing names, executable provider routes,
8
- and the ordered candidate fields MeterGraph products offer. `prices.yaml`
9
- records effective-dated rates and billing rules. Core parses and validates both
10
- datasets, resolves provider aliases and routes, calculates deterministic costs,
11
- and selects a qualified gateway-reported charge or catalog estimate as the
12
- effective call cost. A third dataset, `sources.yaml`, registers the official
13
- pricing sources that keep `prices.yaml` current; see
14
- [Source registry](#source-registry).
31
+ # metergraph-core
15
32
 
16
- It does not own HTTP routes, database access, migrations, authentication,
17
- tenancy, ingest, dashboard code, or any hosted-only concern, and it never reads
18
- server environment variables.
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.
19
36
 
20
37
  ## Install
21
38
 
@@ -41,6 +58,32 @@ result = catalog.snapshot.cost(
41
58
  print(result.canonical_model, result.price_id, result.cost_usd, result.status)
42
59
  ```
43
60
 
61
+ The result names the canonical model and the catalog price row it was billed
62
+ at, so every cost traces back to an effective-dated rate.
63
+
64
+ ## Package scope
65
+
66
+ `metergraph-core` is the reusable model registry, price catalog, and
67
+ deterministic billing engine for
68
+ [Metergraph](https://github.com/metergraph/metergraph), which attributes LLM
69
+ cost to the function, agent, and workflow that made each call.
70
+
71
+ It owns two separate public datasets. `models.yaml` records
72
+ canonical model identity, customer-facing names, executable provider routes,
73
+ and the ordered candidate fields MeterGraph products offer. `prices.yaml`
74
+ records effective-dated rates and billing rules. Core parses and validates both
75
+ datasets, resolves provider aliases and routes, calculates deterministic costs,
76
+ and selects a qualified gateway-reported charge or catalog estimate as the
77
+ effective call cost. A third dataset, `sources.yaml`, registers the official
78
+ pricing sources that keep `prices.yaml` current; see
79
+ [Source registry](#source-registry).
80
+
81
+ It does not own HTTP routes, database access, migrations, authentication,
82
+ tenancy, ingest, dashboard code, or any hosted-only concern, and it never reads
83
+ server environment variables.
84
+
85
+ ## Loading catalogs
86
+
44
87
  `load_catalog()` loads the catalog bundled in the installed package. Pass an
45
88
  explicit `path` for tests or a self-hosted catalog replacement. The returned
46
89
  `LoadedCatalog` exposes the declared catalog `version`, the SHA-256
@@ -1,23 +0,0 @@
1
- [project]
2
- name = "metergraph-core"
3
- version = "0.5.0"
4
- description = "Reusable MeterGraph catalog and deterministic billing engine"
5
- readme = "README.md"
6
- license = "Apache-2.0"
7
- requires-python = ">=3.10"
8
- dependencies = [
9
- "pyyaml>=6.0",
10
- ]
11
-
12
- [project.optional-dependencies]
13
- dev = ["build>=1.2", "pytest>=8"]
14
-
15
- [build-system]
16
- requires = ["setuptools>=68"]
17
- build-backend = "setuptools.build_meta"
18
-
19
- [tool.setuptools.packages.find]
20
- where = ["src"]
21
-
22
- [tool.setuptools.package-data]
23
- metergraph_core = ["data/models.yaml", "data/prices.yaml", "data/sources.yaml"]