metergraph-core 0.2.18__tar.gz → 0.2.20__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph-core
3
- Version: 0.2.18
3
+ Version: 0.2.20
4
4
  Summary: Reusable MeterGraph catalog and deterministic billing engine
5
5
  License-Expression: Apache-2.0
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "metergraph-core"
3
- version = "0.2.18"
3
+ version = "0.2.20"
4
4
  description = "Reusable MeterGraph catalog and deterministic billing engine"
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -14,6 +14,8 @@ _PROVIDER_ALIASES = {
14
14
  "aws-bedrock": "bedrock",
15
15
  "gemini": "google",
16
16
  "google-genai": "google",
17
+ "perplexity": "perplexity-ai",
18
+ "xai": "x-ai",
17
19
  }
18
20
 
19
21
  # The direct catalog channel each captured source provider was actually billed
@@ -29,6 +31,9 @@ _DIRECT_CHANNEL_BY_PROVIDER = {
29
31
  "vertex-ai": "google-vertex-ai",
30
32
  "fireworks": "fireworks-api",
31
33
  "bedrock": "aws-bedrock",
34
+ "deepseek": "deepseek-api",
35
+ "perplexity-ai": "perplexity-api",
36
+ "x-ai": "xai-api",
32
37
  }
33
38
 
34
39
 
@@ -137,6 +142,8 @@ def _price_tokens(
137
142
  output_tokens: Any,
138
143
  cache_read_tokens: Any,
139
144
  cache_write_tokens: Any,
145
+ cache_write_5m_tokens: Any,
146
+ cache_write_1h_tokens: Any,
140
147
  batch: bool,
141
148
  ) -> tuple[Decimal, list[str]]:
142
149
  """Cost a token usage against one already-selected price and its merged
@@ -146,7 +153,11 @@ def _price_tokens(
146
153
  input_count = _tokens(input_tokens)
147
154
  output_count = _tokens(output_tokens)
148
155
  cache_read_count = _tokens(cache_read_tokens) or 0
149
- cache_write_count = _tokens(cache_write_tokens) or 0
156
+ cache_write_5m_count = _tokens(cache_write_5m_tokens)
157
+ if cache_write_5m_count is None:
158
+ cache_write_5m_count = _tokens(cache_write_tokens) or 0
159
+ cache_write_1h_count = _tokens(cache_write_1h_tokens) or 0
160
+ cache_write_count = cache_write_5m_count + cache_write_1h_count
150
161
  if input_count is None:
151
162
  reasons.append("missing_input_tokens")
152
163
  input_count = 0
@@ -210,16 +221,26 @@ def _price_tokens(
210
221
  * input_multiplier
211
222
  / _MILLION
212
223
  )
213
- if cache_write_count:
224
+ if cache_write_5m_count:
214
225
  if price.cache_write_5m_per_mtok is None:
215
- reasons.append("cache_write_rate_unavailable")
226
+ reasons.append("cache_write_5m_rate_unavailable")
216
227
  else:
217
228
  cost += (
218
- Decimal(cache_write_count)
229
+ Decimal(cache_write_5m_count)
219
230
  * price.cache_write_5m_per_mtok
220
231
  * input_multiplier
221
232
  / _MILLION
222
233
  )
234
+ if cache_write_1h_count:
235
+ if price.cache_write_1h_per_mtok is None:
236
+ reasons.append("cache_write_1h_rate_unavailable")
237
+ else:
238
+ cost += (
239
+ Decimal(cache_write_1h_count)
240
+ * price.cache_write_1h_per_mtok
241
+ * input_multiplier
242
+ / _MILLION
243
+ )
223
244
  if rules.get("uncaptured_fees"):
224
245
  reasons.append("uncaptured_fees")
225
246
 
@@ -333,6 +354,8 @@ class CatalogSnapshot:
333
354
  output_tokens: Any,
334
355
  cache_read_tokens: Any = None,
335
356
  cache_write_tokens: Any = None,
357
+ cache_write_5m_tokens: Any = None,
358
+ cache_write_1h_tokens: Any = None,
336
359
  batch: bool = False,
337
360
  ) -> CostResult:
338
361
  provider_key = str(provider or "").strip().lower()
@@ -358,6 +381,8 @@ class CatalogSnapshot:
358
381
  output_tokens=output_tokens,
359
382
  cache_read_tokens=cache_read_tokens,
360
383
  cache_write_tokens=cache_write_tokens,
384
+ cache_write_5m_tokens=cache_write_5m_tokens,
385
+ cache_write_1h_tokens=cache_write_1h_tokens,
361
386
  batch=batch,
362
387
  )
363
388
  return CostResult(
@@ -378,6 +403,8 @@ class CatalogSnapshot:
378
403
  output_tokens: Any,
379
404
  cache_read_tokens: Any = None,
380
405
  cache_write_tokens: Any = None,
406
+ cache_write_5m_tokens: Any = None,
407
+ cache_write_1h_tokens: Any = None,
381
408
  batch: bool = False,
382
409
  ) -> CostResult:
383
410
  """Price an observed deployment from the identity a caller already has:
