llmbrake 0.2.1 → 0.2.2
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/prices.d.ts +2 -2
- package/dist/prices.js +8 -2
- package/package.json +1 -1
package/dist/prices.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* - OpenAI: https://developers.openai.com/api/docs/pricing
|
|
7
7
|
* - Anthropic: https://docs.anthropic.com/en/docs/about-claude/pricing
|
|
8
8
|
* Anthropic IDs for the current generation were checked against the models overview page (2026-10-17).
|
|
9
|
-
* Claude Haiku 5.5
|
|
10
|
-
*
|
|
9
|
+
* Claude Haiku 5.5: short tier by default; computeCostUsd auto-selects `claude-haiku-5-5:long` when prompt_tokens > 100K.
|
|
10
|
+
* Batch, regional/data-residency uplifts and fast/priority tiers are NOT modeled.
|
|
11
11
|
* Override or extend via `createGuard({ prices: { ...DEFAULT_PRICES, ...yours } })`.
|
|
12
12
|
*/
|
|
13
13
|
export interface ModelPrice {
|
package/dist/prices.js
CHANGED
|
@@ -18,16 +18,22 @@ export const DEFAULT_PRICES = {
|
|
|
18
18
|
"claude-opus-5-5": { inputPerMTok: 4.0, cachedInputPerMTok: 0.2, outputPerMTok: 20.0, source: ANTHROPIC },
|
|
19
19
|
"claude-sonnet-5-5": { inputPerMTok: 2.0, cachedInputPerMTok: 0.1, outputPerMTok: 10.0, source: ANTHROPIC },
|
|
20
20
|
"claude-haiku-5-5": { inputPerMTok: 0.1, cachedInputPerMTok: 0.01, outputPerMTok: 0.5, source: ANTHROPIC },
|
|
21
|
+
// Prompts over 100K tokens (cache reads/writes count toward the threshold); whole request billed at this tier.
|
|
22
|
+
"claude-haiku-5-5:long": { inputPerMTok: 0.5, cachedInputPerMTok: 0.05, outputPerMTok: 2.5, source: ANTHROPIC },
|
|
21
23
|
"claude-opus-4-8": { inputPerMTok: 5.0, cachedInputPerMTok: 0.5, outputPerMTok: 25.0, source: ANTHROPIC },
|
|
22
24
|
"claude-sonnet-5": { inputPerMTok: 2.0, cachedInputPerMTok: 0.2, outputPerMTok: 10.0, source: ANTHROPIC },
|
|
23
25
|
"claude-haiku-4-5": { inputPerMTok: 1.0, cachedInputPerMTok: 0.1, outputPerMTok: 5.0, source: ANTHROPIC },
|
|
24
26
|
};
|
|
25
27
|
/** Returns USD cost, or null if the model is not in the table. */
|
|
26
28
|
export function computeCostUsd(model, usage, prices) {
|
|
27
|
-
const
|
|
29
|
+
const prompt = usage.prompt_tokens ?? 0;
|
|
30
|
+
// Haiku 5.5 bills the whole request at the >100K tier once total input crosses 100K.
|
|
31
|
+
const pricedModel = (model === "claude-haiku-5-5" || model.startsWith("claude-haiku-5-5-")) && prompt > 100_000
|
|
32
|
+
? "claude-haiku-5-5:long"
|
|
33
|
+
: model;
|
|
34
|
+
const p = lookupPrice(pricedModel, prices);
|
|
28
35
|
if (!p)
|
|
29
36
|
return null;
|
|
30
|
-
const prompt = usage.prompt_tokens ?? 0;
|
|
31
37
|
const cached = Math.min(usage.prompt_tokens_details?.cached_tokens ?? 0, prompt);
|
|
32
38
|
const uncached = prompt - cached;
|
|
33
39
|
const out = usage.completion_tokens ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llmbrake",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Per-customer monthly USD budgets for OpenAI-compatible chat calls: track cost, auto-downgrade near the cap, block at the cap.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "LLMBrake contributors",
|