@jaypie/llm 1.3.16 → 1.3.18
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/cjs/constants.d.ts +29 -20
- package/dist/cjs/index.cjs +81 -22
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +31 -21
- package/dist/cjs/operate/adapters/BedrockAdapter.d.ts +1 -1
- package/dist/cjs/types/LlmProvider.interface.d.ts +2 -1
- package/dist/cjs/util/cacheControl.d.ts +10 -2
- package/dist/esm/constants.d.ts +29 -20
- package/dist/esm/index.d.ts +31 -21
- package/dist/esm/index.js +81 -22
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/BedrockAdapter.d.ts +1 -1
- package/dist/esm/types/LlmProvider.interface.d.ts +2 -1
- package/dist/esm/util/cacheControl.d.ts +10 -2
- package/package.json +2 -2
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -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;
|
|
@@ -55,10 +58,11 @@ export interface LlmModelCost {
|
|
|
55
58
|
*/
|
|
56
59
|
cachedInputRead?: number;
|
|
57
60
|
/**
|
|
58
|
-
* Cache-write tokens. A scalar when the rate does not vary by TTL
|
|
59
|
-
* the same `"5m"` / `"1h"`
|
|
60
|
-
* calculation reads the TTL
|
|
61
|
-
* means cache writes bill at the
|
|
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.
|
|
62
66
|
*/
|
|
63
67
|
cachedInputWrite?: number | {
|
|
64
68
|
"1h": number;
|
|
@@ -85,34 +89,39 @@ export interface LlmModelCost {
|
|
|
85
89
|
* - **Standard rate only.** Introductory, batch, flex, priority, fast-mode, and
|
|
86
90
|
* data-residency rates are excluded. Sonnet 5 is listed at its standard
|
|
87
91
|
* $3/$15, not the introductory rate.
|
|
88
|
-
* - **Cache writes are Anthropic-only.**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
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).
|
|
93
98
|
* - **Short-context tier.** Long-prompt surcharges are not modeled: Gemini 3.1
|
|
94
99
|
* Pro doubles above 200K, Grok doubles at 200K, GPT-5.5 is 2x in / 1.5x out
|
|
95
100
|
* above 272K.
|
|
96
101
|
* - **Text rates.** Gemini prices audio input higher than text/image/video.
|
|
97
|
-
* - **
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
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).
|
|
101
110
|
*
|
|
102
111
|
* Unlisted ids return `undefined` — callers must handle a miss.
|
|
103
112
|
*/
|
|
104
113
|
export declare const COST: Record<string, LlmModelCost>;
|
|
105
114
|
export declare const PROVIDER: {
|
|
106
115
|
readonly BEDROCK: {
|
|
107
|
-
readonly DEFAULT:
|
|
108
|
-
/** @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_*. */
|
|
109
118
|
readonly MODEL: {
|
|
110
|
-
readonly DEFAULT:
|
|
111
|
-
readonly LARGE:
|
|
112
|
-
readonly SMALL:
|
|
113
|
-
readonly TINY:
|
|
119
|
+
readonly DEFAULT: string;
|
|
120
|
+
readonly LARGE: string;
|
|
121
|
+
readonly SMALL: string;
|
|
122
|
+
readonly TINY: string;
|
|
114
123
|
};
|
|
115
|
-
readonly MODEL_MATCH_WORDS: readonly ["amazon.nova", "amazon.titan", "anthropic.claude", "cohere.command", "meta.llama", "mistral.mistral", "
|
|
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."];
|
|
116
125
|
readonly NAME: "bedrock";
|
|
117
126
|
readonly REGION: "AWS_REGION";
|
|
118
127
|
};
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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,6 +46,7 @@ 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",
|
|
@@ -79,23 +85,51 @@ const MODEL = {
|
|
|
79
85
|
* - **Standard rate only.** Introductory, batch, flex, priority, fast-mode, and
|
|
80
86
|
* data-residency rates are excluded. Sonnet 5 is listed at its standard
|
|
81
87
|
* $3/$15, not the introductory rate.
|
|
82
|
-
* - **Cache writes are Anthropic-only.**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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).
|
|
87
94
|
* - **Short-context tier.** Long-prompt surcharges are not modeled: Gemini 3.1
|
|
88
95
|
* Pro doubles above 200K, Grok doubles at 200K, GPT-5.5 is 2x in / 1.5x out
|
|
89
96
|
* above 272K.
|
|
90
97
|
* - **Text rates.** Gemini prices audio input higher than text/image/video.
|
|
91
|
-
* - **
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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).
|
|
95
106
|
*
|
|
96
107
|
* Unlisted ids return `undefined` — callers must handle a miss.
|
|
97
108
|
*/
|
|
98
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
|
+
},
|
|
99
133
|
// Anthropic — https://platform.claude.com/docs/en/about-claude/pricing
|
|
100
134
|
"claude-3-5-haiku-20241022": {
|
|
101
135
|
cachedInputRead: 0.08,
|
|
@@ -186,6 +220,11 @@ const COST = {
|
|
|
186
220
|
input: 1.4,
|
|
187
221
|
output: 4.4,
|
|
188
222
|
},
|
|
223
|
+
"accounts/fireworks/models/gpt-oss-120b": {
|
|
224
|
+
cachedInputRead: 0.015,
|
|
225
|
+
input: 0.15,
|
|
226
|
+
output: 0.6,
|
|
227
|
+
},
|
|
189
228
|
"accounts/fireworks/models/kimi-k2p7-code": {
|
|
190
229
|
cachedInputRead: 0.19,
|
|
191
230
|
input: 0.95,
|
|
@@ -196,6 +235,14 @@ const COST = {
|
|
|
196
235
|
input: 0.3,
|
|
197
236
|
output: 1.2,
|
|
198
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
|
+
},
|
|
199
246
|
"accounts/fireworks/models/qwen3p7-plus": {
|
|
200
247
|
cachedInputRead: 0.08,
|
|
201
248
|
input: 0.4,
|
|
@@ -259,24 +306,28 @@ const GOOGLE_PROVIDER = {
|
|
|
259
306
|
const PROVIDER = {
|
|
260
307
|
// https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html
|
|
261
308
|
BEDROCK: {
|
|
262
|
-
// Bedrock has no MODEL.* catalog entry yet; keep the literal default id.
|
|
263
309
|
// nova-pro is the Amazon-native model that reliably does tools+structured.
|
|
264
|
-
DEFAULT:
|
|
265
|
-
/** @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_*. */
|
|
266
312
|
MODEL: {
|
|
267
|
-
DEFAULT:
|
|
268
|
-
LARGE:
|
|
269
|
-
SMALL:
|
|
270
|
-
TINY:
|
|
313
|
+
DEFAULT: MODEL.NOVA_LITE,
|
|
314
|
+
LARGE: MODEL.NOVA_PRO,
|
|
315
|
+
SMALL: MODEL.NOVA_LITE,
|
|
316
|
+
TINY: MODEL.NOVA_LITE,
|
|
271
317
|
},
|
|
272
318
|
MODEL_MATCH_WORDS: [
|
|
319
|
+
"ai21.",
|
|
273
320
|
"amazon.nova",
|
|
274
321
|
"amazon.titan",
|
|
275
322
|
"anthropic.claude",
|
|
276
323
|
"cohere.command",
|
|
324
|
+
"deepseek.",
|
|
325
|
+
"google.gemma",
|
|
277
326
|
"meta.llama",
|
|
278
327
|
"mistral.mistral",
|
|
279
|
-
"
|
|
328
|
+
"moonshotai.",
|
|
329
|
+
"openai.gpt-oss",
|
|
330
|
+
"qwen.",
|
|
280
331
|
],
|
|
281
332
|
NAME: "bedrock",
|
|
282
333
|
REGION: "AWS_REGION",
|
|
@@ -743,21 +794,27 @@ function buildExchangeEnvelope({ duration, initialHistoryLength, input, options,
|
|
|
743
794
|
}
|
|
744
795
|
|
|
745
796
|
const CACHE_TTL_DEFAULT = "5m";
|
|
797
|
+
/**
|
|
798
|
+
* Anthropic bills a 1h cache write at 2x input (vs 1.25x for 5m) but reads at
|
|
799
|
+
* the same ~0.1x, so an hour of reuse pays for itself after ~three reads and
|
|
800
|
+
* survives the gaps between turns in a long agentic session.
|
|
801
|
+
*/
|
|
802
|
+
const CACHE_TTL_ANTHROPIC_DEFAULT = "1h";
|
|
746
803
|
/**
|
|
747
804
|
* Normalize the caller-facing `cache` option into a concrete decision.
|
|
748
|
-
* - `undefined` / `true` → enabled at
|
|
805
|
+
* - `undefined` / `true` → enabled at `defaultTtl`
|
|
749
806
|
* - `false` / `0` → disabled
|
|
750
807
|
* - `"5m"` / `"1h"` → enabled at that TTL
|
|
751
808
|
*/
|
|
752
|
-
function resolveCache(cache) {
|
|
809
|
+
function resolveCache(cache, { defaultTtl = CACHE_TTL_DEFAULT } = {}) {
|
|
753
810
|
if (cache === false || cache === 0) {
|
|
754
|
-
return { enabled: false, ttl:
|
|
811
|
+
return { enabled: false, ttl: defaultTtl };
|
|
755
812
|
}
|
|
756
813
|
if (cache === "5m" || cache === "1h") {
|
|
757
814
|
return { enabled: true, ttl: cache };
|
|
758
815
|
}
|
|
759
816
|
// undefined or true
|
|
760
|
-
return { enabled: true, ttl:
|
|
817
|
+
return { enabled: true, ttl: defaultTtl };
|
|
761
818
|
}
|
|
762
819
|
/**
|
|
763
820
|
* Deterministic short key for providers with automatic, prefix-based caching
|
|
@@ -2569,7 +2626,9 @@ class AnthropicAdapter extends BaseProviderAdapter {
|
|
|
2569
2626
|
PROVIDER.ANTHROPIC.MAX_TOKENS.DEFAULT,
|
|
2570
2627
|
stream: false,
|
|
2571
2628
|
};
|
|
2572
|
-
const cache = resolveCache(request.cache
|
|
2629
|
+
const cache = resolveCache(request.cache, {
|
|
2630
|
+
defaultTtl: CACHE_TTL_ANTHROPIC_DEFAULT,
|
|
2631
|
+
});
|
|
2573
2632
|
const cacheControl = cache.enabled
|
|
2574
2633
|
? {
|
|
2575
2634
|
type: "ephemeral",
|