ai-api-pricing 0.0.0-stage → 0.1.0

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/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # ai-api-pricing
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Zero-runtime-dependency TypeScript/JavaScript access to the source-linked [AICostBudget AI API Pricing Dataset](https://aicostbudget.com/en/datasets/ai-api-pricing).
4
+
5
+ ```bash
6
+ npm install ai-api-pricing
7
+ ```
8
+
9
+ ```js
10
+ import { estimateCost } from "ai-api-pricing";
11
+ const estimate = await estimateCost({
12
+ modelId: "gpt-4.1", inputTokens: 1_000_000, outputTokens: 100_000,
13
+ });
14
+ console.log(estimate.total, estimate.officialSourceUrl, estimate.lastVerifiedAt);
15
+ ```
16
+
17
+ The package exports `loadPrices`, `getPrice`, `listModels`, `estimateCost`, and `compareModels`. Live loading uses the GitHub Pages JSON with a 10-second timeout and falls back to the bundled snapshot on any fetch or validation error. Check the returned `source` field to distinguish `live` from `bundled` data. Missing required prices raise a typed `MissingPriceError`; the package never substitutes another rate.
18
+
19
+ ## Refresh the bundled snapshot
20
+
21
+ From the repository root, run:
22
+
23
+ ```bash
24
+ npm run refresh-bundle --workspace ai-api-pricing
25
+ ```
26
+
27
+ The generator reads the checked-in `api/v1/prices.json`, embeds its `generated_at` value, and rewrites `src/generated/bundled.ts`. Review and commit that generated file with the package change.
28
+
29
+ ## Data license and citation
30
+
31
+ Code is MIT-licensed. Pricing data is licensed under [CC BY 4.0](../../LICENSE-DATA). Attribution: **AICostBudget AI API Pricing Dataset**, https://aicostbudget.com/en/datasets/ai-api-pricing, DOI [10.5281/zenodo.23087250](https://doi.org/10.5281/zenodo.23087250).
32
+
33
+ Prices are verified against official provider pages; always confirm before billing decisions.