@jaypie/llm 1.3.15 → 1.3.16
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 +56 -1
- package/dist/cjs/index.cjs +180 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +61 -4
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/operate/adapters/BedrockAdapter.d.ts +2 -0
- package/dist/esm/constants.d.ts +56 -1
- package/dist/esm/index.d.ts +61 -4
- package/dist/esm/index.js +180 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/BedrockAdapter.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/index.d.cts
CHANGED
|
@@ -52,6 +52,61 @@ declare const MODEL: {
|
|
|
52
52
|
SONNET: string;
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
+
/** Price of one million tokens, in US dollars. */
|
|
56
|
+
interface LlmModelCost {
|
|
57
|
+
/**
|
|
58
|
+
* Cache-read (cached input) tokens. Omitted when the provider does not price
|
|
59
|
+
* cache reads separately from uncached input.
|
|
60
|
+
*/
|
|
61
|
+
cachedInputRead?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Cache-write tokens. A scalar when the rate does not vary by TTL; keyed by
|
|
64
|
+
* the same `"5m"` / `"1h"` literals as `LlmCache` when it does, so a cost
|
|
65
|
+
* calculation reads the TTL straight off `OperateRequest.cache`. Omitted
|
|
66
|
+
* means cache writes bill at the `input` rate.
|
|
67
|
+
*/
|
|
68
|
+
cachedInputWrite?: number | {
|
|
69
|
+
"1h": number;
|
|
70
|
+
"5m": number;
|
|
71
|
+
};
|
|
72
|
+
/** Uncached input tokens. */
|
|
73
|
+
input: number;
|
|
74
|
+
/** Output tokens. */
|
|
75
|
+
output: number;
|
|
76
|
+
/**
|
|
77
|
+
* Reasoning tokens, when billed at a rate other than `output`. Omitted means
|
|
78
|
+
* reasoning bills as output, which is true of every provider listed here.
|
|
79
|
+
*/
|
|
80
|
+
reasoning?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Standard list price per million tokens, keyed by literal model id (verified
|
|
84
|
+
* 2026-07-21). Keys are string literals rather than `MODEL.*` references so a
|
|
85
|
+
* model retired from the catalog keeps its price here: historic ids stay
|
|
86
|
+
* priceable after they leave `MODEL.*`, which is what makes replaying old
|
|
87
|
+
* usage records possible.
|
|
88
|
+
*
|
|
89
|
+
* Caveats the numbers cannot carry:
|
|
90
|
+
* - **Standard rate only.** Introductory, batch, flex, priority, fast-mode, and
|
|
91
|
+
* data-residency rates are excluded. Sonnet 5 is listed at its standard
|
|
92
|
+
* $3/$15, not the introductory rate.
|
|
93
|
+
* - **Cache writes are Anthropic-only.** Fireworks writes bill at the input
|
|
94
|
+
* rate. OpenAI and xAI discount reads automatically and publish no write
|
|
95
|
+
* premium. Google charges nothing to write an implicit cache; explicit
|
|
96
|
+
* caching bills storage per hour, a unit this table does not carry (and one
|
|
97
|
+
* `@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
|
+
* - **Proxies are deliberately absent.** Bedrock (`PROVIDER.BEDROCK.*`) and
|
|
103
|
+
* OpenRouter (`MODEL.OPENROUTER.*`) resell many vendors and price per backend
|
|
104
|
+
* route, so no single rate is correct for a proxy id. Price those against the
|
|
105
|
+
* backend model, or against the proxy's own published rate.
|
|
106
|
+
*
|
|
107
|
+
* Unlisted ids return `undefined` — callers must handle a miss.
|
|
108
|
+
*/
|
|
109
|
+
declare const COST: Record<string, LlmModelCost>;
|
|
55
110
|
declare const PROVIDER: {
|
|
56
111
|
readonly BEDROCK: {
|
|
57
112
|
readonly DEFAULT: "amazon.nova-pro-v1:0";
|
|
@@ -206,22 +261,24 @@ declare const DEFAULT: {
|
|
|
206
261
|
*/
|
|
207
262
|
declare const ALL: {
|
|
208
263
|
readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-latest"];
|
|
209
|
-
readonly COMBINED: readonly ("claude-opus-4-8" | "claude-haiku-4-5" | "gemini-3.
|
|
264
|
+
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.5-flash" | "gemini-3.1-flash-lite" | "gpt-5.4" | "grok-4-1-fast-reasoning" | "grok-4-1-fast-non-reasoning")[];
|
|
210
265
|
readonly LARGE: readonly ["claude-opus-4-8", "gemini-3.1-pro-preview", "gpt-5.5", "grok-latest"];
|
|
211
266
|
readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3.5-flash", "gpt-5.4-mini", "grok-4-1-fast-reasoning"];
|
|
212
267
|
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
|
|
213
268
|
};
|
|
214
269
|
|
|
215
270
|
declare const constants_ALL: typeof ALL;
|
|
271
|
+
declare const constants_COST: typeof COST;
|
|
216
272
|
declare const constants_DEFAULT: typeof DEFAULT;
|
|
217
273
|
declare const constants_EFFORT: typeof EFFORT;
|
|
218
274
|
type constants_LlmEffort = LlmEffort;
|
|
275
|
+
type constants_LlmModelCost = LlmModelCost;
|
|
219
276
|
type constants_LlmProviderName = LlmProviderName;
|
|
220
277
|
declare const constants_MODEL: typeof MODEL;
|
|
221
278
|
declare const constants_PROVIDER: typeof PROVIDER;
|
|
222
279
|
declare namespace constants {
|
|
223
|
-
export { constants_ALL as ALL, constants_DEFAULT as DEFAULT, constants_EFFORT as EFFORT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
|
|
224
|
-
export type { constants_LlmEffort as LlmEffort, constants_LlmProviderName as LlmProviderName };
|
|
280
|
+
export { constants_ALL as ALL, constants_COST as COST, constants_DEFAULT as DEFAULT, constants_EFFORT as EFFORT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
|
|
281
|
+
export type { constants_LlmEffort as LlmEffort, constants_LlmModelCost as LlmModelCost, constants_LlmProviderName as LlmProviderName };
|
|
225
282
|
}
|
|
226
283
|
|
|
227
284
|
interface LlmTool {
|
|
@@ -1042,4 +1099,4 @@ declare class XaiProvider implements LlmProvider {
|
|
|
1042
1099
|
}
|
|
1043
1100
|
|
|
1044
1101
|
export { BedrockProvider, ErrorCategory, FireworksProvider, GoogleProvider as GeminiProvider, GoogleProvider, JaypieToolkit, constants as LLM, Llm, LlmError, LlmMessageRole, LlmMessageType, LlmProgressEventType, LlmQuotaError, LlmRateLimitError, LlmStreamChunkType, LlmTransientError, LlmUnrecoverableError, OpenRouterProvider, Toolkit, XaiProvider, extractReasoning, isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, jsonSchemaToNaturalSchema, naturalSchemaToJsonSchema, toolkit, tools };
|
|
1045
|
-
export type { LlmCache, LlmEffort, LlmErrorOptions, LlmExchangeCallback, LlmExchangeEnvelope, LlmExchangeRequest, LlmExchangeResolution, LlmExchangeResponse, LlmExchangeTiming, LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmModelOption, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
|
|
1102
|
+
export type { LlmCache, LlmEffort, LlmErrorOptions, LlmExchangeCallback, LlmExchangeEnvelope, LlmExchangeRequest, LlmExchangeResolution, LlmExchangeResponse, LlmExchangeTiming, LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmModelCost, LlmModelOption, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as Llm } from "./Llm.js";
|
|
2
2
|
export * as LLM from "./constants.js";
|
|
3
|
-
export type { LlmEffort } from "./constants.js";
|
|
3
|
+
export type { LlmEffort, LlmModelCost } from "./constants.js";
|
|
4
4
|
export type { LlmCache, LlmExchangeCallback, LlmExchangeEnvelope, LlmExchangeRequest, LlmExchangeResolution, LlmExchangeResponse, LlmExchangeTiming, LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmModelOption, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
5
5
|
export { LlmMessageRole, LlmMessageType, LlmProgressEventType, } from "./types/LlmProvider.interface.js";
|
|
6
6
|
export { isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, } from "./types/LlmOperateInput.guards.js";
|
|
@@ -47,6 +47,8 @@ type BedrockRequest = Omit<ConverseCommandInput, "messages"> & {
|
|
|
47
47
|
type AnnotatedBedrockResponse = ConverseCommandOutput & {
|
|
48
48
|
__jaypieStructuredOutput?: boolean;
|
|
49
49
|
};
|
|
50
|
+
/** Exported for tests; not part of the package's public surface. */
|
|
51
|
+
export declare function isCachePointUnsupportedError(error: unknown): boolean;
|
|
50
52
|
export declare class BedrockAdapter extends BaseProviderAdapter {
|
|
51
53
|
readonly name: "bedrock";
|
|
52
54
|
readonly defaultModel: "amazon.nova-pro-v1:0";
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -47,6 +47,61 @@ export declare const MODEL: {
|
|
|
47
47
|
SONNET: string;
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
+
/** Price of one million tokens, in US dollars. */
|
|
51
|
+
export interface LlmModelCost {
|
|
52
|
+
/**
|
|
53
|
+
* Cache-read (cached input) tokens. Omitted when the provider does not price
|
|
54
|
+
* cache reads separately from uncached input.
|
|
55
|
+
*/
|
|
56
|
+
cachedInputRead?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Cache-write tokens. A scalar when the rate does not vary by TTL; keyed by
|
|
59
|
+
* the same `"5m"` / `"1h"` literals as `LlmCache` when it does, so a cost
|
|
60
|
+
* calculation reads the TTL straight off `OperateRequest.cache`. Omitted
|
|
61
|
+
* means cache writes bill at the `input` rate.
|
|
62
|
+
*/
|
|
63
|
+
cachedInputWrite?: number | {
|
|
64
|
+
"1h": number;
|
|
65
|
+
"5m": number;
|
|
66
|
+
};
|
|
67
|
+
/** Uncached input tokens. */
|
|
68
|
+
input: number;
|
|
69
|
+
/** Output tokens. */
|
|
70
|
+
output: number;
|
|
71
|
+
/**
|
|
72
|
+
* Reasoning tokens, when billed at a rate other than `output`. Omitted means
|
|
73
|
+
* reasoning bills as output, which is true of every provider listed here.
|
|
74
|
+
*/
|
|
75
|
+
reasoning?: number;
|
|
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.** Fireworks writes bill at the input
|
|
89
|
+
* rate. OpenAI and xAI discount reads automatically and publish no write
|
|
90
|
+
* premium. Google charges nothing to write an implicit cache; explicit
|
|
91
|
+
* caching bills storage per hour, a unit this table does not carry (and one
|
|
92
|
+
* `@jaypie/llm` does not wire).
|
|
93
|
+
* - **Short-context tier.** Long-prompt surcharges are not modeled: Gemini 3.1
|
|
94
|
+
* Pro doubles above 200K, Grok doubles at 200K, GPT-5.5 is 2x in / 1.5x out
|
|
95
|
+
* above 272K.
|
|
96
|
+
* - **Text rates.** Gemini prices audio input higher than text/image/video.
|
|
97
|
+
* - **Proxies are deliberately absent.** Bedrock (`PROVIDER.BEDROCK.*`) and
|
|
98
|
+
* OpenRouter (`MODEL.OPENROUTER.*`) resell many vendors and price per backend
|
|
99
|
+
* route, so no single rate is correct for a proxy id. Price those against the
|
|
100
|
+
* backend model, or against the proxy's own published rate.
|
|
101
|
+
*
|
|
102
|
+
* Unlisted ids return `undefined` — callers must handle a miss.
|
|
103
|
+
*/
|
|
104
|
+
export declare const COST: Record<string, LlmModelCost>;
|
|
50
105
|
export declare const PROVIDER: {
|
|
51
106
|
readonly BEDROCK: {
|
|
52
107
|
readonly DEFAULT: "amazon.nova-pro-v1:0";
|
|
@@ -201,7 +256,7 @@ export declare const DEFAULT: {
|
|
|
201
256
|
*/
|
|
202
257
|
export declare const ALL: {
|
|
203
258
|
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.
|
|
259
|
+
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
260
|
readonly LARGE: readonly ["claude-opus-4-8", "gemini-3.1-pro-preview", "gpt-5.5", "grok-latest"];
|
|
206
261
|
readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3.5-flash", "gpt-5.4-mini", "grok-4-1-fast-reasoning"];
|
|
207
262
|
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -52,6 +52,61 @@ declare const MODEL: {
|
|
|
52
52
|
SONNET: string;
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
+
/** Price of one million tokens, in US dollars. */
|
|
56
|
+
interface LlmModelCost {
|
|
57
|
+
/**
|
|
58
|
+
* Cache-read (cached input) tokens. Omitted when the provider does not price
|
|
59
|
+
* cache reads separately from uncached input.
|
|
60
|
+
*/
|
|
61
|
+
cachedInputRead?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Cache-write tokens. A scalar when the rate does not vary by TTL; keyed by
|
|
64
|
+
* the same `"5m"` / `"1h"` literals as `LlmCache` when it does, so a cost
|
|
65
|
+
* calculation reads the TTL straight off `OperateRequest.cache`. Omitted
|
|
66
|
+
* means cache writes bill at the `input` rate.
|
|
67
|
+
*/
|
|
68
|
+
cachedInputWrite?: number | {
|
|
69
|
+
"1h": number;
|
|
70
|
+
"5m": number;
|
|
71
|
+
};
|
|
72
|
+
/** Uncached input tokens. */
|
|
73
|
+
input: number;
|
|
74
|
+
/** Output tokens. */
|
|
75
|
+
output: number;
|
|
76
|
+
/**
|
|
77
|
+
* Reasoning tokens, when billed at a rate other than `output`. Omitted means
|
|
78
|
+
* reasoning bills as output, which is true of every provider listed here.
|
|
79
|
+
*/
|
|
80
|
+
reasoning?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Standard list price per million tokens, keyed by literal model id (verified
|
|
84
|
+
* 2026-07-21). Keys are string literals rather than `MODEL.*` references so a
|
|
85
|
+
* model retired from the catalog keeps its price here: historic ids stay
|
|
86
|
+
* priceable after they leave `MODEL.*`, which is what makes replaying old
|
|
87
|
+
* usage records possible.
|
|
88
|
+
*
|
|
89
|
+
* Caveats the numbers cannot carry:
|
|
90
|
+
* - **Standard rate only.** Introductory, batch, flex, priority, fast-mode, and
|
|
91
|
+
* data-residency rates are excluded. Sonnet 5 is listed at its standard
|
|
92
|
+
* $3/$15, not the introductory rate.
|
|
93
|
+
* - **Cache writes are Anthropic-only.** Fireworks writes bill at the input
|
|
94
|
+
* rate. OpenAI and xAI discount reads automatically and publish no write
|
|
95
|
+
* premium. Google charges nothing to write an implicit cache; explicit
|
|
96
|
+
* caching bills storage per hour, a unit this table does not carry (and one
|
|
97
|
+
* `@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
|
+
* - **Proxies are deliberately absent.** Bedrock (`PROVIDER.BEDROCK.*`) and
|
|
103
|
+
* OpenRouter (`MODEL.OPENROUTER.*`) resell many vendors and price per backend
|
|
104
|
+
* route, so no single rate is correct for a proxy id. Price those against the
|
|
105
|
+
* backend model, or against the proxy's own published rate.
|
|
106
|
+
*
|
|
107
|
+
* Unlisted ids return `undefined` — callers must handle a miss.
|
|
108
|
+
*/
|
|
109
|
+
declare const COST: Record<string, LlmModelCost>;
|
|
55
110
|
declare const PROVIDER: {
|
|
56
111
|
readonly BEDROCK: {
|
|
57
112
|
readonly DEFAULT: "amazon.nova-pro-v1:0";
|
|
@@ -206,22 +261,24 @@ declare const DEFAULT: {
|
|
|
206
261
|
*/
|
|
207
262
|
declare const ALL: {
|
|
208
263
|
readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-latest"];
|
|
209
|
-
readonly COMBINED: readonly ("claude-opus-4-8" | "claude-haiku-4-5" | "gemini-3.
|
|
264
|
+
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.5-flash" | "gemini-3.1-flash-lite" | "gpt-5.4" | "grok-4-1-fast-reasoning" | "grok-4-1-fast-non-reasoning")[];
|
|
210
265
|
readonly LARGE: readonly ["claude-opus-4-8", "gemini-3.1-pro-preview", "gpt-5.5", "grok-latest"];
|
|
211
266
|
readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3.5-flash", "gpt-5.4-mini", "grok-4-1-fast-reasoning"];
|
|
212
267
|
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
|
|
213
268
|
};
|
|
214
269
|
|
|
215
270
|
declare const constants_ALL: typeof ALL;
|
|
271
|
+
declare const constants_COST: typeof COST;
|
|
216
272
|
declare const constants_DEFAULT: typeof DEFAULT;
|
|
217
273
|
declare const constants_EFFORT: typeof EFFORT;
|
|
218
274
|
type constants_LlmEffort = LlmEffort;
|
|
275
|
+
type constants_LlmModelCost = LlmModelCost;
|
|
219
276
|
type constants_LlmProviderName = LlmProviderName;
|
|
220
277
|
declare const constants_MODEL: typeof MODEL;
|
|
221
278
|
declare const constants_PROVIDER: typeof PROVIDER;
|
|
222
279
|
declare namespace constants {
|
|
223
|
-
export { constants_ALL as ALL, constants_DEFAULT as DEFAULT, constants_EFFORT as EFFORT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
|
|
224
|
-
export type { constants_LlmEffort as LlmEffort, constants_LlmProviderName as LlmProviderName };
|
|
280
|
+
export { constants_ALL as ALL, constants_COST as COST, constants_DEFAULT as DEFAULT, constants_EFFORT as EFFORT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
|
|
281
|
+
export type { constants_LlmEffort as LlmEffort, constants_LlmModelCost as LlmModelCost, constants_LlmProviderName as LlmProviderName };
|
|
225
282
|
}
|
|
226
283
|
|
|
227
284
|
interface LlmTool {
|
|
@@ -1042,4 +1099,4 @@ declare class XaiProvider implements LlmProvider {
|
|
|
1042
1099
|
}
|
|
1043
1100
|
|
|
1044
1101
|
export { BedrockProvider, ErrorCategory, FireworksProvider, GoogleProvider as GeminiProvider, GoogleProvider, JaypieToolkit, constants as LLM, Llm, LlmError, LlmMessageRole, LlmMessageType, LlmProgressEventType, LlmQuotaError, LlmRateLimitError, LlmStreamChunkType, LlmTransientError, LlmUnrecoverableError, OpenRouterProvider, Toolkit, XaiProvider, extractReasoning, isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, jsonSchemaToNaturalSchema, naturalSchemaToJsonSchema, toolkit, tools };
|
|
1045
|
-
export type { LlmCache, LlmEffort, LlmErrorOptions, LlmExchangeCallback, LlmExchangeEnvelope, LlmExchangeRequest, LlmExchangeResolution, LlmExchangeResponse, LlmExchangeTiming, LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmModelOption, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
|
|
1102
|
+
export type { LlmCache, LlmEffort, LlmErrorOptions, LlmExchangeCallback, LlmExchangeEnvelope, LlmExchangeRequest, LlmExchangeResolution, LlmExchangeResponse, LlmExchangeTiming, LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmModelCost, LlmModelOption, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
|
package/dist/esm/index.js
CHANGED
|
@@ -43,8 +43,8 @@ const MODEL = {
|
|
|
43
43
|
QWEN: "accounts/fireworks/models/qwen3p7-plus",
|
|
44
44
|
},
|
|
45
45
|
// Google
|
|
46
|
-
GEMINI_FLASH: "gemini-3.
|
|
47
|
-
GEMINI_FLASH_LITE: "gemini-3.
|
|
46
|
+
GEMINI_FLASH: "gemini-3.6-flash",
|
|
47
|
+
GEMINI_FLASH_LITE: "gemini-3.5-flash-lite",
|
|
48
48
|
GEMINI_PRO: "gemini-3.1-pro-preview",
|
|
49
49
|
// OpenAI
|
|
50
50
|
SOL: "gpt-5.6-sol",
|
|
@@ -65,6 +65,177 @@ const MODEL = {
|
|
|
65
65
|
SONNET: "anthropic/claude-sonnet-5",
|
|
66
66
|
},
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Standard list price per million tokens, keyed by literal model id (verified
|
|
70
|
+
* 2026-07-21). Keys are string literals rather than `MODEL.*` references so a
|
|
71
|
+
* model retired from the catalog keeps its price here: historic ids stay
|
|
72
|
+
* priceable after they leave `MODEL.*`, which is what makes replaying old
|
|
73
|
+
* usage records possible.
|
|
74
|
+
*
|
|
75
|
+
* Caveats the numbers cannot carry:
|
|
76
|
+
* - **Standard rate only.** Introductory, batch, flex, priority, fast-mode, and
|
|
77
|
+
* data-residency rates are excluded. Sonnet 5 is listed at its standard
|
|
78
|
+
* $3/$15, not the introductory rate.
|
|
79
|
+
* - **Cache writes are Anthropic-only.** Fireworks writes bill at the input
|
|
80
|
+
* rate. OpenAI and xAI discount reads automatically and publish no write
|
|
81
|
+
* premium. Google charges nothing to write an implicit cache; explicit
|
|
82
|
+
* caching bills storage per hour, a unit this table does not carry (and one
|
|
83
|
+
* `@jaypie/llm` does not wire).
|
|
84
|
+
* - **Short-context tier.** Long-prompt surcharges are not modeled: Gemini 3.1
|
|
85
|
+
* Pro doubles above 200K, Grok doubles at 200K, GPT-5.5 is 2x in / 1.5x out
|
|
86
|
+
* above 272K.
|
|
87
|
+
* - **Text rates.** Gemini prices audio input higher than text/image/video.
|
|
88
|
+
* - **Proxies are deliberately absent.** Bedrock (`PROVIDER.BEDROCK.*`) and
|
|
89
|
+
* OpenRouter (`MODEL.OPENROUTER.*`) resell many vendors and price per backend
|
|
90
|
+
* route, so no single rate is correct for a proxy id. Price those against the
|
|
91
|
+
* backend model, or against the proxy's own published rate.
|
|
92
|
+
*
|
|
93
|
+
* Unlisted ids return `undefined` — callers must handle a miss.
|
|
94
|
+
*/
|
|
95
|
+
const COST = {
|
|
96
|
+
// Anthropic — https://platform.claude.com/docs/en/about-claude/pricing
|
|
97
|
+
"claude-3-5-haiku-20241022": {
|
|
98
|
+
cachedInputRead: 0.08,
|
|
99
|
+
cachedInputWrite: { "1h": 1.6, "5m": 1.0 },
|
|
100
|
+
input: 0.8,
|
|
101
|
+
output: 4.0,
|
|
102
|
+
},
|
|
103
|
+
"claude-fable-5": {
|
|
104
|
+
cachedInputRead: 1.0,
|
|
105
|
+
cachedInputWrite: { "1h": 20.0, "5m": 12.5 },
|
|
106
|
+
input: 10.0,
|
|
107
|
+
output: 50.0,
|
|
108
|
+
},
|
|
109
|
+
"claude-haiku-4-5": {
|
|
110
|
+
cachedInputRead: 0.1,
|
|
111
|
+
cachedInputWrite: { "1h": 2.0, "5m": 1.25 },
|
|
112
|
+
input: 1.0,
|
|
113
|
+
output: 5.0,
|
|
114
|
+
},
|
|
115
|
+
"claude-mythos-5": {
|
|
116
|
+
cachedInputRead: 1.0,
|
|
117
|
+
cachedInputWrite: { "1h": 20.0, "5m": 12.5 },
|
|
118
|
+
input: 10.0,
|
|
119
|
+
output: 50.0,
|
|
120
|
+
},
|
|
121
|
+
"claude-opus-4-1": {
|
|
122
|
+
cachedInputRead: 1.5,
|
|
123
|
+
cachedInputWrite: { "1h": 30.0, "5m": 18.75 },
|
|
124
|
+
input: 15.0,
|
|
125
|
+
output: 75.0,
|
|
126
|
+
},
|
|
127
|
+
"claude-opus-4-5": {
|
|
128
|
+
cachedInputRead: 0.5,
|
|
129
|
+
cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
|
|
130
|
+
input: 5.0,
|
|
131
|
+
output: 25.0,
|
|
132
|
+
},
|
|
133
|
+
"claude-opus-4-6": {
|
|
134
|
+
cachedInputRead: 0.5,
|
|
135
|
+
cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
|
|
136
|
+
input: 5.0,
|
|
137
|
+
output: 25.0,
|
|
138
|
+
},
|
|
139
|
+
"claude-opus-4-7": {
|
|
140
|
+
cachedInputRead: 0.5,
|
|
141
|
+
cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
|
|
142
|
+
input: 5.0,
|
|
143
|
+
output: 25.0,
|
|
144
|
+
},
|
|
145
|
+
"claude-opus-4-8": {
|
|
146
|
+
cachedInputRead: 0.5,
|
|
147
|
+
cachedInputWrite: { "1h": 10.0, "5m": 6.25 },
|
|
148
|
+
input: 5.0,
|
|
149
|
+
output: 25.0,
|
|
150
|
+
},
|
|
151
|
+
"claude-sonnet-4-20250514": {
|
|
152
|
+
cachedInputRead: 0.3,
|
|
153
|
+
cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
|
|
154
|
+
input: 3.0,
|
|
155
|
+
output: 15.0,
|
|
156
|
+
},
|
|
157
|
+
"claude-sonnet-4-5": {
|
|
158
|
+
cachedInputRead: 0.3,
|
|
159
|
+
cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
|
|
160
|
+
input: 3.0,
|
|
161
|
+
output: 15.0,
|
|
162
|
+
},
|
|
163
|
+
"claude-sonnet-4-6": {
|
|
164
|
+
cachedInputRead: 0.3,
|
|
165
|
+
cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
|
|
166
|
+
input: 3.0,
|
|
167
|
+
output: 15.0,
|
|
168
|
+
},
|
|
169
|
+
"claude-sonnet-5": {
|
|
170
|
+
cachedInputRead: 0.3,
|
|
171
|
+
cachedInputWrite: { "1h": 6.0, "5m": 3.75 },
|
|
172
|
+
input: 3.0,
|
|
173
|
+
output: 15.0,
|
|
174
|
+
},
|
|
175
|
+
// Fireworks — https://docs.fireworks.ai/serverless/pricing
|
|
176
|
+
"accounts/fireworks/models/deepseek-v4-pro": {
|
|
177
|
+
cachedInputRead: 0.145,
|
|
178
|
+
input: 1.74,
|
|
179
|
+
output: 3.48,
|
|
180
|
+
},
|
|
181
|
+
"accounts/fireworks/models/glm-5p2": {
|
|
182
|
+
cachedInputRead: 0.14,
|
|
183
|
+
input: 1.4,
|
|
184
|
+
output: 4.4,
|
|
185
|
+
},
|
|
186
|
+
"accounts/fireworks/models/kimi-k2p7-code": {
|
|
187
|
+
cachedInputRead: 0.19,
|
|
188
|
+
input: 0.95,
|
|
189
|
+
output: 4.0,
|
|
190
|
+
},
|
|
191
|
+
"accounts/fireworks/models/minimax-m2p7": {
|
|
192
|
+
cachedInputRead: 0.06,
|
|
193
|
+
input: 0.3,
|
|
194
|
+
output: 1.2,
|
|
195
|
+
},
|
|
196
|
+
"accounts/fireworks/models/qwen3p7-plus": {
|
|
197
|
+
cachedInputRead: 0.08,
|
|
198
|
+
input: 0.4,
|
|
199
|
+
output: 1.6,
|
|
200
|
+
},
|
|
201
|
+
// Google — https://ai.google.dev/gemini-api/docs/pricing
|
|
202
|
+
"gemini-2.5-flash": { cachedInputRead: 0.03, input: 0.3, output: 2.5 },
|
|
203
|
+
"gemini-3.1-flash-lite": {
|
|
204
|
+
cachedInputRead: 0.025,
|
|
205
|
+
input: 0.25,
|
|
206
|
+
output: 1.5,
|
|
207
|
+
},
|
|
208
|
+
"gemini-3.1-flash-lite-preview": {
|
|
209
|
+
cachedInputRead: 0.025,
|
|
210
|
+
input: 0.25,
|
|
211
|
+
output: 1.5,
|
|
212
|
+
},
|
|
213
|
+
"gemini-3.1-pro-preview": { cachedInputRead: 0.2, input: 2.0, output: 12.0 },
|
|
214
|
+
"gemini-3.5-flash": { cachedInputRead: 0.15, input: 1.5, output: 9.0 },
|
|
215
|
+
// Flash-Lite 3.5 has no separate cache-read rate on the standard tier
|
|
216
|
+
"gemini-3.5-flash-lite": { input: 0.3, output: 2.5 },
|
|
217
|
+
"gemini-3.6-flash": { cachedInputRead: 0.15, input: 1.5, output: 7.5 },
|
|
218
|
+
// OpenAI — https://developers.openai.com/api/docs/pricing
|
|
219
|
+
"gpt-5.4": { cachedInputRead: 0.25, input: 2.5, output: 15.0 },
|
|
220
|
+
"gpt-5.4-mini": { cachedInputRead: 0.075, input: 0.75, output: 4.5 },
|
|
221
|
+
"gpt-5.4-nano": { cachedInputRead: 0.02, input: 0.2, output: 1.25 },
|
|
222
|
+
"gpt-5.5": { cachedInputRead: 0.5, input: 5.0, output: 30.0 },
|
|
223
|
+
"gpt-5.6-luna": { cachedInputRead: 0.1, input: 1.0, output: 6.0 },
|
|
224
|
+
"gpt-5.6-sol": { cachedInputRead: 0.5, input: 5.0, output: 30.0 },
|
|
225
|
+
"gpt-5.6-terra": { cachedInputRead: 0.25, input: 2.5, output: 15.0 },
|
|
226
|
+
// xAI — https://docs.x.ai/docs/models ("grok-latest" aliases grok-4.3-latest)
|
|
227
|
+
"grok-4-1-fast-non-reasoning": {
|
|
228
|
+
cachedInputRead: 0.05,
|
|
229
|
+
input: 0.2,
|
|
230
|
+
output: 0.5,
|
|
231
|
+
},
|
|
232
|
+
"grok-4-1-fast-reasoning": {
|
|
233
|
+
cachedInputRead: 0.05,
|
|
234
|
+
input: 0.2,
|
|
235
|
+
output: 0.5,
|
|
236
|
+
},
|
|
237
|
+
"grok-latest": { cachedInputRead: 0.2, input: 1.25, output: 2.5 },
|
|
238
|
+
};
|
|
68
239
|
const GOOGLE_PROVIDER = {
|
|
69
240
|
// https://ai.google.dev/gemini-api/docs/models
|
|
70
241
|
DEFAULT: MODEL.GEMINI_FLASH,
|
|
@@ -270,6 +441,7 @@ const ALL = {
|
|
|
270
441
|
var constants = /*#__PURE__*/Object.freeze({
|
|
271
442
|
__proto__: null,
|
|
272
443
|
ALL: ALL,
|
|
444
|
+
COST: COST,
|
|
273
445
|
DEFAULT: DEFAULT,
|
|
274
446
|
EFFORT: EFFORT,
|
|
275
447
|
MODEL: MODEL,
|
|
@@ -2996,13 +3168,16 @@ function isTemperatureDeprecationError$3(error) {
|
|
|
2996
3168
|
const msg = error?.message ?? "";
|
|
2997
3169
|
return /temperature.*deprecated|deprecated.*temperature/i.test(msg);
|
|
2998
3170
|
}
|
|
3171
|
+
/** Exported for tests; not part of the package's public surface. */
|
|
2999
3172
|
function isCachePointUnsupportedError(error) {
|
|
3000
3173
|
const name = error?.constructor?.name ?? "";
|
|
3001
3174
|
const msg = error?.message ?? "";
|
|
3002
3175
|
// A model that cannot cache rejects the cachePoint block with a
|
|
3003
|
-
// ValidationException naming caching / cachePoint.
|
|
3004
|
-
|
|
3005
|
-
|
|
3176
|
+
// ValidationException naming caching / cachePoint. Bedrock words this as
|
|
3177
|
+
// "You invoked an unsupported model or your request did not allow prompt
|
|
3178
|
+
// caching" — "unsupported" is one word, so it must be matched separately
|
|
3179
|
+
// from "not support".
|
|
3180
|
+
return (/ValidationException|invalid|not support|unsupported/i.test(name + " " + msg) && /cachePoint|cache_point|prompt caching|caching/i.test(msg));
|
|
3006
3181
|
}
|
|
3007
3182
|
function extractJson(text) {
|
|
3008
3183
|
// Try direct parse first
|