metergraph-core 0.9.0__tar.gz → 0.9.1__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 (31) hide show
  1. {metergraph_core-0.9.0/src/metergraph_core.egg-info → metergraph_core-0.9.1}/PKG-INFO +1 -1
  2. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/pyproject.toml +1 -1
  3. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/catalog.py +19 -2
  4. {metergraph_core-0.9.0 → metergraph_core-0.9.1/src/metergraph_core.egg-info}/PKG-INFO +1 -1
  5. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/MANIFEST.in +0 -0
  6. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/README.md +0 -0
  7. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/setup.cfg +0 -0
  8. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/__init__.py +0 -0
  9. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/billing.py +0 -0
  10. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/calls.py +0 -0
  11. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/catalog_delta.py +0 -0
  12. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/catalogs.py +0 -0
  13. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/data/models.yaml +0 -0
  14. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/data/prices.yaml +0 -0
  15. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/data/sources.yaml +0 -0
  16. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/extractors.py +0 -0
  17. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/families.py +0 -0
  18. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/loader.py +0 -0
  19. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/models.py +0 -0
  20. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/providers/__init__.py +0 -0
  21. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/providers/anthropic.py +0 -0
  22. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/providers/google.py +0 -0
  23. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/refresh.py +0 -0
  24. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/reliability.py +0 -0
  25. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/responses.py +0 -0
  26. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/retrieval.py +0 -0
  27. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core/sources.py +0 -0
  28. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core.egg-info/SOURCES.txt +0 -0
  29. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core.egg-info/dependency_links.txt +0 -0
  30. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/src/metergraph_core.egg-info/requires.txt +0 -0
  31. {metergraph_core-0.9.0 → metergraph_core-0.9.1}/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.9.0
3
+ Version: 0.9.1
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.9.0"
3
+ version = "0.9.1"
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"
@@ -168,6 +168,20 @@ def counts_cache_read_in_input(
168
168
  return pair in _INPUT_INCLUDES_CACHE_READ_PAIRS
169
169
 
170
170
 
171
+ def counts_cache_write_in_input(
172
+ publisher: Any, channel: Any, rules: Mapping[str, Any]
173
+ ) -> bool:
174
+ """Native OpenAI writes are a subset of input, unless a row overrides it."""
175
+ stated = rules.get("input_includes_cache_write")
176
+ if stated is not None:
177
+ return bool(stated)
178
+ return (
179
+ isinstance(publisher, str) and isinstance(channel, str)
180
+ and publisher.strip().lower() == "openai"
181
+ and channel.strip().lower() == "openai-api"
182
+ )
183
+
184
+
171
185
  def normalize_provider(provider: str) -> str:
172
186
  """Fold a provider spelling through metergraph-core's provider-alias map
173
187
  (e.g. ``aws``/``amazon-bedrock`` -> ``bedrock``, ``google-genai`` ->
@@ -634,7 +648,10 @@ def _price_tokens(
634
648
  deducted_input = input_count
635
649
  else:
636
650
  deducted_input += cache_read_count
637
- if rules.get("input_includes_cache_write"):
651
+ input_includes_cache_write = counts_cache_write_in_input(
652
+ price.publisher, price.pricing_channel, rules
653
+ )
654
+ if input_includes_cache_write:
638
655
  if cache_write_count > input_count - deducted_input:
639
656
  reasons.append("cache_write_exceeds_input")
640
657
  deducted_input = input_count
@@ -715,7 +732,7 @@ def _price_tokens(
715
732
  if long_context.get("threshold_counts_cached_tokens"):
716
733
  if not input_includes_cache_read:
717
734
  prompt_count += cache_read_count
718
- if not rules.get("input_includes_cache_write"):
735
+ if not input_includes_cache_write:
719
736
  prompt_count += cache_write_count
720
737
  # OpenAI Flex shares Batch rates, including its long-context exceptions.
721
738
  applies = not (batch or openai_flex) or long_context.get("applies_to_batch", True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph-core
3
- Version: 0.9.0
3
+ Version: 0.9.1
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