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