@broberg/ai-sdk 0.55.3 → 0.56.1

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,213 +1,7 @@
1
- // src/cost/pricing.ts
2
- var V = "2026-06-02";
3
- var MS = "2026-06-04-mistral.ai";
4
- var AN = "2026-10-08-platform.claude.com";
5
- var PRICING = {
6
- // Anthropic (direct API). DEFAULT_TIER_MAP: fast/cheap=haiku, smart/vision=sonnet, powerful=opus.
7
- // $1.00/$5.00 — Anthropic's published Haiku 4.5 rate, confirmed against the
8
- // claude-api skill's model table 2026-09-03. F048: this row said $0.80/$4.00 while
9
- // "openrouter:anthropic/claude-haiku-4.5" said $1.00/$5.00 — the SAME model at two
10
- // prices, and the shorter, likelier id carried the wrong one. A consumer pricing
11
- // 68M haiku tokens (upmetrics' real volume) was told 20% under.
12
- "anthropic:claude-haiku-4-5": {
13
- inputPer1M: 1,
14
- outputPer1M: 5,
15
- cacheReadPer1M: 0.1,
16
- cacheWritePer1M: 1.25,
17
- version: "2026-09-03"
18
- },
19
- "anthropic:claude-sonnet-4-6": {
20
- inputPer1M: 3,
21
- outputPer1M: 15,
22
- cacheReadPer1M: 0.3,
23
- cacheWritePer1M: 3.75,
24
- version: V
25
- },
26
- // $5.00/$25.00 — Anthropic's published Opus 4.8 rate, confirmed against the
27
- // claude-api skill's model table 2026-09-03.
28
- //
29
- // FOUND BY THE CONTRADICTION GUARD ON ITS FIRST RUN, not by a report. This row said
30
- // $15.00/$75.00 while "openrouter:anthropic/claude-opus-4.8" said $5.00/$25.00 —
31
- // THREE TIMES too high, the opposite direction from the haiku error and a larger
32
- // multiple. Nobody had noticed, because both numbers looked like answers.
33
- "anthropic:claude-opus-4-8": {
34
- inputPer1M: 5,
35
- outputPer1M: 25,
36
- cacheReadPer1M: 0.5,
37
- cacheWritePer1M: 6.25,
38
- version: "2026-09-03"
39
- },
40
- // F075 — the rest of what Anthropic's /v1/models lists for our key, read 2026-10-08
41
- // from platform.claude.com/docs/en/about-claude/pricing. Cache-read is NOT 0.1x
42
- // everywhere: Opus/Sonnet 5.5 are 0.05x and Fable 5.1 is 0.025x. cacheWrite is the
43
- // 5-minute rate (the only one the SDK writes).
44
- "anthropic:claude-fable-5-1": { inputPer1M: 10, outputPer1M: 50, cacheReadPer1M: 0.25, cacheWritePer1M: 12.5, version: AN },
45
- "anthropic:claude-fable-5": { inputPer1M: 10, outputPer1M: 50, cacheReadPer1M: 1, cacheWritePer1M: 12.5, version: AN },
46
- "anthropic:claude-opus-5-5": { inputPer1M: 4, outputPer1M: 20, cacheReadPer1M: 0.2, cacheWritePer1M: 5, version: AN },
47
- "anthropic:claude-opus-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },
48
- "anthropic:claude-opus-4-7": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },
49
- "anthropic:claude-opus-4-6": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },
50
- "anthropic:claude-opus-4-5": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },
51
- "anthropic:claude-sonnet-5-5": { inputPer1M: 2, outputPer1M: 10, cacheReadPer1M: 0.1, cacheWritePer1M: 2.5, version: AN },
52
- "anthropic:claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cacheReadPer1M: 0.2, cacheWritePer1M: 2.5, version: AN },
53
- "anthropic:claude-sonnet-4-5": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75, version: AN },
54
- "anthropic:claude-haiku-5-5": {
55
- inputPer1M: 0.1,
56
- outputPer1M: 0.5,
57
- cacheReadPer1M: 0.01,
58
- cacheWritePer1M: 0.125,
59
- version: AN,
60
- longPrompt: { aboveTokens: 1e5, inputPer1M: 0.5, outputPer1M: 2.5, cacheReadPer1M: 0.05, cacheWritePer1M: 0.625 }
61
- },
62
- // OpenAI. embedding default tier = text-embedding-3-small (no output tokens).
63
- // Cached input is 50% of the input rate — $1.25 vs $2.50 (gpt-4o) and $0.075 vs
64
- // $0.15 (gpt-4o-mini), read from developers.openai.com/api/docs/pricing on
65
- // 2026-08-27. NOTE IT IS 50%, NOT the 10% Mistral and Gemini charge: assuming one
66
- // uniform discount across providers would have understated OpenAI's cost by 4x on
67
- // the cached half. Caching is automatic above 1,024 tokens — no key, no opt-in.
68
- // The embedding models list NO cached price (embeddings do not cache), so they
69
- // deliberately get no row here rather than a guessed one.
70
- "openai:text-embedding-3-small": { inputPer1M: 0.02, outputPer1M: 0, version: V },
71
- "openai:text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0, version: V },
72
- "openai:gpt-4o": { inputPer1M: 2.5, cacheReadPer1M: 1.25, outputPer1M: 10, version: "2026-08-27-developers.openai.com" },
73
- "openai:gpt-4o-mini": { inputPer1M: 0.15, cacheReadPer1M: 0.075, outputPer1M: 0.6, version: "2026-08-27-developers.openai.com" },
74
- // Whisper is priced per MINUTE — see MEDIA_PRICING in ./media-pricing.ts. It used to
75
- // sit here as 0/0 "so token-based compute never charges it", and inwardly that worked.
76
- // Outwardly it did not: getModelPrice("whisper-1") answered `{unit:"per_1m_tokens",
77
- // inputPer1M: 0}` — i.e. "this model is free" — because media rows are consulted LAST
78
- // and a token row was already there. The per-minute price was unreachable by its own
79
- // id. computeCost still returns 0 for it (no entry) and transcribe still computes its
80
- // own cost, so nothing about billing changed; only the public answer stopped lying.
81
- // OpenRouter (meta-router — model slugs include the upstream vendor). Slugs use
82
- // dots (claude-sonnet-4.6) to match OpenRouter's live ids; the dashed forms
83
- // never matched a real call. Caught by the F014 catalogue research.
84
- "openrouter:anthropic/claude-sonnet-4.6": { inputPer1M: 3, outputPer1M: 15, version: V },
85
- // OpenRouter ground-truth $1/$5 — a markup over Anthropic-direct's $0.8/$4
86
- // (the `anthropic:` entry above). Was masked while the slug used dashes.
87
- "openrouter:anthropic/claude-haiku-4.5": { inputPer1M: 1, outputPer1M: 5, version: "2026-06-04" },
88
- "openrouter:google/gemini-2.5-flash": { inputPer1M: 0.3, outputPer1M: 2.5, version: V },
89
- // Ground-truth from OpenRouter /api/v1/models, re-read 2026-10-02 (F067.5; was 0.279/1.2).
90
- "openrouter:minimax/minimax-m2.7": {
91
- inputPer1M: 0.21,
92
- outputPer1M: 0.84,
93
- version: "2026-10-02-openrouter-live"
94
- },
95
- // DeepSeek V4 (CN-hosted — NOT GDPR-safe; non-personal-data workloads only).
96
- // On 2026-05-22 DeepSeek made the "75% off" promo the permanent official price.
97
- // V4-Pro $0.435/$0.87 is ~34x cheaper than GPT-5.5 on output; flash is cheaper
98
- // still. Numbers match OpenRouter /api/v1/models 1:1 (no router markup). A strong
99
- // cheap route for fleet background work once `claude -p` is API-billed (15 Jun).
100
- // Re-read from OpenRouter /api/v1/models 2026-10-02 (F067.5). These moved three
101
- // times in a month (Sep 3: pro 1.02, Oct 1: flash 0.042, Oct 2: flash 0.028) — an
102
- // OpenRouter call books usage.cost from the response anyway; this row is the fallback.
103
- "openrouter:deepseek/deepseek-v4-pro": { inputPer1M: 0.2088, outputPer1M: 0.4176, version: "2026-10-02-openrouter-live" },
104
- "openrouter:deepseek/deepseek-v4-flash": { inputPer1M: 0.028, outputPer1M: 0.056, version: "2026-10-02-openrouter-live" },
105
- // DeepSeek DIRECT API (provider "deepseek", F030 non-PII secondary). Rates from
106
- // api-docs.deepseek.com 2026-06-30 ($0.14/$0.28 per 1M; both map to deepseek-v4-flash).
107
- // `deepseek-chat` (non-thinking) + `deepseek-reasoner` (thinking) DEPRECATE 2026-07-24.
108
- // (The bare `deepseek-v4-flash` basename is already priced via the openrouter entry
109
- // above — kept distinct here to avoid a basename collision in the F027 pricing-API.)
110
- // Verify against a real key when it lands.
111
- "deepseek:deepseek-chat": { inputPer1M: 0.14, outputPer1M: 0.28, version: "2026-06-30-deepseek-direct" },
112
- "deepseek:deepseek-reasoner": { inputPer1M: 0.14, outputPer1M: 0.28, version: "2026-06-30-deepseek-direct" },
113
- // F066 — TypeSafe Jev. docs.typesafe.ai/models, read 2026-10-01: "$42 per billion
114
- // tokens (input only)", output free. Priced on the VERSIONED id because the response
115
- // reports the model that actually ran ("jev-1.13.0") even when you ask for
116
- // "jev-latest" — so a future version arrives unpriced and is booked as such, rather
117
- // than inheriting a number nobody checked for it.
118
- "typesafe:jev-1.13.0": { inputPer1M: 0.042, outputPer1M: 0, version: "2026-10-01-typesafe-official" },
119
- // Cached input tokens cost 10% of the input rate — $0.03 vs $0.30 (2.5-flash) and
120
- // $0.01 vs $0.10 (2.5-flash-lite), read from ai.google.dev/gemini-api/docs/pricing
121
- // on 2026-08-27 rather than recalled. NB the storage fee on that page ($1/1M
122
- // tokens/hour) applies to EXPLICIT context caching, where you create a CachedContent
123
- // object with a TTL. We use IMPLICIT caching, which has no storage charge — so this
124
- // table is not silently under-billing.
125
- // Google Gemini (direct). Provider key is "gemini" — matches the adapter's
126
- // usage.provider + the override.provider callers pass. (Image-gen models are
127
- // priced per-image in the adapter, not here.)
128
- "gemini:gemini-2.5-flash": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 2.5, version: "2026-08-27-ai.google.dev" },
129
- // flash-lite is the default `video` tier (F019) — cheap native video understanding.
130
- "gemini:gemini-2.5-flash-lite": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: "2026-08-27-ai.google.dev" },
131
- // Vertex AI (F038) — the EU-resident route to the SAME Gemini models, so Google's
132
- // published Gemini token prices apply. Listed separately because cost lookups key on
133
- // `provider:model`: without these rows an EU vision/video call would silently log
134
- // $0, which is worse than no tracking (a confident wrong number).
135
- "vertex:gemini-2.5-flash": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 2.5, version: "2026-08-27-ai.google.dev" },
136
- "vertex:gemini-2.5-flash-lite": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: "2026-08-27-ai.google.dev" },
137
- // Cached prompt tokens bill at 10% of the input rate (F039, measured 2026-08-27:
138
- // an 8,810-token prefix reported 8,784 cached on the second call WITH a
139
- // prompt_cache_key, and 0 without one at every size up to 57k).
140
- // Mistral (direct, La Plateforme). Official prices from mistral.ai/pricing
141
- // (2026-06-04, per Christian's CD report). EU/Paris-hosted — the designated
142
- // GDPR-safe provider for client/personal-data workloads (see F015). NB:
143
- // medium-3.5 is the premium "Vibe" coding tier ($1.5/$7.5); Large 3 ($0.5/$1.5)
144
- // is the cheaper frontier general-purpose model despite the higher number.
145
- "mistral:mistral-large-latest": { inputPer1M: 0.5, cacheReadPer1M: 0.05, outputPer1M: 1.5, version: MS },
146
- "mistral:mistral-large-2512": { inputPer1M: 0.5, cacheReadPer1M: 0.05, outputPer1M: 1.5, version: MS },
147
- // Large 4 (F074.1), measured 2026-10-08 on docs.mistral.ai/models/mistral-large-4:
148
- // LIST price. The page also shows a 50% "Public Preview" sale ($0.68/$0.07/$2.09)
149
- // with no end date; booking the sale would under-report the day it ends, unseen.
150
- // Cached input shows as "$0.14": that is 10% of $1.36 rounded to cents (the sale's
151
- // "$0.07" is 0.068 the same way), and 10% is the rate measured for Mistral (F039).
152
- "mistral:mistral-large-4": { inputPer1M: 1.36, cacheReadPer1M: 0.136, outputPer1M: 4.18, version: "2026-10-08-docs.mistral.ai" },
153
- "mistral:mistral-large-4-0": { inputPer1M: 1.36, cacheReadPer1M: 0.136, outputPer1M: 4.18, version: "2026-10-08-docs.mistral.ai" },
154
- "mistral:mistral-medium-latest": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: MS },
155
- "mistral:mistral-medium-3.5": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: MS },
156
- // F076.2 — Mistral's model API now lists mistral-medium-3 as an alias of Medium 3.5
157
- // (measured 2026-10-08), so it bills at 3.5's price, not Medium 3's $0.40/$2.00.
158
- "mistral:mistral-medium-3": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
159
- // F076.1 — Small 4 (2603) is $0.15/$0.60, measured 2026-10-08 on
160
- // docs.mistral.ai/models/mistral-small-4-0-26-03 AND OpenRouter's mistral-small-2603.
161
- // This row said $0.10/$0.30 (Small 3's price, carried over when -latest moved to
162
- // 2603), so the fleet's fast/cheap tiers were booked at about half their cost.
163
- "mistral:mistral-small-latest": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: "2026-10-08-docs.mistral.ai" },
164
- "mistral:mistral-small-2603": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: "2026-10-08-docs.mistral.ai" },
165
- "mistral:ministral-3b-latest": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.1, version: MS },
166
- "mistral:ministral-8b-latest": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.15, version: MS },
167
- "mistral:ministral-14b-latest": { inputPer1M: 0.2, cacheReadPer1M: 0.02, outputPer1M: 0.2, version: MS },
168
- // F076.2 — both Magistral aliases now point at the unified models (measured
169
- // 2026-10-08 via /v1/models): magistral-medium-latest → Medium 3.5, magistral-small-
170
- // latest → Small 4. They bill at those models' prices, not the old Magistral rates.
171
- "mistral:magistral-medium-latest": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
172
- "mistral:magistral-small-latest": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: "2026-10-08-docs.mistral.ai" },
173
- // F076.2 — ids Mistral's model API lists for our key that had no row (a call to any
174
- // of them was booked at $0). Prices from docs.mistral.ai, 2026-10-08; cache-read at
175
- // the measured 10% (F039).
176
- "mistral:mistral-vibe-cli-fast": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: "2026-10-08-docs.mistral.ai" },
177
- "mistral:mistral-medium-3-5": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
178
- "mistral:mistral-medium": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
179
- "mistral:mistral-medium-2604": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
180
- "mistral:mistral-vibe-cli-latest": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
181
- "mistral:mistral-vibe-cli-with-tools": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: "2026-10-08-docs.mistral.ai" },
182
- "mistral:ministral-14b-2512": { inputPer1M: 0.2, cacheReadPer1M: 0.02, outputPer1M: 0.2, version: "2026-10-08-docs.mistral.ai" },
183
- "mistral:ministral-8b-2512": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.15, version: "2026-10-08-docs.mistral.ai" },
184
- "mistral:ministral-3b-2512": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.1, version: "2026-10-08-docs.mistral.ai" },
185
- "mistral:voxtral-small-2507": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: "2026-10-08-docs.mistral.ai" },
186
- "mistral:voxtral-small-latest": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: "2026-10-08-docs.mistral.ai" },
187
- "mistral:codestral-2508": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: "2026-10-08-docs.mistral.ai" },
188
- "mistral:mistral-code-latest": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: "2026-10-08-docs.mistral.ai" },
189
- "mistral:mistral-code-fim-latest": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: "2026-10-08-docs.mistral.ai" },
190
- "mistral:devstral-latest": { inputPer1M: 0.4, cacheReadPer1M: 0.04, outputPer1M: 2, version: MS },
191
- "mistral:codestral-latest": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: MS },
192
- "mistral:open-mistral-nemo": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.15, version: MS },
193
- // Moderation (F016.4) — per input token; output 0. (OCR is per-page in the adapter.)
194
- "mistral:mistral-moderation-latest": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0, version: MS },
195
- // Embeddings (F016.5) — per input token.
196
- "mistral:mistral-embed": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0, version: MS },
197
- "mistral:codestral-embed": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0, version: MS },
198
- // F048 — reported by upmetrics as an unknown model (6 calls). Official mistral.ai/pricing.
199
- "mistral:pixtral-large-latest": { inputPer1M: 2, cacheReadPer1M: 0.2, outputPer1M: 6, version: "2026-09-03" }
200
- };
201
- function stripDatedSuffix(model) {
202
- return model.replace(/-\d{8}$/, "");
203
- }
204
- function getPrice(provider, model) {
205
- const exact = PRICING[`${provider}:${model}`];
206
- if (exact) return exact;
207
- const base = stripDatedSuffix(model);
208
- if (base !== model) return PRICING[`${provider}:${base}`];
209
- return void 0;
210
- }
1
+ import {
2
+ PRICING,
3
+ stripDatedSuffix
4
+ } from "./chunk-QVMGFHCF.js";
211
5
 
212
6
  // src/cost/media-pricing.ts
213
7
  var MEDIA_PRICING_CHECKED_AT = "2026-09-05";
@@ -516,8 +310,6 @@ function resetPricingWarningForTests() {
516
310
  }
517
311
 
518
312
  export {
519
- PRICING,
520
- getPrice,
521
313
  MEDIA_PRICING_CHECKED_AT,
522
314
  MEDIA_PRICING,
523
315
  DEFAULT_CLIP_SEC,
@@ -533,4 +325,4 @@ export {
533
325
  warnIfPricingStale,
534
326
  resetPricingWarningForTests
535
327
  };
536
- //# sourceMappingURL=chunk-ILZ33HZO.js.map
328
+ //# sourceMappingURL=chunk-BOZYLPIM.js.map