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 +32 -2
- package/dist/cjs/generated/bundled.js +18734 -0
- package/dist/cjs/generated/bundled.js.map +1 -0
- package/dist/cjs/index.js +307 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/generated/bundled.d.ts +3 -0
- package/dist/esm/generated/bundled.d.ts.map +1 -0
- package/dist/esm/generated/bundled.js +18731 -0
- package/dist/esm/generated/bundled.js.map +1 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +294 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +114 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +29 -4
package/README.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ai-api-pricing
|
|
2
2
|
|
|
3
|
-
|
|
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.
|