vibezcheck 0.4.2 → 0.5.3
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/LICENSE +21 -21
- package/README.md +249 -273
- package/bin/vibezcheck.js +4 -4
- package/dist/ai-sdk/index.d.mts +28 -59
- package/dist/ai-sdk/index.d.ts +28 -59
- package/dist/ai-sdk/index.js +307 -69
- package/dist/ai-sdk/index.js.map +1 -1
- package/dist/ai-sdk/index.mjs +307 -69
- package/dist/ai-sdk/index.mjs.map +1 -1
- package/dist/ai-sdk/middleware.d.mts +15 -0
- package/dist/ai-sdk/middleware.d.ts +15 -0
- package/dist/ai-sdk/middleware.js +1433 -0
- package/dist/ai-sdk/middleware.js.map +1 -0
- package/dist/ai-sdk/middleware.mjs +1396 -0
- package/dist/ai-sdk/middleware.mjs.map +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs.map +1 -1
- package/dist/billing/index.d.mts +90 -1
- package/dist/billing/index.d.ts +90 -1
- package/dist/billing/index.js +1542 -2
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +1537 -1
- package/dist/billing/index.mjs.map +1 -1
- package/dist/cli/index.js +59 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +59 -7
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{client-ynfWcHX6.d.ts → client-BORmJy8s.d.ts} +1 -1
- package/dist/{client-w_hWhQ6g.d.mts → client-CbuXmoXz.d.mts} +1 -1
- package/dist/compat/stripe-meter.d.mts +21 -0
- package/dist/compat/stripe-meter.d.ts +21 -0
- package/dist/compat/stripe-meter.js +1451 -0
- package/dist/compat/stripe-meter.js.map +1 -0
- package/dist/compat/stripe-meter.mjs +1414 -0
- package/dist/compat/stripe-meter.mjs.map +1 -0
- package/dist/compat/stripe-provider.d.mts +34 -0
- package/dist/compat/stripe-provider.d.ts +34 -0
- package/dist/compat/stripe-provider.js +1620 -0
- package/dist/compat/stripe-provider.js.map +1 -0
- package/dist/compat/stripe-provider.mjs +1587 -0
- package/dist/compat/stripe-provider.mjs.map +1 -0
- package/dist/compat/token-meter.d.mts +28 -0
- package/dist/compat/token-meter.d.ts +28 -0
- package/dist/compat/token-meter.js +1320 -0
- package/dist/compat/token-meter.js.map +1 -0
- package/dist/compat/token-meter.mjs +1283 -0
- package/dist/compat/token-meter.mjs.map +1 -0
- package/dist/customers/index.d.mts +1 -1
- package/dist/customers/index.d.ts +1 -1
- package/dist/customers/index.js.map +1 -1
- package/dist/customers/index.mjs.map +1 -1
- package/dist/index.d.mts +25 -11
- package/dist/index.d.ts +25 -11
- package/dist/index.js +810 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +798 -72
- package/dist/index.mjs.map +1 -1
- package/dist/meter/index.d.mts +2 -2
- package/dist/meter/index.d.ts +2 -2
- package/dist/meter/index.js +176 -42
- package/dist/meter/index.js.map +1 -1
- package/dist/meter/index.mjs +176 -42
- package/dist/meter/index.mjs.map +1 -1
- package/dist/pricing/index.d.mts +15 -4
- package/dist/pricing/index.d.ts +15 -4
- package/dist/pricing/index.js +165 -29
- package/dist/pricing/index.js.map +1 -1
- package/dist/pricing/index.mjs +164 -29
- package/dist/pricing/index.mjs.map +1 -1
- package/dist/react/index.d.mts +46 -2
- package/dist/react/index.d.ts +46 -2
- package/dist/react/index.js +471 -29
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +469 -29
- package/dist/react/index.mjs.map +1 -1
- package/dist/{types-Mozk4-Mr.d.mts → types-6P71CXAD.d.mts} +16 -6
- package/dist/{types-Mozk4-Mr.d.ts → types-6P71CXAD.d.ts} +16 -6
- package/dist/with-billing-Bj6Ya_Iy.d.ts +49 -0
- package/dist/with-billing-DndWGxL8.d.mts +49 -0
- package/package.json +35 -10
package/dist/meter/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MeterOptions, U as UsageEvent, a as UsageSummary, S as StreamWrapOptions, T as TokenUsage, C as CustomerParam } from '../types-
|
|
2
|
-
export { V as VibezMeter, c as createMeter } from '../client-
|
|
1
|
+
import { M as MeterOptions, U as UsageEvent, a as UsageSummary, S as StreamWrapOptions, T as TokenUsage, C as CustomerParam } from '../types-6P71CXAD.mjs';
|
|
2
|
+
export { V as VibezMeter, c as createMeter } from '../client-CbuXmoXz.mjs';
|
|
3
3
|
import 'stripe';
|
|
4
4
|
|
|
5
5
|
declare class MeterBatcher {
|
package/dist/meter/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MeterOptions, U as UsageEvent, a as UsageSummary, S as StreamWrapOptions, T as TokenUsage, C as CustomerParam } from '../types-
|
|
2
|
-
export { V as VibezMeter, c as createMeter } from '../client-
|
|
1
|
+
import { M as MeterOptions, U as UsageEvent, a as UsageSummary, S as StreamWrapOptions, T as TokenUsage, C as CustomerParam } from '../types-6P71CXAD.js';
|
|
2
|
+
export { V as VibezMeter, c as createMeter } from '../client-BORmJy8s.js';
|
|
3
3
|
import 'stripe';
|
|
4
4
|
|
|
5
5
|
declare class MeterBatcher {
|
package/dist/meter/index.js
CHANGED
|
@@ -310,12 +310,12 @@ function extractOpenAIResponseUsage(response) {
|
|
|
310
310
|
function inspectOpenAIStreamChunk(chunk) {
|
|
311
311
|
if (!chunk || typeof chunk !== "object") return {};
|
|
312
312
|
const model = chunk.model;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? 0;
|
|
316
|
-
const outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? 0;
|
|
317
|
-
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? 0;
|
|
318
|
-
const cachedTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.input_token_details?.cached_tokens ?? 0;
|
|
313
|
+
const rawUsage = chunk.usage || chunk.token_usage || chunk.x_groq?.usage || chunk.usageMetadata;
|
|
314
|
+
if (rawUsage) {
|
|
315
|
+
const inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokens ?? rawUsage.inputTokens ?? rawUsage.promptTokenCount ?? 0;
|
|
316
|
+
const outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.completionTokens ?? rawUsage.outputTokens ?? rawUsage.candidatesTokenCount ?? 0;
|
|
317
|
+
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? rawUsage.reasoning_tokens ?? rawUsage.reasoningTokens ?? rawUsage.thoughtsTokenCount ?? 0;
|
|
318
|
+
const cachedTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.input_token_details?.cached_tokens ?? rawUsage.prompt_cache_hit_tokens ?? rawUsage.cached_tokens ?? rawUsage.cachedTokens ?? rawUsage.cachedContentTokenCount ?? 0;
|
|
319
319
|
return {
|
|
320
320
|
model,
|
|
321
321
|
usage: {
|
|
@@ -330,11 +330,11 @@ function inspectOpenAIStreamChunk(chunk) {
|
|
|
330
330
|
}
|
|
331
331
|
if (chunk.type === "response.completed" || chunk.type === "response.done") {
|
|
332
332
|
if (chunk.response?.usage) {
|
|
333
|
-
const
|
|
334
|
-
const inputTokens =
|
|
335
|
-
const outputTokens =
|
|
336
|
-
const reasoningTokens =
|
|
337
|
-
const cachedTokens =
|
|
333
|
+
const rawUsage2 = chunk.response.usage;
|
|
334
|
+
const inputTokens = rawUsage2.input_tokens ?? 0;
|
|
335
|
+
const outputTokens = rawUsage2.output_tokens ?? 0;
|
|
336
|
+
const reasoningTokens = rawUsage2.output_token_details?.reasoning_tokens ?? 0;
|
|
337
|
+
const cachedTokens = rawUsage2.input_token_details?.cached_tokens ?? 0;
|
|
338
338
|
return {
|
|
339
339
|
model: chunk.response.model || model,
|
|
340
340
|
usage: {
|
|
@@ -499,7 +499,7 @@ function detectAndExtractUsage(response, fallbackModel, fallbackProvider) {
|
|
|
499
499
|
|
|
500
500
|
// src/pricing/table.ts
|
|
501
501
|
var MODEL_PRICING_TABLE = {
|
|
502
|
-
// --- OpenAI ---
|
|
502
|
+
// --- OpenAI (Modern & Reasoning) ---
|
|
503
503
|
"gpt-5.6-sol": { inputPer1M: 4, outputPer1M: 20, cachedInputPer1M: 0.4 },
|
|
504
504
|
"gpt-5.6-terra": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.2 },
|
|
505
505
|
"gpt-5.6-luna": { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },
|
|
@@ -511,11 +511,22 @@ var MODEL_PRICING_TABLE = {
|
|
|
511
511
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },
|
|
512
512
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cachedInputPer1M: 1.25 },
|
|
513
513
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.075 },
|
|
514
|
+
"gpt-4.5": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
|
|
515
|
+
"gpt-4.5-preview": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
|
|
516
|
+
"chatgpt-4o-latest": { inputPer1M: 5, outputPer1M: 15 },
|
|
514
517
|
"gpt-4.1": { inputPer1M: 2, outputPer1M: 8, cachedInputPer1M: 1 },
|
|
515
518
|
"gpt-4.1-nano": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.05 },
|
|
519
|
+
// --- OpenAI (Legacy & Backward Compatibility) ---
|
|
520
|
+
"gpt-4-turbo": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
|
|
521
|
+
"gpt-4-turbo-preview": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
|
|
522
|
+
"gpt-4": { inputPer1M: 30, outputPer1M: 60 },
|
|
523
|
+
"gpt-4-32k": { inputPer1M: 60, outputPer1M: 120 },
|
|
524
|
+
"gpt-3.5-turbo": { inputPer1M: 0.5, outputPer1M: 1.5 },
|
|
525
|
+
"gpt-3.5-turbo-16k": { inputPer1M: 3, outputPer1M: 4 },
|
|
516
526
|
"text-embedding-3-small": { inputPer1M: 0.02, outputPer1M: 0 },
|
|
517
527
|
"text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0 },
|
|
518
|
-
|
|
528
|
+
"text-embedding-ada-002": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
529
|
+
// --- Anthropic (Modern & Extended Thinking) ---
|
|
519
530
|
"claude-3-7-sonnet": { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },
|
|
520
531
|
"claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.3 },
|
|
521
532
|
"claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
@@ -523,48 +534,145 @@ var MODEL_PRICING_TABLE = {
|
|
|
523
534
|
"haiku-4.5": { inputPer1M: 1, outputPer1M: 5, cachedInputPer1M: 0.1 },
|
|
524
535
|
"claude-opus-5": { inputPer1M: 5, outputPer1M: 25, cachedInputPer1M: 1.5 },
|
|
525
536
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cachedInputPer1M: 1.5 },
|
|
526
|
-
// ---
|
|
537
|
+
// --- Anthropic (Legacy & Backward Compatibility) ---
|
|
538
|
+
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
539
|
+
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cachedInputPer1M: 0.025 },
|
|
540
|
+
"claude-2.1": { inputPer1M: 8, outputPer1M: 24 },
|
|
541
|
+
"claude-2.0": { inputPer1M: 8, outputPer1M: 24 },
|
|
542
|
+
"claude-instant-1.2": { inputPer1M: 1.63, outputPer1M: 5.51 },
|
|
543
|
+
// --- Google Gemini (Modern & Thoughts) ---
|
|
527
544
|
"gemini-3.7-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },
|
|
528
545
|
"gemini-3.1-pro": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.5 },
|
|
529
546
|
"gemini-3.5-flash": { inputPer1M: 1.5, outputPer1M: 9, cachedInputPer1M: 0.38 },
|
|
530
547
|
"gemini-3.1-flash-lite": { inputPer1M: 0.25, outputPer1M: 1.5, cachedInputPer1M: 0.06 },
|
|
548
|
+
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
549
|
+
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.0375 },
|
|
531
550
|
"gemini-2.0-flash": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.025 },
|
|
551
|
+
"gemini-2.0-flash-lite": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
|
|
552
|
+
"gemini-2.0-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
553
|
+
// --- Google Gemini (Legacy & Backward Compatibility) ---
|
|
532
554
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
533
555
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
|
|
556
|
+
"gemini-1.5-flash-8b": { inputPer1M: 0.0375, outputPer1M: 0.15, cachedInputPer1M: 9375e-6 },
|
|
557
|
+
"gemini-1.0-pro": { inputPer1M: 0.5, outputPer1M: 1.5 },
|
|
534
558
|
// --- xAI Grok ---
|
|
535
559
|
"grok-4.6": { inputPer1M: 3, outputPer1M: 15 },
|
|
560
|
+
"grok-3": { inputPer1M: 3, outputPer1M: 15 },
|
|
561
|
+
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 1.5 },
|
|
536
562
|
"grok-2": { inputPer1M: 2, outputPer1M: 10 },
|
|
537
563
|
"grok-2-vision": { inputPer1M: 2, outputPer1M: 10 },
|
|
538
564
|
"grok-beta": { inputPer1M: 5, outputPer1M: 15 },
|
|
539
565
|
// --- Mistral ---
|
|
540
566
|
"mistral-large-3": { inputPer1M: 2, outputPer1M: 6 },
|
|
541
567
|
"mistral-large-latest": { inputPer1M: 2, outputPer1M: 6 },
|
|
568
|
+
"mistral-large-2411": { inputPer1M: 2, outputPer1M: 6 },
|
|
542
569
|
"codestral-latest": { inputPer1M: 0.3, outputPer1M: 0.9 },
|
|
570
|
+
"mistral-medium-latest": { inputPer1M: 2.7, outputPer1M: 8.1 },
|
|
543
571
|
"mistral-small-latest": { inputPer1M: 0.2, outputPer1M: 0.6 },
|
|
544
572
|
"ministral-8b-latest": { inputPer1M: 0.1, outputPer1M: 0.1 },
|
|
545
|
-
|
|
573
|
+
"ministral-3b-latest": { inputPer1M: 0.04, outputPer1M: 0.04 },
|
|
574
|
+
"open-mistral-7b": { inputPer1M: 0.2, outputPer1M: 0.2 },
|
|
575
|
+
"open-mixtral-8x7b": { inputPer1M: 0.7, outputPer1M: 0.7 },
|
|
576
|
+
"open-mixtral-8x22b": { inputPer1M: 2, outputPer1M: 6 },
|
|
577
|
+
// --- Groq & Meta Llama LPUs ---
|
|
546
578
|
"llama-3.3-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
|
|
579
|
+
"llama-3.1-405b": { inputPer1M: 3, outputPer1M: 3 },
|
|
580
|
+
"llama-3.1-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
|
|
547
581
|
"llama-3.1-8b-instant": { inputPer1M: 0.05, outputPer1M: 0.08 },
|
|
582
|
+
"llama-3.2-1b-preview": { inputPer1M: 0.04, outputPer1M: 0.04 },
|
|
583
|
+
"llama-3.2-3b-preview": { inputPer1M: 0.06, outputPer1M: 0.06 },
|
|
584
|
+
"llama-3.2-11b-vision": { inputPer1M: 0.18, outputPer1M: 0.18 },
|
|
585
|
+
"llama-3.2-90b-vision": { inputPer1M: 0.9, outputPer1M: 0.9 },
|
|
548
586
|
"deepseek-r1-distill-llama-70b": { inputPer1M: 0.75, outputPer1M: 0.99 },
|
|
587
|
+
"deepseek-r1-distill-qwen-32b": { inputPer1M: 0.49, outputPer1M: 0.49 },
|
|
549
588
|
"qwen-2.5-32b": { inputPer1M: 0.29, outputPer1M: 0.39 },
|
|
589
|
+
"qwen-2.5-72b": { inputPer1M: 0.35, outputPer1M: 0.4 },
|
|
590
|
+
"mixtral-8x7b-32768": { inputPer1M: 0.24, outputPer1M: 0.24 },
|
|
591
|
+
"gemma2-9b-it": { inputPer1M: 0.2, outputPer1M: 0.2 },
|
|
550
592
|
// --- DeepSeek ---
|
|
551
593
|
"deepseek-v4-pro": { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },
|
|
552
594
|
"deepseek-v4-flash": { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },
|
|
553
|
-
"deepseek-
|
|
554
|
-
"deepseek-
|
|
595
|
+
"deepseek-v3": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
|
|
596
|
+
"deepseek-chat": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
|
|
597
|
+
"deepseek-r1": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
|
|
598
|
+
"deepseek-reasoner": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
|
|
555
599
|
// --- Cohere ---
|
|
556
600
|
"command-r-plus": { inputPer1M: 2.5, outputPer1M: 10 },
|
|
557
|
-
"command-r": { inputPer1M: 0.15, outputPer1M: 0.6 }
|
|
601
|
+
"command-r": { inputPer1M: 0.15, outputPer1M: 0.6 },
|
|
602
|
+
"command": { inputPer1M: 1, outputPer1M: 2 },
|
|
603
|
+
"command-light": { inputPer1M: 0.3, outputPer1M: 0.6 },
|
|
604
|
+
"embed-english-v3.0": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
605
|
+
// --- Perplexity ---
|
|
606
|
+
"sonar": { inputPer1M: 1, outputPer1M: 1 },
|
|
607
|
+
"sonar-pro": { inputPer1M: 3, outputPer1M: 15 },
|
|
608
|
+
"sonar-reasoning": { inputPer1M: 1, outputPer1M: 5 },
|
|
609
|
+
"sonar-reasoning-pro": { inputPer1M: 2, outputPer1M: 8 }
|
|
610
|
+
};
|
|
611
|
+
var MODEL_ALIASES = {
|
|
612
|
+
// OpenAI Shorthands & Aliases
|
|
613
|
+
"gpt4": "gpt-4",
|
|
614
|
+
"gpt4o": "gpt-4o",
|
|
615
|
+
"gpt-4-preview": "gpt-4-turbo",
|
|
616
|
+
"gpt-4-0125-preview": "gpt-4-turbo",
|
|
617
|
+
"gpt-4-1106-preview": "gpt-4-turbo",
|
|
618
|
+
"gpt-3.5": "gpt-3.5-turbo",
|
|
619
|
+
"gpt-3.5-turbo-0125": "gpt-3.5-turbo",
|
|
620
|
+
"gpt-3.5-turbo-1106": "gpt-3.5-turbo",
|
|
621
|
+
"gpt-3.5-turbo-16k-0613": "gpt-3.5-turbo-16k",
|
|
622
|
+
// Anthropic Shorthands
|
|
623
|
+
"sonnet": "claude-3-5-sonnet",
|
|
624
|
+
"sonnet-3.7": "claude-3-7-sonnet",
|
|
625
|
+
"sonnet-3.5": "claude-3-5-sonnet",
|
|
626
|
+
"haiku": "claude-3-5-haiku",
|
|
627
|
+
"haiku-3.5": "claude-3-5-haiku",
|
|
628
|
+
"opus": "claude-3-opus",
|
|
629
|
+
"claude-2": "claude-2.0",
|
|
630
|
+
"claude-instant": "claude-instant-1.2",
|
|
631
|
+
// DeepSeek Shorthands
|
|
632
|
+
"r1": "deepseek-r1",
|
|
633
|
+
"v3": "deepseek-v3",
|
|
634
|
+
// Gemini Shorthands
|
|
635
|
+
"flash": "gemini-2.0-flash",
|
|
636
|
+
"pro": "gemini-1.5-pro",
|
|
637
|
+
// Meta / Groq Shorthands
|
|
638
|
+
"llama-3.3-70b": "llama-3.3-70b-versatile",
|
|
639
|
+
"llama-3.1-70b": "llama-3.1-70b-versatile",
|
|
640
|
+
"llama-3.1-8b": "llama-3.1-8b-instant",
|
|
641
|
+
"llama-3-70b": "llama-3.1-70b-versatile",
|
|
642
|
+
"llama-3-8b": "llama-3.1-8b-instant",
|
|
643
|
+
// Mistral Shorthands
|
|
644
|
+
"codestral": "codestral-latest",
|
|
645
|
+
"mistral-large": "mistral-large-latest",
|
|
646
|
+
"mistral-small": "mistral-small-latest"
|
|
558
647
|
};
|
|
559
648
|
var customPricingRegistry = {};
|
|
560
649
|
function normalizeModelKey(rawModel) {
|
|
561
650
|
if (!rawModel) return "unknown";
|
|
562
651
|
let model = rawModel.toLowerCase().trim();
|
|
652
|
+
model = model.replace(/^[a-z0-9_-]+\.(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
|
|
653
|
+
model = model.replace(/^(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
|
|
654
|
+
model = model.replace(/-v\d+(:\d+)?$/, "");
|
|
655
|
+
model = model.replace(/:\d+$/, "");
|
|
563
656
|
if (model.includes("/")) {
|
|
564
|
-
model = model.split("/")
|
|
657
|
+
model = model.split("/").slice(1).join("/");
|
|
565
658
|
}
|
|
659
|
+
model = model.replace(/:(latest|free|beta)$/, "");
|
|
566
660
|
model = model.replace(/-\d{8}$/, "");
|
|
567
661
|
model = model.replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
662
|
+
model = model.replace(/llama(\d+)-(\d+)-/g, "llama-$1.$2-");
|
|
663
|
+
model = model.replace(/llama(\d+)\.(\d+)-/g, "llama-$1.$2-");
|
|
664
|
+
if (MODEL_ALIASES[model]) {
|
|
665
|
+
return MODEL_ALIASES[model];
|
|
666
|
+
}
|
|
667
|
+
if (!MODEL_PRICING_TABLE[model]) {
|
|
668
|
+
const withoutInstruct = model.replace(/-(instruct|chat|preview)$/, "");
|
|
669
|
+
if (MODEL_PRICING_TABLE[withoutInstruct]) {
|
|
670
|
+
return withoutInstruct;
|
|
671
|
+
}
|
|
672
|
+
if (MODEL_ALIASES[withoutInstruct]) {
|
|
673
|
+
return MODEL_ALIASES[withoutInstruct];
|
|
674
|
+
}
|
|
675
|
+
}
|
|
568
676
|
return model;
|
|
569
677
|
}
|
|
570
678
|
function getModelPricing(modelName) {
|
|
@@ -581,6 +689,10 @@ function getModelPricing(modelName) {
|
|
|
581
689
|
if (MODEL_PRICING_TABLE[modelName]) {
|
|
582
690
|
return MODEL_PRICING_TABLE[modelName];
|
|
583
691
|
}
|
|
692
|
+
const alias = MODEL_ALIASES[modelName.toLowerCase().trim()];
|
|
693
|
+
if (alias && MODEL_PRICING_TABLE[alias]) {
|
|
694
|
+
return MODEL_PRICING_TABLE[alias];
|
|
695
|
+
}
|
|
584
696
|
return {
|
|
585
697
|
inputPer1M: 1,
|
|
586
698
|
outputPer1M: 3,
|
|
@@ -603,35 +715,57 @@ function calculateCost(params) {
|
|
|
603
715
|
} else {
|
|
604
716
|
rates = getModelPricing(params.model);
|
|
605
717
|
}
|
|
606
|
-
const inputTokens = params.inputTokens ?? 0;
|
|
607
|
-
const outputTokens = params.outputTokens ?? 0;
|
|
608
|
-
const reasoningTokens = params.reasoningTokens ?? 0;
|
|
609
|
-
const cachedTokens = params.cachedTokens ?? 0;
|
|
610
|
-
const regularInputTokens =
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
const
|
|
620
|
-
|
|
718
|
+
const inputTokens = BigInt(Math.max(0, params.inputTokens ?? 0));
|
|
719
|
+
const outputTokens = BigInt(Math.max(0, params.outputTokens ?? 0));
|
|
720
|
+
const reasoningTokens = BigInt(Math.max(0, params.reasoningTokens ?? 0));
|
|
721
|
+
const cachedTokens = BigInt(Math.max(0, params.cachedTokens ?? 0));
|
|
722
|
+
const regularInputTokens = inputTokens > cachedTokens ? inputTokens - cachedTokens : 0n;
|
|
723
|
+
const rateInputNano = BigInt(Math.round(rates.inputPer1M * 1e3));
|
|
724
|
+
const cachedPer1M = rates.cachedInputPer1M ?? rates.inputPer1M * 0.15;
|
|
725
|
+
const rateCachedNano = BigInt(Math.round(cachedPer1M * 1e3));
|
|
726
|
+
const rateOutputNano = BigInt(Math.round(rates.outputPer1M * 1e3));
|
|
727
|
+
const reasoningPer1M = rates.reasoningPer1M ?? rates.outputPer1M;
|
|
728
|
+
const rateReasoningNano = BigInt(Math.round(reasoningPer1M * 1e3));
|
|
729
|
+
const regularInputCostNano = regularInputTokens * rateInputNano;
|
|
730
|
+
const cachedInputCostNano = cachedTokens * rateCachedNano;
|
|
731
|
+
const inputCostNano = regularInputCostNano + cachedInputCostNano;
|
|
732
|
+
const outputCostNano = outputTokens * rateOutputNano;
|
|
733
|
+
const reasoningCostNano = reasoningTokens * rateReasoningNano;
|
|
734
|
+
const standardCacheCostNano = cachedTokens * rateInputNano;
|
|
735
|
+
const cachedDiscountNano = standardCacheCostNano > cachedInputCostNano ? standardCacheCostNano - cachedInputCostNano : 0n;
|
|
736
|
+
const wholesaleNano = inputCostNano + outputCostNano;
|
|
621
737
|
const markup = params.markupMultiplier ?? 1;
|
|
622
|
-
let
|
|
738
|
+
let billedNano = wholesaleNano;
|
|
739
|
+
let hasRetail = false;
|
|
623
740
|
if (markup !== 1 || params.minimumChargeUSD !== void 0) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
741
|
+
hasRetail = true;
|
|
742
|
+
const markupMultiplierNano = BigInt(Math.round(markup * 1e3));
|
|
743
|
+
billedNano = wholesaleNano * markupMultiplierNano / 1000n;
|
|
744
|
+
if (params.minimumChargeUSD !== void 0 && params.minimumChargeUSD > 0) {
|
|
745
|
+
const minChargeNano = BigInt(Math.round(params.minimumChargeUSD * 1e9));
|
|
746
|
+
if (billedNano < minChargeNano) {
|
|
747
|
+
billedNano = minChargeNano;
|
|
748
|
+
}
|
|
627
749
|
}
|
|
628
750
|
}
|
|
751
|
+
const inputCostUSD = Number(inputCostNano) / 1e9;
|
|
752
|
+
const outputCostUSD = Number(outputCostNano) / 1e9;
|
|
753
|
+
const reasoningCostUSD = Number(reasoningCostNano) / 1e9;
|
|
754
|
+
const cachedDiscountUSD = Number(cachedDiscountNano) / 1e9;
|
|
755
|
+
const totalUSD = Number(wholesaleNano) / 1e9;
|
|
756
|
+
const wholesaleTotalUSD = totalUSD;
|
|
757
|
+
const billedUSD = Number(billedNano) / 1e9;
|
|
758
|
+
const profitUSD = Math.max(0, billedUSD - wholesaleTotalUSD);
|
|
759
|
+
const retailUSD = hasRetail ? billedUSD : void 0;
|
|
629
760
|
return {
|
|
630
761
|
inputCostUSD: Number(inputCostUSD.toFixed(8)),
|
|
631
762
|
outputCostUSD: Number(outputCostUSD.toFixed(8)),
|
|
632
|
-
reasoningCostUSD: reasoningTokens >
|
|
633
|
-
cachedDiscountUSD: cachedTokens >
|
|
763
|
+
reasoningCostUSD: reasoningTokens > 0n ? Number(reasoningCostUSD.toFixed(8)) : void 0,
|
|
764
|
+
cachedDiscountUSD: cachedTokens > 0n ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
|
|
634
765
|
totalUSD: Number(totalUSD.toFixed(8)),
|
|
766
|
+
wholesaleTotalUSD: Number(wholesaleTotalUSD.toFixed(8)),
|
|
767
|
+
billedUSD: Number(billedUSD.toFixed(8)),
|
|
768
|
+
profitUSD: Number(profitUSD.toFixed(8)),
|
|
635
769
|
retailUSD: retailUSD !== void 0 ? Number(retailUSD.toFixed(8)) : void 0,
|
|
636
770
|
currency: rates.currency || "USD"
|
|
637
771
|
};
|
|
@@ -837,7 +971,7 @@ function wrapUniversalStream(stream, options = {}, onComplete) {
|
|
|
837
971
|
return wrapGeminiStream(stream, options, onComplete);
|
|
838
972
|
}
|
|
839
973
|
if (Symbol.asyncIterator in stream) {
|
|
840
|
-
if (options.provider === "anthropic") {
|
|
974
|
+
if (options.provider === "anthropic" || options.model?.toLowerCase().includes("claude")) {
|
|
841
975
|
return wrapAnthropicStream(stream, options, onComplete);
|
|
842
976
|
}
|
|
843
977
|
return wrapOpenAIStream(stream, options, onComplete);
|
|
@@ -859,7 +993,7 @@ var VibezMeter = class {
|
|
|
859
993
|
this.stripeClient = new import_stripe.default(key, {
|
|
860
994
|
appInfo: {
|
|
861
995
|
name: "vibezcheck",
|
|
862
|
-
version: "0.
|
|
996
|
+
version: "0.5.3",
|
|
863
997
|
url: "https://vibezcheck.xyz"
|
|
864
998
|
}
|
|
865
999
|
});
|