@jaypie/llm 1.3.15 → 1.3.17

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/esm/index.js CHANGED
@@ -28,6 +28,11 @@ const EFFORT = {
28
28
  HIGHEST: "highest",
29
29
  };
30
30
  const MODEL = {
31
+ // Amazon (Nova; the only first-class models served over Bedrock. Bedrock also
32
+ // resells other vendors, but those routes are not catalogued — reach them by
33
+ // passing the literal id, which determineModelProvider resolves to bedrock.)
34
+ NOVA_LITE: "us.amazon.nova-2-lite-v1:0",
35
+ NOVA_PRO: "amazon.nova-pro-v1:0",
31
36
  // Anthropic
32
37
  FABLE: "claude-fable-5",
33
38
  OPUS: "claude-opus-4-8",
@@ -38,13 +43,14 @@ const MODEL = {
38
43
  FIREWORKS: {
39
44
  DEEPSEEK: "accounts/fireworks/models/deepseek-v4-pro",
40
45
  GLM: "accounts/fireworks/models/glm-5p2",
46
+ GPT_OSS: "accounts/fireworks/models/gpt-oss-120b",
41
47
  KIMI: "accounts/fireworks/models/kimi-k2p7-code",
42
48
  MINIMAX: "accounts/fireworks/models/minimax-m2p7",
43
49
  QWEN: "accounts/fireworks/models/qwen3p7-plus",
44
50
  },
45
51
  // Google
46
- GEMINI_FLASH: "gemini-3.5-flash",
47
- GEMINI_FLASH_LITE: "gemini-3.1-flash-lite",
52
+ GEMINI_FLASH: "gemini-3.6-flash",
53
+ GEMINI_FLASH_LITE: "gemini-3.5-flash-lite",
48
54
  GEMINI_PRO: "gemini-3.1-pro-preview",
49
55
  // OpenAI
50
56
  SOL: "gpt-5.6-sol",
@@ -65,6 +71,218 @@ const MODEL = {
65
71
  SONNET: "anthropic/claude-sonnet-5",
66
72
  },
67
73
  };
74
+ /**
75
+ * Standard list price per million tokens, keyed by literal model id (verified
76
+ * 2026-07-21). Keys are string literals rather than `MODEL.*` references so a
77
+ * model retired from the catalog keeps its price here: historic ids stay
78
+ * priceable after they leave `MODEL.*`, which is what makes replaying old
79
+ * usage records possible.
80
+ *
81
+ * Caveats the numbers cannot carry:
82
+ * - **Standard rate only.** Introductory, batch, flex, priority, fast-mode, and
83
+ * data-residency rates are excluded. Sonnet 5 is listed at its standard
84
+ * $3/$15, not the introductory rate.
85
+ * - **Cache writes are Anthropic-only.** Bedrock publishes a literal $0 write
86
+ * for Amazon's own models, recorded here as `cachedInputWrite: 0`. Fireworks
87
+ * writes bill at the input rate. OpenAI and xAI discount reads automatically
88
+ * and publish no write premium. Google charges nothing to write an implicit
89
+ * cache; explicit caching bills storage per hour, a unit this table does not
90
+ * carry (and one `@jaypie/llm` does not wire).
91
+ * - **Short-context tier.** Long-prompt surcharges are not modeled: Gemini 3.1
92
+ * Pro doubles above 200K, Grok doubles at 200K, GPT-5.5 is 2x in / 1.5x out
93
+ * above 272K.
94
+ * - **Text rates.** Gemini prices audio input higher than text/image/video.
95
+ * - **Proxy routes are deliberately absent.** `MODEL.OPENROUTER.*`, and any
96
+ * uncatalogued Bedrock id reselling a third-party model, are another vendor's
97
+ * model behind a gateway, priced per route and per region, so no single rate
98
+ * here would be correct. Price those against the backend model, or against
99
+ * the gateway's own published rate. Amazon's own Nova models are first-class,
100
+ * not proxies, and are priced below at the standard US on-demand rate (`us.`
101
+ * geo profile for Nova 2 Lite; the `global.` profile is cheaper and is not
102
+ * modeled).
103
+ *
104
+ * Unlisted ids return `undefined` — callers must handle a miss.
105
+ */
106
+ const COST = {
107
+ // Amazon — AWS Price List API, AmazonBedrock/us-east-1 (published 2026-07-20;
108
+ // us-west-2 identical). https://aws.amazon.com/bedrock/pricing/ renders its
109
+ // tables in JavaScript, so the Price List offer file is the citable source.
110
+ // Nova 2 Lite is quoted at the `us.` geo rate this catalog's id bills against;
111
+ // the `global.` profile is $0.30/$2.50 and is not modeled.
112
+ "amazon.nova-lite-v1:0": {
113
+ cachedInputRead: 0.015,
114
+ cachedInputWrite: 0,
115
+ input: 0.06,
116
+ output: 0.24,
117
+ },
118
+ "amazon.nova-pro-v1:0": {
119
+ cachedInputRead: 0.2,
120
+ cachedInputWrite: 0,
121
+ input: 0.8,
122
+ output: 3.2,
123
+ },
124
+ "us.amazon.nova-2-lite-v1:0": {
125
+ cachedInputRead: 0.0825,
126
+ cachedInputWrite: 0,
127
+ input: 0.33,
128
+ output: 2.75,
129
+ },
130
+ // Anthropic — https://platform.claude.com/docs/en/about-claude/pricing
131
+ "claude-3-5-haiku-20241022": {
132
+ cachedInputRead: 0.08,
133
+ cachedInputWrite: { "1h": 1.6, "5m": 1.0 },
134
+ input: 0.8,
135
+ output: 4.0,
136
+ },
137
+ "claude-fable-5": {
138
+ cachedInputRead: 1.0,
139
+ cachedInputWrite: { "1h": 20.0, "5m": 12.5 },
140
+ input: 10.0,
141
+ output: 50.0,
142
+ },
143
+ "claude-haiku-4-5": {
144
+ cachedInputRead: 0.1,
145
+ cachedInputWrite: { "1h": 2.0, "5m": 1.25 },
146
+ input: 1.0,
147
+ output: 5.0,
148
+ },
149
+ "claude-mythos-5": {
150
+ cachedInputRead: 1.0,
151
+ cachedInputWrite: { "1h": 20.0, "5m": 12.5 },
152
+ input: 10.0,
153
+ output: 50.0,
154
+ },
155
+ "claude-opus-4-1": {
156
+ cachedInputRead: 1.5,
157
+ cachedInputWrite: { "1h": 30.0, "5m": 18.75 },
158
+ input: 15.0,
159
+ output: 75.0,
160
+ },
161
+ "claude-opus-4-5": {
162
+ cachedInputRead: 0.5,
163
+ cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
164
+ input: 5.0,
165
+ output: 25.0,
166
+ },
167
+ "claude-opus-4-6": {
168
+ cachedInputRead: 0.5,
169
+ cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
170
+ input: 5.0,
171
+ output: 25.0,
172
+ },
173
+ "claude-opus-4-7": {
174
+ cachedInputRead: 0.5,
175
+ cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
176
+ input: 5.0,
177
+ output: 25.0,
178
+ },
179
+ "claude-opus-4-8": {
180
+ cachedInputRead: 0.5,
181
+ cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
182
+ input: 5.0,
183
+ output: 25.0,
184
+ },
185
+ "claude-sonnet-4-20250514": {
186
+ cachedInputRead: 0.3,
187
+ cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
188
+ input: 3.0,
189
+ output: 15.0,
190
+ },
191
+ "claude-sonnet-4-5": {
192
+ cachedInputRead: 0.3,
193
+ cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
194
+ input: 3.0,
195
+ output: 15.0,
196
+ },
197
+ "claude-sonnet-4-6": {
198
+ cachedInputRead: 0.3,
199
+ cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
200
+ input: 3.0,
201
+ output: 15.0,
202
+ },
203
+ "claude-sonnet-5": {
204
+ cachedInputRead: 0.3,
205
+ cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
206
+ input: 3.0,
207
+ output: 15.0,
208
+ },
209
+ // Fireworks — https://docs.fireworks.ai/serverless/pricing
210
+ "accounts/fireworks/models/deepseek-v4-pro": {
211
+ cachedInputRead: 0.145,
212
+ input: 1.74,
213
+ output: 3.48,
214
+ },
215
+ "accounts/fireworks/models/glm-5p2": {
216
+ cachedInputRead: 0.14,
217
+ input: 1.4,
218
+ output: 4.4,
219
+ },
220
+ "accounts/fireworks/models/gpt-oss-120b": {
221
+ cachedInputRead: 0.015,
222
+ input: 0.15,
223
+ output: 0.6,
224
+ },
225
+ "accounts/fireworks/models/kimi-k2p7-code": {
226
+ cachedInputRead: 0.19,
227
+ input: 0.95,
228
+ output: 4.0,
229
+ },
230
+ "accounts/fireworks/models/minimax-m2p7": {
231
+ cachedInputRead: 0.06,
232
+ input: 0.3,
233
+ output: 1.2,
234
+ },
235
+ // Retired from MODEL.* on 2026-07-21: its structured output is
236
+ // nondeterministic (clean JSON, prose, or an empty array from the same
237
+ // request). Priced here so historic usage stays replayable.
238
+ "accounts/fireworks/models/nemotron-3-ultra-nvfp4": {
239
+ cachedInputRead: 0.12,
240
+ input: 0.6,
241
+ output: 2.4,
242
+ },
243
+ "accounts/fireworks/models/qwen3p7-plus": {
244
+ cachedInputRead: 0.08,
245
+ input: 0.4,
246
+ output: 1.6,
247
+ },
248
+ // Google — https://ai.google.dev/gemini-api/docs/pricing
249
+ "gemini-2.5-flash": { cachedInputRead: 0.03, input: 0.3, output: 2.5 },
250
+ "gemini-3.1-flash-lite": {
251
+ cachedInputRead: 0.025,
252
+ input: 0.25,
253
+ output: 1.5,
254
+ },
255
+ "gemini-3.1-flash-lite-preview": {
256
+ cachedInputRead: 0.025,
257
+ input: 0.25,
258
+ output: 1.5,
259
+ },
260
+ "gemini-3.1-pro-preview": { cachedInputRead: 0.2, input: 2.0, output: 12.0 },
261
+ "gemini-3.5-flash": { cachedInputRead: 0.15, input: 1.5, output: 9.0 },
262
+ // Flash-Lite 3.5 has no separate cache-read rate on the standard tier
263
+ "gemini-3.5-flash-lite": { input: 0.3, output: 2.5 },
264
+ "gemini-3.6-flash": { cachedInputRead: 0.15, input: 1.5, output: 7.5 },
265
+ // OpenAI — https://developers.openai.com/api/docs/pricing
266
+ "gpt-5.4": { cachedInputRead: 0.25, input: 2.5, output: 15.0 },
267
+ "gpt-5.4-mini": { cachedInputRead: 0.075, input: 0.75, output: 4.5 },
268
+ "gpt-5.4-nano": { cachedInputRead: 0.02, input: 0.2, output: 1.25 },
269
+ "gpt-5.5": { cachedInputRead: 0.5, input: 5.0, output: 30.0 },
270
+ "gpt-5.6-luna": { cachedInputRead: 0.1, input: 1.0, output: 6.0 },
271
+ "gpt-5.6-sol": { cachedInputRead: 0.5, input: 5.0, output: 30.0 },
272
+ "gpt-5.6-terra": { cachedInputRead: 0.25, input: 2.5, output: 15.0 },
273
+ // xAI — https://docs.x.ai/docs/models ("grok-latest" aliases grok-4.3-latest)
274
+ "grok-4-1-fast-non-reasoning": {
275
+ cachedInputRead: 0.05,
276
+ input: 0.2,
277
+ output: 0.5,
278
+ },
279
+ "grok-4-1-fast-reasoning": {
280
+ cachedInputRead: 0.05,
281
+ input: 0.2,
282
+ output: 0.5,
283
+ },
284
+ "grok-latest": { cachedInputRead: 0.2, input: 1.25, output: 2.5 },
285
+ };
68
286
  const GOOGLE_PROVIDER = {
69
287
  // https://ai.google.dev/gemini-api/docs/models
70
288
  DEFAULT: MODEL.GEMINI_FLASH,
@@ -85,24 +303,28 @@ const GOOGLE_PROVIDER = {
85
303
  const PROVIDER = {
86
304
  // https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html
87
305
  BEDROCK: {
88
- // Bedrock has no MODEL.* catalog entry yet; keep the literal default id.
89
306
  // nova-pro is the Amazon-native model that reliably does tools+structured.
90
- DEFAULT: "amazon.nova-pro-v1:0",
91
- /** @deprecated Size tiers are retired in 2.0. Use PROVIDER.BEDROCK.DEFAULT. */
307
+ DEFAULT: MODEL.NOVA_PRO,
308
+ /** @deprecated Size tiers are retired in 2.0. Use PROVIDER.BEDROCK.DEFAULT, or pick a specific model from MODEL.NOVA_*. */
92
309
  MODEL: {
93
- DEFAULT: "amazon.nova-lite-v1:0",
94
- LARGE: "amazon.nova-pro-v1:0",
95
- SMALL: "amazon.nova-lite-v1:0",
96
- TINY: "amazon.nova-micro-v1:0",
310
+ DEFAULT: MODEL.NOVA_LITE,
311
+ LARGE: MODEL.NOVA_PRO,
312
+ SMALL: MODEL.NOVA_LITE,
313
+ TINY: MODEL.NOVA_LITE,
97
314
  },
98
315
  MODEL_MATCH_WORDS: [
316
+ "ai21.",
99
317
  "amazon.nova",
100
318
  "amazon.titan",
101
319
  "anthropic.claude",
102
320
  "cohere.command",
321
+ "deepseek.",
322
+ "google.gemma",
103
323
  "meta.llama",
104
324
  "mistral.mistral",
105
- "ai21.",
325
+ "moonshotai.",
326
+ "openai.gpt-oss",
327
+ "qwen.",
106
328
  ],
107
329
  NAME: "bedrock",
108
330
  REGION: "AWS_REGION",
@@ -270,6 +492,7 @@ const ALL = {
270
492
  var constants = /*#__PURE__*/Object.freeze({
271
493
  __proto__: null,
272
494
  ALL: ALL,
495
+ COST: COST,
273
496
  DEFAULT: DEFAULT,
274
497
  EFFORT: EFFORT,
275
498
  MODEL: MODEL,
@@ -2996,13 +3219,16 @@ function isTemperatureDeprecationError$3(error) {
2996
3219
  const msg = error?.message ?? "";
2997
3220
  return /temperature.*deprecated|deprecated.*temperature/i.test(msg);
2998
3221
  }
3222
+ /** Exported for tests; not part of the package's public surface. */
2999
3223
  function isCachePointUnsupportedError(error) {
3000
3224
  const name = error?.constructor?.name ?? "";
3001
3225
  const msg = error?.message ?? "";
3002
3226
  // A model that cannot cache rejects the cachePoint block with a
3003
- // ValidationException naming caching / cachePoint.
3004
- return (/ValidationException|invalid|not support/i.test(name + " " + msg) &&
3005
- /cachePoint|cache_point|prompt caching|caching/i.test(msg));
3227
+ // ValidationException naming caching / cachePoint. Bedrock words this as
3228
+ // "You invoked an unsupported model or your request did not allow prompt
3229
+ // caching" — "unsupported" is one word, so it must be matched separately
3230
+ // from "not support".
3231
+ return (/ValidationException|invalid|not support|unsupported/i.test(name + " " + msg) && /cachePoint|cache_point|prompt caching|caching/i.test(msg));
3006
3232
  }
3007
3233
  function extractJson(text) {
3008
3234
  // Try direct parse first