@broberg/ai-sdk 0.64.2 → 0.65.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/dist/chunk-D53S242W.js +449 -0
- package/dist/chunk-D53S242W.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/pricing.d.ts +82 -1
- package/dist/pricing.js +5 -1
- package/package.json +1 -1
- package/dist/chunk-JMRWFOAC.js +0 -337
- package/dist/chunk-JMRWFOAC.js.map +0 -1
package/dist/pricing.d.ts
CHANGED
|
@@ -56,9 +56,30 @@ interface BasePrice {
|
|
|
56
56
|
* rows inherit the inventory snapshot's. */
|
|
57
57
|
checkedAt?: string;
|
|
58
58
|
}
|
|
59
|
+
/** F080.1 — what a token-priced model is FOR. "Cheapest from Mistral" means the
|
|
60
|
+
* cheapest CHAT model; without this a moderation endpoint won the question. */
|
|
61
|
+
type PriceKind = "chat" | "embedding" | "moderation" | "ocr" | "transcribe" | "tts" | "image" | "video" | "judge" | "audio";
|
|
62
|
+
/** F080.1 — is the model known to exist upstream, as of the last measurement?
|
|
63
|
+
* `listed`: in the provider's own model list (direct) or in the OpenRouter catalogue
|
|
64
|
+
* snapshot. `gone`: we priced it, but the provider no longer lists it. `unknown`: we
|
|
65
|
+
* never asked that provider — never read it as `listed`. */
|
|
66
|
+
type UpstreamStatus = "listed" | "gone" | "unknown";
|
|
59
67
|
/** A model billed per token. */
|
|
60
68
|
interface TokenModelPrice extends BasePrice {
|
|
61
69
|
unit: "per_1m_tokens";
|
|
70
|
+
/** F080.1 — chat, embedding, moderation … (see {@link PriceKind}). */
|
|
71
|
+
kind: PriceKind;
|
|
72
|
+
/** F080.1 — how WE reach it: our own provider adapter, or OpenRouter. */
|
|
73
|
+
route: "direct" | "openrouter";
|
|
74
|
+
/** F080.1 — the `override` that calls exactly this row. */
|
|
75
|
+
callAs: {
|
|
76
|
+
provider: string;
|
|
77
|
+
model: string;
|
|
78
|
+
};
|
|
79
|
+
/** F080.1 — a deferred-batch price (`…:batch`), not an interactive one. */
|
|
80
|
+
batch: boolean;
|
|
81
|
+
/** F080.1 — see {@link UpstreamStatus}. */
|
|
82
|
+
upstream: UpstreamStatus;
|
|
62
83
|
/** USD per 1M input tokens. */
|
|
63
84
|
inputPer1M: number;
|
|
64
85
|
/** USD per 1M output tokens. */
|
|
@@ -118,6 +139,9 @@ interface PriceFilter {
|
|
|
118
139
|
/** Only $0/$0 models when true; only paid when false. */
|
|
119
140
|
free?: boolean;
|
|
120
141
|
}
|
|
142
|
+
/** F080.1 — classify a model by its id (and, for OpenRouter rows, what it outputs).
|
|
143
|
+
* One place, so "cheapest chat model" and every future filter agree on what chat is. */
|
|
144
|
+
declare function classifyKind(id: string, out?: "text" | "image" | "audio"): PriceKind;
|
|
121
145
|
/** Every non-token price the SDK bills from (F050). Separate from
|
|
122
146
|
* {@link listModelPrices} because the two answer different questions and mixing
|
|
123
147
|
* them silently changed what an existing caller's list meant. */
|
|
@@ -191,5 +215,62 @@ declare function pricingFreshness(nowMs?: number): PricingFreshness;
|
|
|
191
215
|
declare function warnIfPricingStale(nowMs?: number): void;
|
|
192
216
|
/** Test-only: forget that we already warned. */
|
|
193
217
|
declare function resetPricingWarningForTests(): void;
|
|
218
|
+
interface CheapestQuery {
|
|
219
|
+
/** The model maker: "mistral", "openai", "anthropic", "google", "deepseek", … */
|
|
220
|
+
vendor: string;
|
|
221
|
+
/** Default "chat". */
|
|
222
|
+
kind?: PriceKind;
|
|
223
|
+
/** Only rows we reach this way. Default: both. */
|
|
224
|
+
route?: "direct" | "openrouter";
|
|
225
|
+
region?: PriceRegion;
|
|
226
|
+
/** Deferred-batch prices. Default false — they are not interactive prices. */
|
|
227
|
+
includeBatch?: boolean;
|
|
228
|
+
/** Models the provider no longer lists. Default false. */
|
|
229
|
+
includeGone?: boolean;
|
|
230
|
+
/** OpenRouter ":free" promo ids (rate-limited, may vanish). Default false. */
|
|
231
|
+
includeFree?: boolean;
|
|
232
|
+
/** Default 3. */
|
|
233
|
+
limit?: number;
|
|
234
|
+
/** For tests: "now" for the staleness check. */
|
|
235
|
+
nowMs?: number;
|
|
236
|
+
}
|
|
237
|
+
interface CheapestRow {
|
|
238
|
+
model: string;
|
|
239
|
+
/** The `override` that calls exactly this row. */
|
|
240
|
+
callAs: {
|
|
241
|
+
provider: string;
|
|
242
|
+
model: string;
|
|
243
|
+
};
|
|
244
|
+
route: "direct" | "openrouter";
|
|
245
|
+
kind: PriceKind;
|
|
246
|
+
region: PriceRegion;
|
|
247
|
+
inputPer1M: number;
|
|
248
|
+
outputPer1M: number;
|
|
249
|
+
/** (3 × input + output) / 4 — the ranking key, the same 3:1 blend OpenRouter uses. */
|
|
250
|
+
blendedPer1M: number;
|
|
251
|
+
source: "curated" | "inventory";
|
|
252
|
+
checkedAt?: string;
|
|
253
|
+
upstream: UpstreamStatus;
|
|
254
|
+
/** Everything a reader should know before trusting this row. Empty = none. */
|
|
255
|
+
caveats: string[];
|
|
256
|
+
}
|
|
257
|
+
interface CheapestResult {
|
|
258
|
+
vendor: string;
|
|
259
|
+
kind: PriceKind;
|
|
260
|
+
/** Cheapest first. Empty when nothing matched — never a near-miss from another kind. */
|
|
261
|
+
results: CheapestRow[];
|
|
262
|
+
/** How many rows matched before `limit`. */
|
|
263
|
+
matched: number;
|
|
264
|
+
/** The token table is older than the freshness threshold (or has no check date). */
|
|
265
|
+
stale: boolean;
|
|
266
|
+
checkedAt: string;
|
|
267
|
+
/** Query-level reservations (e.g. staleness). */
|
|
268
|
+
caveats: string[];
|
|
269
|
+
}
|
|
270
|
+
/** The cheapest models a vendor offers for one kind of work — with where each price
|
|
271
|
+
* came from, when it was checked, and how to call it. Measured on 22 Oct 2026 that
|
|
272
|
+
* the obvious sort answered "cheapest from Mistral" with a moderation model that no
|
|
273
|
+
* longer exists; this is the answer that does not. */
|
|
274
|
+
declare function cheapestModels(q: CheapestQuery): CheapestResult;
|
|
194
275
|
|
|
195
|
-
export { DEFAULT_CLIP_SEC, MEDIA_PRICING_CHECKED_AT, type MediaPrice, type MediaUnit, type ModelPrice, PRICING_STALE_AFTER_DAYS, type PriceFilter, type PriceRegion, type PricingFreshness, type UnitFreshness, findModelPrices, getMediaPrice, getModelPrice, listMediaPrices, listModelPrices, priceCall, pricingFreshness, pricingGeneratedAt, resetPricingWarningForTests, warnIfPricingStale };
|
|
276
|
+
export { type CheapestQuery, type CheapestResult, type CheapestRow, DEFAULT_CLIP_SEC, MEDIA_PRICING_CHECKED_AT, type MediaPrice, type MediaUnit, type ModelPrice, PRICING_STALE_AFTER_DAYS, type PriceFilter, type PriceKind, type PriceRegion, type PricingFreshness, type UnitFreshness, type UpstreamStatus, cheapestModels, classifyKind, findModelPrices, getMediaPrice, getModelPrice, listMediaPrices, listModelPrices, priceCall, pricingFreshness, pricingGeneratedAt, resetPricingWarningForTests, warnIfPricingStale };
|
package/dist/pricing.js
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
DEFAULT_CLIP_SEC,
|
|
3
3
|
MEDIA_PRICING_CHECKED_AT,
|
|
4
4
|
PRICING_STALE_AFTER_DAYS,
|
|
5
|
+
cheapestModels,
|
|
6
|
+
classifyKind,
|
|
5
7
|
findModelPrices,
|
|
6
8
|
getMediaPrice,
|
|
7
9
|
getModelPrice,
|
|
@@ -12,12 +14,14 @@ import {
|
|
|
12
14
|
pricingGeneratedAt,
|
|
13
15
|
resetPricingWarningForTests,
|
|
14
16
|
warnIfPricingStale
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-D53S242W.js";
|
|
16
18
|
import "./chunk-BWBRED4O.js";
|
|
17
19
|
export {
|
|
18
20
|
DEFAULT_CLIP_SEC,
|
|
19
21
|
MEDIA_PRICING_CHECKED_AT,
|
|
20
22
|
PRICING_STALE_AFTER_DAYS,
|
|
23
|
+
cheapestModels,
|
|
24
|
+
classifyKind,
|
|
21
25
|
findModelPrices,
|
|
22
26
|
getMediaPrice,
|
|
23
27
|
getModelPrice,
|
package/package.json
CHANGED