@@ -401,6 +428,8 @@ class CatalogSnapshot:
401
428
  output_tokens=output_tokens,
402
429
  cache_read_tokens=cache_read_tokens,
403
430
  cache_write_tokens=cache_write_tokens,
431
+ cache_write_5m_tokens=cache_write_5m_tokens,
432
+ cache_write_1h_tokens=cache_write_1h_tokens,
404
433
  batch=batch,
405
434
  )
406
435
  return CostResult(
@@ -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-09-07"
9
+ version: "2026-09-11"
10
10
  currency: USD
11
- pricing_verified_at: "2026-09-07"
11
+ pricing_verified_at: "2026-09-11"
12
12
  models:
13
13
  - canonical_id: openai/gpt-5.6-sol
14
14
  publisher: openai
@@ -756,6 +756,18 @@ models:
756
756
  aliases:
757
757
  - {provider: google, alias: gemini-2.5-flash-lite, channel: google-api}
758
758
  - {provider: google, alias: models/gemini-2.5-flash-lite, channel: google-api}
759
+ - {provider: google, alias: gemini-flash-lite-latest, channel: google-api}
760
+ - {provider: google, alias: models/gemini-flash-lite-latest, channel: google-api}
761
+ - {provider: google, alias: google/gemini-flash-lite-latest, channel: google-api}
762
+ - {provider: google, alias: google/models/gemini-flash-lite-latest, channel: google-api}
763
+ - {provider: unknown, alias: gemini-flash-lite-latest, channel: google-api}
764
+ - {provider: unknown, alias: models/gemini-flash-lite-latest, channel: google-api}
765
+ - {provider: unknown, alias: google/gemini-flash-lite-latest, channel: google-api}
766
+ - {provider: unknown, alias: google/models/gemini-flash-lite-latest, channel: google-api}
767
+ - {provider: litellm, alias: gemini-flash-lite-latest, channel: google-api}
768
+ - {provider: litellm, alias: models/gemini-flash-lite-latest, channel: google-api}
769
+ - {provider: litellm, alias: google/gemini-flash-lite-latest, channel: google-api}
770
+ - {provider: litellm, alias: google/models/gemini-flash-lite-latest, channel: google-api}
759
771
  prices:
760
772
  - channel: google-api
761
773
  region: global
@@ -1104,6 +1116,44 @@ models:
1104
1116
  cache_read_per_mtok: 0.075
1105
1117
  source_url: https://ai-gateway.vercel.sh/v1/models
1106
1118
 
1119
+ - canonical_id: google/gemini-3.8-flash
1120
+ publisher: google
1121
+ aliases:
1122
+ - {provider: google, alias: gemini-3.8-flash, channel: google-api}
1123
+ - {provider: google, alias: models/gemini-3.8-flash, channel: google-api}
1124
+ - {provider: google, alias: gemini-flash-latest, channel: google-api}
1125
+ - {provider: google, alias: models/gemini-flash-latest, channel: google-api}
1126
+ - {provider: google, alias: google/gemini-flash-latest, channel: google-api}
1127
+ - {provider: google, alias: google/models/gemini-flash-latest, channel: google-api}
1128
+ - {provider: unknown, alias: gemini-flash-latest, channel: google-api}
1129
+ - {provider: unknown, alias: models/gemini-flash-latest, channel: google-api}
1130
+ - {provider: unknown, alias: google/gemini-flash-latest, channel: google-api}
1131
+ - {provider: unknown, alias: google/models/gemini-flash-latest, channel: google-api}
1132
+ - {provider: litellm, alias: gemini-flash-latest, channel: google-api}
1133
+ - {provider: litellm, alias: models/gemini-flash-latest, channel: google-api}
1134
+ - {provider: litellm, alias: google/gemini-flash-latest, channel: google-api}
1135
+ - {provider: litellm, alias: google/models/gemini-flash-latest, channel: google-api}
1136
+ prices:
1137
+ - channel: google-api
1138
+ region: global
1139
+ effective_from: "2026-09-01"
1140
+ effective_to: "2027-01-01"
1141
+ input_per_mtok: 0.75
1142
+ output_per_mtok: 3.75
1143
+ cache_read_per_mtok: 0.075
1144
+ batch_input_per_mtok: 0.375
1145
+ batch_output_per_mtok: 1.875
1146
+ source_url: https://ai.google.dev/gemini-api/docs/pricing
1147
+ - channel: google-api
1148
+ region: global
1149
+ effective_from: "2027-01-01"
1150
+ input_per_mtok: 1.50
1151
+ output_per_mtok: 7.50
1152
+ cache_read_per_mtok: 0.15
1153
+ batch_input_per_mtok: 0.75
1154
+ batch_output_per_mtok: 3.75
1155
+ source_url: https://ai.google.dev/gemini-api/docs/pricing
1156
+
1107
1157
  - canonical_id: google/gemma-4-31b-it
1108
1158
  publisher: google
1109
1159
  aliases:
@@ -1142,6 +1192,38 @@ models:
1142
1192
  cache_read_per_mtok: 0.04
1143
1193
  source_url: https://ai-gateway.vercel.sh/v1/models
1144
1194
 
1195
+ - canonical_id: deepseek/deepseek-v4.1-flash
1196
+ publisher: deepseek
1197
+ aliases:
1198
+ - provider: deepseek
1199
+ alias: deepseek/deepseek-v4.1-flash
1200
+ channel: vercel-ai-gateway
1201
+ rules: {input_includes_cache_read: true}
1202
+ prices:
1203
+ - channel: vercel-ai-gateway
1204
+ region: global
1205
+ effective_from: "2026-09-08"
1206
+ input_per_mtok: 0.30
1207
+ output_per_mtok: 1.20
1208
+ cache_read_per_mtok: 0.03
1209
+ source_url: https://ai-gateway.vercel.sh/v1/models
1210
+
1211
+ - canonical_id: meta/muse-spark-1.3
1212
+ publisher: meta
1213
+ aliases:
1214
+ - provider: meta
1215
+ alias: meta/muse-spark-1.3
1216
+ channel: vercel-ai-gateway
1217
+ rules: {input_includes_cache_read: true}
1218
+ prices:
1219
+ - channel: vercel-ai-gateway
1220
+ region: global
1221
+ effective_from: "2026-09-11"
1222
+ input_per_mtok: 1.25
1223
+ output_per_mtok: 4.25
1224
+ cache_read_per_mtok: 0.15
1225
+ source_url: https://ai-gateway.vercel.sh/v1/models
1226
+
1145
1227
  - canonical_id: thinkingmachines/inkling
1146
1228
  publisher: thinkingmachines
1147
1229
  aliases:
@@ -1403,9 +1485,17 @@ models:
1403
1485
  - channel: vercel-ai-gateway
1404
1486
  region: global
1405
1487
  effective_from: "2026-08-14"
1488
+ effective_to: "2026-09-11"
1406
1489
  input_per_mtok: 0.70
1407
1490
  output_per_mtok: 2.20
1408
1491
  source_url: https://vercel.com/ai-gateway/models/glm-5.3
1492
+ - channel: vercel-ai-gateway
1493
+ region: global
1494
+ effective_from: "2026-09-11"
1495
+ input_per_mtok: 1.40
1496
+ output_per_mtok: 4.40
1497
+ cache_read_per_mtok: 0.14
1498
+ source_url: https://ai-gateway.vercel.sh/v1/models
1409
1499
  - channel: fireworks-api
1410
1500
  region: global
1411
1501
  effective_from: "2026-08-14"
@@ -1435,9 +1525,18 @@ models:
1435
1525
  - channel: vercel-ai-gateway
1436
1526
  region: global
1437
1527
  effective_from: "2026-08-26"
1528
+ effective_to: "2026-09-11"
1438
1529
  input_per_mtok: 0.07125
1439
1530
  output_per_mtok: 0.2375
1440
1531
  source_url: https://vercel.com/ai-gateway/models/glm-5.3-flash
1532
+ - channel: vercel-ai-gateway
1533
+ region: global
1534
+ effective_from: "2026-09-11"
1535
+ input_per_mtok: 0.15
1536
+ output_per_mtok: 0.50
1537
+ cache_read_per_mtok: 0.03
1538
+ source_url: https://ai-gateway.vercel.sh/v1/models
1539
+
1441
1540
  - channel: fireworks-api
1442
1541
  region: global
1443
1542
  effective_from: "2026-08-26"
@@ -1446,6 +1545,22 @@ models:
1446
1545
  cache_read_per_mtok: 0.03
1447
1546
  source_url: https://fireworks.ai/models/fireworks/glm-5p3-flash
1448
1547
 
1548
+ - canonical_id: zai/glm-5.3-fast
1549
+ publisher: zai
1550
+ aliases:
1551
+ - provider: zai
1552
+ alias: zai/glm-5.3-fast
1553
+ channel: vercel-ai-gateway
1554
+ rules: {input_includes_cache_read: true}
1555
+ prices:
1556
+ - channel: vercel-ai-gateway
1557
+ region: global
1558
+ effective_from: "2026-09-02"
1559
+ input_per_mtok: 2.10
1560
+ output_per_mtok: 6.60
1561
+ cache_read_per_mtok: 0.21
1562
+ source_url: https://ai-gateway.vercel.sh/v1/models
1563
+
1449
1564
  - canonical_id: moonshotai/kimi-k2.6
1450
1565
  publisher: moonshotai
1451
1566
  aliases:
@@ -100,6 +100,8 @@ class LoadedCatalog:
100
100
  output_tokens: Any,
101
101
  cache_read_tokens: Any = None,
102
102
  cache_write_tokens: Any = None,
103
+ cache_write_5m_tokens: Any = None,
104
+ cache_write_1h_tokens: Any = None,
103
105
  batch: bool = False,
104
106
  ) -> CostResult:
105
107
  """Price an observed deployment channel-exactly. See
@@ -112,6 +114,8 @@ class LoadedCatalog:
112
114
  output_tokens=output_tokens,
113
115
  cache_read_tokens=cache_read_tokens,
114
116
  cache_write_tokens=cache_write_tokens,
117
+ cache_write_5m_tokens=cache_write_5m_tokens,
118
+ cache_write_1h_tokens=cache_write_1h_tokens,
115
119
  batch=batch,
116
120
  )
117
121
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph-core
3
- Version: 0.2.18
3
+ Version: 0.2.20
4
4
  Summary: Reusable MeterGraph catalog and deterministic billing engine
5
5
  License-Expression: Apache-2.0
6
6
  Requires-Python: >=3.10