@bastani/pi-ai 0.9.41-alpha.2 → 0.9.41-alpha.3

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ This package is a Bastani fork of `@earendil-works/pi-ai`. Upstream history at t
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.9.41-alpha.3] - 2026-10-22
8
+
9
+ ### Added
10
+
11
+ - Added `Usage.cost.totalFromProvider`. It is `true` when `cost.total` is the billed cost reported by the provider and `false` when the total is estimated from the model's catalog rates, as `calculateCost()` and the image generators now record. A missing value, as in sessions recorded before this field existed, means `false`.
12
+
7
13
  ## [0.9.41-alpha.2] - 2026-10-22
8
14
 
9
15
  ### Added
package/README.md CHANGED
@@ -236,6 +236,8 @@ for (const block of response.content) {
236
236
  }
237
237
  ```
238
238
 
239
+ `usage.cost.totalFromProvider` is `true` when `usage.cost.total` is the billed cost reported by the provider and `false` when it is estimated from the model's catalog rates. A missing value, as in sessions recorded before this field existed, also means `false`.
240
+
239
241
  Snippets in the rest of this README assume a `models` collection set up like this (with the relevant providers registered).
240
242
 
241
243
  ## Providers and Models
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAiC,MAAM,mBAAmB,CAAC;AAiBlE,OAAO,KAAK,EASX,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAOb,MAAM,aAAa,CAAC;AAwKrB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAmPhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,o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B,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AA4RD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAyZzE,CAAC;AA4BF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAgDlF,CAAC"}
@@ -156,6 +156,7 @@ function applyFastModePricing(usage) {
156
156
  usage.cost.cacheRead *= FAST_MODE_PRICE_MULTIPLIER;
157
157
  usage.cost.cacheWrite *= FAST_MODE_PRICE_MULTIPLIER;
158
158
  usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
159
+ usage.cost.totalFromProvider = false;
159
160
  }
160
161
  /**
161
162
  * Reject a payload hook that rewrote a field the model's fast route owns.
@@ -304,6 +305,7 @@ function addEarlierAttemptCosts(output, model, servingModel, event) {
304
305
  output.usage.cost.cacheRead += attemptUsage.cost.cacheRead;
305
306
  output.usage.cost.cacheWrite += attemptUsage.cost.cacheWrite;
306
307
  output.usage.cost.total += attemptUsage.cost.total;
308
+ output.usage.cost.totalFromProvider = false;
307
309
  }
308
310
  }
309
311
  function getAnthropicCompat(model) {