metergraph-core 0.8.5__tar.gz → 0.8.7__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 (25) hide show
  1. {metergraph_core-0.8.5/src/metergraph_core.egg-info → metergraph_core-0.8.7}/PKG-INFO +4 -3
  2. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/README.md +3 -2
  3. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/pyproject.toml +1 -1
  4. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/calls.py +8 -4
  5. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/catalog.py +12 -3
  6. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/catalog_delta.py +1 -0
  7. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/data/prices.yaml +120 -7
  8. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/loader.py +29 -8
  9. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/models.py +1 -1
  10. {metergraph_core-0.8.5 → metergraph_core-0.8.7/src/metergraph_core.egg-info}/PKG-INFO +4 -3
  11. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/MANIFEST.in +0 -0
  12. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/setup.cfg +0 -0
  13. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/__init__.py +0 -0
  14. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/billing.py +0 -0
  15. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/data/models.yaml +0 -0
  16. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/data/sources.yaml +0 -0
  17. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/extractors.py +0 -0
  18. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/refresh.py +0 -0
  19. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/responses.py +0 -0
  20. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/retrieval.py +0 -0
  21. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core/sources.py +0 -0
  22. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core.egg-info/SOURCES.txt +0 -0
  23. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core.egg-info/dependency_links.txt +0 -0
  24. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/src/metergraph_core.egg-info/requires.txt +0 -0
  25. {metergraph_core-0.8.5 → metergraph_core-0.8.7}/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.8.5
3
+ Version: 0.8.7
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
@@ -186,8 +186,9 @@ standard `cache_read_per_mtok`, as before. A standard call always uses the
186
186
  standard cache-read rate. A row with only a batch cache rate fully prices a
187
187
  cached batch call, while a cached standard call on it is `partial` with
188
188
  `cache_read_rate_unavailable`.
189
- Batch cache writes use `Price.batch_cache_write_5m_per_mtok` when stated;
190
- otherwise they retain the row's standard cache-write rate.
189
+ Batch cache writes use `Price.batch_cache_write_5m_per_mtok` or
190
+ `Price.batch_cache_write_1h_per_mtok` for the matching TTL when stated;
191
+ otherwise each retains the row's standard cache-write rate.
191
192
 
192
193
  A `ModelUsage` count left `None` is unknown, not zero. A missing input or
193
194
  output count keeps the subtotal that is known, marks the result `partial`, and
@@ -156,8 +156,9 @@ standard `cache_read_per_mtok`, as before. A standard call always uses the
156
156
  standard cache-read rate. A row with only a batch cache rate fully prices a
157
157
  cached batch call, while a cached standard call on it is `partial` with
158
158
  `cache_read_rate_unavailable`.
159
- Batch cache writes use `Price.batch_cache_write_5m_per_mtok` when stated;
160
- otherwise they retain the row's standard cache-write rate.
159
+ Batch cache writes use `Price.batch_cache_write_5m_per_mtok` or
160
+ `Price.batch_cache_write_1h_per_mtok` for the matching TTL when stated;
161
+ otherwise each retains the row's standard cache-write rate.
161
162
 
162
163
  A `ModelUsage` count left `None` is unknown, not zero. A missing input or
163
164
  output count keeps the subtotal that is known, marks the result `partial`, and
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "metergraph-core"
3
- version = "0.8.5"
3
+ version = "0.8.7"
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"
@@ -7,7 +7,7 @@ from typing import Any, Mapping, Sequence
7
7
 
8
8
  from .catalog import CostResult, ModelUsage, direct_channel_for_provider, normalize_provider
9
9
  from .loader import LoadedCatalog
10
- from .responses import _as_mapping, _bundled_catalog, cost_from_response, response_format
10
+ from .responses import _as_mapping, _bundled_catalog, _first, cost_from_response, response_format
11
11
 
12
12
  _ZERO = Decimal('0')
13
13
 
@@ -138,7 +138,7 @@ def response_retrieval_usage(response: Any, *, format: str | None = None) -> tup
138
138
  usage = data.get('usage')
139
139
  usage = usage if isinstance(usage, Mapping) else {}
140
140
  server = usage.get('server_tool_use')
141
- if 'server_tool_use' in usage and not isinstance(server, Mapping):
141
+ if server is not None and not isinstance(server, Mapping):
142
142
  return (RetrievalUsage('web_search', None),)
143
143
  server = server or {}
144
144
  found = [RetrievalUsage(op, server[key]) for key, op in (
@@ -157,8 +157,12 @@ def response_retrieval_usage(response: Any, *, format: str | None = None) -> tup
157
157
  candidates = data.get('candidates')
158
158
  if isinstance(candidates, list):
159
159
  for item in candidates:
160
- metadata = item.get('groundingMetadata') if isinstance(item, Mapping) else None
161
- if isinstance(metadata, Mapping) and ('webSearchQueries' in metadata or 'groundingChunks' in metadata):
160
+ metadata = _first(item, 'groundingMetadata', 'grounding_metadata') if isinstance(item, Mapping) else None
161
+ if isinstance(metadata, Mapping) and any(
162
+ _first(metadata, camel, snake) is not None
163
+ for camel, snake in (("webSearchQueries", "web_search_queries"),
164
+ ("groundingChunks", "grounding_chunks"))
165
+ ):
162
166
  # Grounding evidence does not establish billable query count.
163
167
  return (RetrievalUsage('google_search_grounding', None),)
164
168
  if detected == 'openai.responses':
@@ -242,11 +242,16 @@ class Price:
242
242
  batch_cache_read_per_mtok: Decimal | None = None
243
243
  # OpenAI publishes a separate Batch/Flex cache-write rate.
244
244
  batch_cache_write_5m_per_mtok: Decimal | None = None
245
+ batch_cache_write_1h_per_mtok: Decimal | None = None
245
246
 
246
247
  def __post_init__(self) -> None:
247
248
  # The loader checks the rate it reads, but a row built or replaced
248
249
  # directly must not bill a negative or undefined cache component.
249
- for name in ("batch_cache_read_per_mtok", "batch_cache_write_5m_per_mtok"):
250
+ for name in (
251
+ "batch_cache_read_per_mtok",
252
+ "batch_cache_write_5m_per_mtok",
253
+ "batch_cache_write_1h_per_mtok",
254
+ ):
250
255
  rate = getattr(self, name)
251
256
  if rate is not None and not (
252
257
  isinstance(rate, Decimal) and rate.is_finite() and rate >= 0
@@ -411,6 +416,7 @@ def _billed_terms(resolved: ResolvedPrice) -> tuple[Any, ...]:
411
416
  price.batch_output_per_mtok,
412
417
  price.batch_cache_read_per_mtok,
413
418
  price.batch_cache_write_5m_per_mtok,
419
+ price.batch_cache_write_1h_per_mtok,
414
420
  price.request_fee_per_1k_usd,
415
421
  resolved.rules,
416
422
  )
@@ -565,6 +571,7 @@ def _price_tokens(
565
571
  output_rate = price.output_per_mtok
566
572
  cache_read_rate = price.cache_read_per_mtok
567
573
  cache_write_5m_rate = price.cache_write_5m_per_mtok
574
+ cache_write_1h_rate = price.cache_write_1h_per_mtok
568
575
  if batch:
569
576
  if price.batch_input_per_mtok is None or price.batch_output_per_mtok is None:
570
577
  reasons.append("batch_rate_unavailable")
@@ -577,6 +584,8 @@ def _price_tokens(
577
584
  cache_read_rate = price.batch_cache_read_per_mtok
578
585
  if price.batch_cache_write_5m_per_mtok is not None:
579
586
  cache_write_5m_rate = price.batch_cache_write_5m_per_mtok
587
+ if price.batch_cache_write_1h_per_mtok is not None:
588
+ cache_write_1h_rate = price.batch_cache_write_1h_per_mtok
580
589
 
581
590
  input_multiplier = Decimal("1")
582
591
  output_multiplier = Decimal("1")
@@ -633,12 +642,12 @@ def _price_tokens(
633
642
  / _MILLION
634
643
  )
635
644
  if cache_write_1h_count:
636
- if price.cache_write_1h_per_mtok is None:
645
+ if cache_write_1h_rate is None:
637
646
  reasons.append("cache_write_1h_rate_unavailable")
638
647
  else:
639
648
  cache_write_usd += (
640
649
  Decimal(cache_write_1h_count)
641
- * price.cache_write_1h_per_mtok
650
+ * cache_write_1h_rate
642
651
  * input_multiplier
643
652
  / _MILLION
644
653
  )
@@ -55,6 +55,7 @@ RATE_FIELDS = (
55
55
  "batch_output_per_mtok",
56
56
  "batch_cache_read_per_mtok",
57
57
  "batch_cache_write_5m_per_mtok",
58
+ "batch_cache_write_1h_per_mtok",
58
59
  "request_fee_per_1k_usd",
59
60
  )
60
61
  _PRICE_FIELDS = frozenset(
@@ -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-29.2"
9
+ version: "2026-11-02.1"
10
10
  currency: USD
11
- pricing_verified_at: "2026-10-29"
11
+ pricing_verified_at: "2026-11-02"
12
12
  models:
13
13
  - canonical_id: openai/gpt-6-sol
14
14
  publisher: openai
@@ -1623,6 +1623,7 @@ models:
1623
1623
  - channel: anthropic-api
1624
1624
  region: global
1625
1625
  effective_from: "2026-10-07"
1626
+ effective_to: "2026-10-30"
1626
1627
  input_per_mtok: 0.10
1627
1628
  output_per_mtok: 0.50
1628
1629
  cache_read_per_mtok: 0.01
@@ -1633,6 +1634,19 @@ models:
1633
1634
  rules:
1634
1635
  long_context: {threshold: 100000, input_multiplier: 5, output_multiplier: 5, threshold_counts_cached_tokens: true}
1635
1636
  source_url: https://www.anthropic.com/claude-haiku-5-5
1637
+ - channel: anthropic-api
1638
+ region: global
1639
+ effective_from: "2026-10-30"
1640
+ input_per_mtok: 0.10
1641
+ output_per_mtok: 0.50
1642
+ cache_read_per_mtok: 0.01
1643
+ cache_write_5m_per_mtok: 0.125
1644
+ cache_write_1h_per_mtok: 0.20
1645
+ batch_input_per_mtok: 0.05
1646
+ batch_output_per_mtok: 0.25
1647
+ rules:
1648
+ long_context: {threshold: 100000, input_multiplier: 5, output_multiplier: 5, threshold_counts_cached_tokens: true}
1649
+ source_url: https://platform.claude.com/docs/en/about-claude/pricing
1636
1650
  - channel: vercel-ai-gateway
1637
1651
  region: global
1638
1652
  effective_from: "2026-10-07"
@@ -3620,12 +3634,46 @@ models:
3620
3634
  - channel: moonshot-api
3621
3635
  region: global
3622
3636
  effective_from: "2026-10-24"
3637
+ effective_to: "2026-10-30"
3623
3638
  input_per_mtok: 2.00
3624
3639
  output_per_mtok: 10.00
3625
3640
  cache_read_per_mtok: 0.20
3626
3641
  cache_write_5m_per_mtok: 2.00
3627
3642
  rules: {input_includes_cache_read: true, input_includes_cache_write: true}
3628
3643
  source_url: https://platform.kimi.ai/
3644
+ # Batch input/output are 60% of the standard price, the rule the platform
3645
+ # states for this model: https://platform.kimi.ai/docs/pricing/batch
3646
+ - channel: moonshot-api
3647
+ region: global
3648
+ effective_from: "2026-10-30"
3649
+ effective_to: "2026-11-02"
3650
+ input_per_mtok: 2.00
3651
+ output_per_mtok: 10.00
3652
+ cache_read_per_mtok: 0.20
3653
+ cache_write_5m_per_mtok: 2.00
3654
+ batch_input_per_mtok: 1.20
3655
+ batch_output_per_mtok: 6.00
3656
+ batch_cache_read_per_mtok: 0.12
3657
+ batch_cache_write_5m_per_mtok: 1.20
3658
+ rules: {input_includes_cache_read: true, input_includes_cache_write: true}
3659
+ source_url: https://platform.kimi.ai/
3660
+ # Current 1h rates: https://platform.kimi.ai/docs/pricing/chat
3661
+ # Batch 1h rates: https://platform.kimi.ai/docs/pricing/batch
3662
+ - channel: moonshot-api
3663
+ region: global
3664
+ effective_from: "2026-11-02"
3665
+ input_per_mtok: 2.00
3666
+ output_per_mtok: 10.00
3667
+ cache_read_per_mtok: 0.20
3668
+ cache_write_5m_per_mtok: 2.00
3669
+ cache_write_1h_per_mtok: 4.00
3670
+ batch_input_per_mtok: 1.20
3671
+ batch_output_per_mtok: 6.00
3672
+ batch_cache_read_per_mtok: 0.12
3673
+ batch_cache_write_5m_per_mtok: 1.20
3674
+ batch_cache_write_1h_per_mtok: 2.40
3675
+ rules: {input_includes_cache_read: true, input_includes_cache_write: true}
3676
+ source_url: https://platform.kimi.ai/docs/pricing/batch
3629
3677
 
3630
3678
  - canonical_id: moonshotai/kimi-k3.1-pro-highspeed
3631
3679
  publisher: moonshotai
@@ -3698,12 +3746,46 @@ models:
3698
3746
  - channel: moonshot-api
3699
3747
  region: global
3700
3748
  effective_from: "2026-10-29"
3749
+ effective_to: "2026-10-30"
3701
3750
  input_per_mtok: 3.0
3702
3751
  output_per_mtok: 15.0
3703
3752
  cache_read_per_mtok: 0.3
3704
3753
  cache_write_5m_per_mtok: 3.0
3705
3754
  rules: {input_includes_cache_read: true, input_includes_cache_write: true}
3706
3755
  source_url: https://platform.kimi.ai/
3756
+ # Batch input/output are 60% of the standard price, the rule the platform
3757
+ # states for this model: https://platform.kimi.ai/docs/pricing/batch
3758
+ - channel: moonshot-api
3759
+ region: global
3760
+ effective_from: "2026-10-30"
3761
+ effective_to: "2026-11-02"
3762
+ input_per_mtok: 3.0
3763
+ output_per_mtok: 15.0
3764
+ cache_read_per_mtok: 0.3
3765
+ cache_write_5m_per_mtok: 3.0
3766
+ batch_input_per_mtok: 1.80
3767
+ batch_output_per_mtok: 9.00
3768
+ batch_cache_read_per_mtok: 0.18
3769
+ batch_cache_write_5m_per_mtok: 1.80
3770
+ rules: {input_includes_cache_read: true, input_includes_cache_write: true}
3771
+ source_url: https://platform.kimi.ai/
3772
+ # Current 1h rates: https://platform.kimi.ai/docs/pricing/chat
3773
+ # Batch 1h rates: https://platform.kimi.ai/docs/pricing/batch
3774
+ - channel: moonshot-api
3775
+ region: global
3776
+ effective_from: "2026-11-02"
3777
+ input_per_mtok: 3.0
3778
+ output_per_mtok: 15.0
3779
+ cache_read_per_mtok: 0.3
3780
+ cache_write_5m_per_mtok: 3.0
3781
+ cache_write_1h_per_mtok: 6.0
3782
+ batch_input_per_mtok: 1.80
3783
+ batch_output_per_mtok: 9.00
3784
+ batch_cache_read_per_mtok: 0.18
3785
+ batch_cache_write_5m_per_mtok: 1.80
3786
+ batch_cache_write_1h_per_mtok: 3.60
3787
+ rules: {input_includes_cache_read: true, input_includes_cache_write: true}
3788
+ source_url: https://platform.kimi.ai/docs/pricing/batch
3707
3789
  - channel: fireworks-api
3708
3790
  region: global
3709
3791
  effective_from: "2026-07-19"
@@ -4574,10 +4656,6 @@ models:
4574
4656
  cache_read_per_mtok: 0.16
4575
4657
  source_url: https://fireworks.ai/models/fireworks/kimi-k2p6
4576
4658
 
4577
- # Google prices this model's output by modality: $9.00 text, $17.50 video.
4578
- # The catalog carries one output rate per price row, so this records the text
4579
- # rate. A video-heavy caller is therefore under-costed here, which is the
4580
- # known limitation to revisit if that traffic ever becomes material.
4581
4659
  - channel: openrouter-api
4582
4660
  region: global
4583
4661
  effective_from: "2026-10-20"
@@ -4609,7 +4687,9 @@ models:
4609
4687
  - {provider: google, alias: gemini-omni-1.1-flash, channel: google-api}
4610
4688
  - {provider: google, alias: models/gemini-omni-1.1-flash, channel: google-api}
4611
4689
  prices:
4612
- # Uses the video output rate: video is this model's only output modality.
4690
+ # Google lists $9.00 text and $17.50 video output here; $17.50 is the
4691
+ # billed rate, the one its stated 5,792 tokens per second of 720p video
4692
+ # at about $0.10 per second resolves to.
4613
4693
  - channel: google-api
4614
4694
  region: global
4615
4695
  effective_from: "2026-08-27"
@@ -4629,6 +4709,20 @@ models:
4629
4709
  - channel: google-api
4630
4710
  region: global
4631
4711
  effective_from: "2026-10-29"
4712
+ effective_to: "2026-10-30"
4713
+ input_per_mtok: 1.50
4714
+ output_per_mtok: 17.50
4715
+ source_url: https://ai.google.dev/gemini-api/docs/pricing
4716
+ - channel: google-api
4717
+ region: global
4718
+ effective_from: "2026-10-30"
4719
+ effective_to: "2026-10-31"
4720
+ input_per_mtok: 1.5
4721
+ output_per_mtok: 9
4722
+ source_url: https://ai.google.dev/gemini-api/docs/pricing
4723
+ - channel: google-api
4724
+ region: global
4725
+ effective_from: "2026-10-31"
4632
4726
  input_per_mtok: 1.50
4633
4727
  output_per_mtok: 17.50
4634
4728
  source_url: https://ai.google.dev/gemini-api/docs/pricing
@@ -6463,6 +6557,14 @@ models:
6463
6557
  input_includes_cache_write: true
6464
6558
  effective_from: "2026-11-02"
6465
6559
  source_url: https://openrouter.ai/qwen/qwen3-coder-30b-a3b-instruct
6560
+ - provider: openrouter
6561
+ alias: alibaba/qwen3-coder-30b-a3b-instruct
6562
+ channel: openrouter-api
6563
+ effective_from: "2026-11-02"
6564
+ rules:
6565
+ input_includes_cache_read: true
6566
+ input_includes_cache_write: true
6567
+ source_url: https://openrouter.ai/qwen/qwen3-coder-30b-a3b-instruct
6466
6568
  prices:
6467
6569
  - channel: vercel-ai-gateway
6468
6570
  region: global
@@ -12253,11 +12355,22 @@ models:
12253
12355
  - channel: openai-api
12254
12356
  region: global
12255
12357
  effective_from: "2025-06-10"
12358
+ effective_to: "2026-10-29"
12359
+ input_per_mtok: 2
12360
+ output_per_mtok: 8
12361
+ cache_read_per_mtok: 0.50
12362
+ batch_input_per_mtok: 1
12363
+ batch_output_per_mtok: 4
12364
+ source_url: https://developers.openai.com/api/docs/models/o3
12365
+ - channel: openai-api
12366
+ region: global
12367
+ effective_from: "2026-10-29"
12256
12368
  input_per_mtok: 2
12257
12369
  output_per_mtok: 8
12258
12370
  cache_read_per_mtok: 0.50
12259
12371
  batch_input_per_mtok: 1
12260
12372
  batch_output_per_mtok: 4
12373
+ batch_cache_read_per_mtok: 0.25
12261
12374
  source_url: https://developers.openai.com/api/docs/models/o3
12262
12375
  - channel: vercel-ai-gateway
12263
12376
  region: global
@@ -89,16 +89,25 @@ class LoadedCatalog:
89
89
  # Gateways whose amount billing declines per publisher; see Dispute.
90
90
  disputes: tuple[Dispute, ...] = ()
91
91
 
92
- def canonical_model_id(self, provider: str, model_id: str) -> str:
93
- """Resolve a captured provider-native model id to its canonical id,
94
- using the known source ``provider`` to disambiguate names shared across
95
- providers. An unknown provider, unknown id, or non-string input is left
96
- unchanged so none is ever misattributed."""
92
+ def canonical_model_id(self, provider: str, model_id: str, *, at: Any = None) -> str:
93
+ """Resolve a provider's model name, using ``at`` (default now) for migrations.
94
+
95
+ Unknown or ambiguous names are returned unchanged.
96
+ """
97
97
  if not isinstance(model_id, str) or not isinstance(provider, str):
98
98
  return model_id
99
- return self.canonical_ids.get(
100
- (normalize_provider(provider), model_id), model_id
101
- )
99
+ provider = normalize_provider(provider)
100
+ canonical = self.canonical_ids.get((provider, model_id))
101
+ if canonical is not None:
102
+ return canonical
103
+ when = _coerce_datetime(at) if at is not None else datetime.now(timezone.utc)
104
+ matches = {
105
+ alias.canonical_id
106
+ for alias in self.snapshot._aliases.get((provider, model_id.lower()), ())
107
+ if (alias.effective_from is None or alias.effective_from <= when)
108
+ and (alias.effective_to is None or when < alias.effective_to)
109
+ }
110
+ return next(iter(matches)) if len(matches) == 1 else model_id
102
111
 
103
112
  def infer_direct_channel(self, model: Any) -> str | None:
104
113
  """Infer a direct pricing channel only when the catalog is unambiguous."""
@@ -419,6 +428,17 @@ def parse_catalog(
419
428
  f"{canonical}: invalid batch_cache_write_5m_per_mtok "
420
429
  f"{batch_cache_write!r}"
421
430
  )
431
+ batch_cache_write_1h = price.get("batch_cache_write_1h_per_mtok")
432
+ batch_cache_write_1h_per_mtok = _decimal(batch_cache_write_1h)
433
+ if batch_cache_write_1h is not None and (
434
+ batch_cache_write_1h_per_mtok is None
435
+ or not batch_cache_write_1h_per_mtok.is_finite()
436
+ or batch_cache_write_1h_per_mtok < 0
437
+ ):
438
+ raise CatalogError(
439
+ f"{canonical}: invalid batch_cache_write_1h_per_mtok "
440
+ f"{batch_cache_write_1h!r}"
441
+ )
422
442
  prices.append(
423
443
  Price(
424
444
  id=f"{canonical}:{channel}:{region}:{_id_date(effective_from)}",
@@ -445,6 +465,7 @@ def parse_catalog(
445
465
  currency=currency,
446
466
  batch_cache_read_per_mtok=batch_cache_read_per_mtok,
447
467
  batch_cache_write_5m_per_mtok=batch_cache_write_5m_per_mtok,
468
+ batch_cache_write_1h_per_mtok=batch_cache_write_1h_per_mtok,
448
469
  )
449
470
  )
450
471
  return version, {key: tuple(value) for key, value in aliases.items()}, _unique_ids(prices)
@@ -479,7 +479,7 @@ def validate_model_registry(
479
479
  f"{route.id}: model {route.model_id!r} has no pricing channel "
480
480
  f"{route.pricing_channel!r}"
481
481
  )
482
- canonical = catalog.canonical_model_id(route.provider, route.model_id)
482
+ canonical = catalog.canonical_model_id(route.provider, route.model_id, at=validation_time)
483
483
  if canonical == route.model_id:
484
484
  resolved = catalog.snapshot.resolve_price(
485
485
  model=route.model_id,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph-core
3
- Version: 0.8.5
3
+ Version: 0.8.7
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
@@ -186,8 +186,9 @@ standard `cache_read_per_mtok`, as before. A standard call always uses the
186
186
  standard cache-read rate. A row with only a batch cache rate fully prices a
187
187
  cached batch call, while a cached standard call on it is `partial` with
188
188
  `cache_read_rate_unavailable`.
189
- Batch cache writes use `Price.batch_cache_write_5m_per_mtok` when stated;
190
- otherwise they retain the row's standard cache-write rate.
189
+ Batch cache writes use `Price.batch_cache_write_5m_per_mtok` or
190
+ `Price.batch_cache_write_1h_per_mtok` for the matching TTL when stated;
191
+ otherwise each retains the row's standard cache-write rate.
191
192
 
192
193
  A `ModelUsage` count left `None` is unknown, not zero. A missing input or
193
194
  output count keeps the subtotal that is known, marks the result `partial`, and