vibezcheck 0.5.0 → 0.5.4

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.
Files changed (74) hide show
  1. package/README.md +43 -24
  2. package/dist/ai-sdk/index.d.mts +4 -4
  3. package/dist/ai-sdk/index.d.ts +4 -4
  4. package/dist/ai-sdk/index.js +357 -43
  5. package/dist/ai-sdk/index.js.map +1 -1
  6. package/dist/ai-sdk/index.mjs +357 -43
  7. package/dist/ai-sdk/index.mjs.map +1 -1
  8. package/dist/ai-sdk/middleware.d.mts +3 -3
  9. package/dist/ai-sdk/middleware.d.ts +3 -3
  10. package/dist/ai-sdk/middleware.js +316 -44
  11. package/dist/ai-sdk/middleware.js.map +1 -1
  12. package/dist/ai-sdk/middleware.mjs +316 -44
  13. package/dist/ai-sdk/middleware.mjs.map +1 -1
  14. package/dist/billing/index.d.mts +3 -3
  15. package/dist/billing/index.d.ts +3 -3
  16. package/dist/billing/index.js +312 -42
  17. package/dist/billing/index.js.map +1 -1
  18. package/dist/billing/index.mjs +312 -42
  19. package/dist/billing/index.mjs.map +1 -1
  20. package/dist/cli/index.js +103 -29
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/cli/index.mjs +103 -29
  23. package/dist/cli/index.mjs.map +1 -1
  24. package/dist/{client-CJ2Dj8ID.d.ts → client-BORmJy8s.d.ts} +1 -1
  25. package/dist/{client-Dmwb3hQt.d.mts → client-CbuXmoXz.d.mts} +1 -1
  26. package/dist/compat/stripe-meter.d.mts +4 -4
  27. package/dist/compat/stripe-meter.d.ts +4 -4
  28. package/dist/compat/stripe-meter.js +336 -47
  29. package/dist/compat/stripe-meter.js.map +1 -1
  30. package/dist/compat/stripe-meter.mjs +336 -47
  31. package/dist/compat/stripe-meter.mjs.map +1 -1
  32. package/dist/compat/stripe-provider.d.mts +4 -24
  33. package/dist/compat/stripe-provider.d.ts +4 -24
  34. package/dist/compat/stripe-provider.js +498 -59
  35. package/dist/compat/stripe-provider.js.map +1 -1
  36. package/dist/compat/stripe-provider.mjs +505 -59
  37. package/dist/compat/stripe-provider.mjs.map +1 -1
  38. package/dist/compat/token-meter.d.mts +18 -6
  39. package/dist/compat/token-meter.d.ts +18 -6
  40. package/dist/compat/token-meter.js +343 -35
  41. package/dist/compat/token-meter.js.map +1 -1
  42. package/dist/compat/token-meter.mjs +343 -35
  43. package/dist/compat/token-meter.mjs.map +1 -1
  44. package/dist/customers/index.d.mts +1 -1
  45. package/dist/customers/index.d.ts +1 -1
  46. package/dist/index.d.mts +10 -7
  47. package/dist/index.d.ts +10 -7
  48. package/dist/index.js +672 -47
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +664 -47
  51. package/dist/index.mjs.map +1 -1
  52. package/dist/meter/index.d.mts +2 -2
  53. package/dist/meter/index.d.ts +2 -2
  54. package/dist/meter/index.js +220 -25
  55. package/dist/meter/index.js.map +1 -1
  56. package/dist/meter/index.mjs +220 -25
  57. package/dist/meter/index.mjs.map +1 -1
  58. package/dist/pricing/index.d.mts +11 -3
  59. package/dist/pricing/index.d.ts +11 -3
  60. package/dist/pricing/index.js +153 -8
  61. package/dist/pricing/index.js.map +1 -1
  62. package/dist/pricing/index.mjs +152 -8
  63. package/dist/pricing/index.mjs.map +1 -1
  64. package/dist/react/index.d.mts +6 -4
  65. package/dist/react/index.d.ts +6 -4
  66. package/dist/react/index.js +420 -200
  67. package/dist/react/index.js.map +1 -1
  68. package/dist/react/index.mjs +420 -200
  69. package/dist/react/index.mjs.map +1 -1
  70. package/dist/{types-BVGqbKnY.d.mts → types-6P71CXAD.d.mts} +10 -6
  71. package/dist/{types-BVGqbKnY.d.ts → types-6P71CXAD.d.ts} +10 -6
  72. package/dist/{with-billing-CDqKIAQ6.d.ts → with-billing-Bj6Ya_Iy.d.ts} +5 -3
  73. package/dist/{with-billing-mci2vtFS.d.mts → with-billing-DndWGxL8.d.mts} +5 -3
  74. package/package.json +10 -10
@@ -309,12 +309,38 @@ function extractOpenAIResponseUsage(response) {
309
309
  function inspectOpenAIStreamChunk(chunk) {
310
310
  if (!chunk || typeof chunk !== "object") return {};
311
311
  const model = chunk.model;
312
- if (chunk.usage) {
313
- const rawUsage = chunk.usage;
314
- const inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? 0;
315
- const outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? 0;
316
- const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? 0;
317
- const cachedTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.input_token_details?.cached_tokens ?? 0;
312
+ const rawUsage = (chunk.type === "finish" ? chunk.usage : null) || chunk.usage || chunk.token_usage || chunk.x_groq?.usage || chunk.usageMetadata;
313
+ if (rawUsage) {
314
+ let inputTokens = 0;
315
+ let outputTokens = 0;
316
+ let reasoningTokens = 0;
317
+ let cachedTokens = 0;
318
+ if (typeof rawUsage.inputTokens === "object" && rawUsage.inputTokens !== null) {
319
+ inputTokens = rawUsage.inputTokens.total ?? rawUsage.inputTokens.noCache ?? 0;
320
+ cachedTokens = rawUsage.inputTokens.cacheRead ?? 0;
321
+ } else if (typeof rawUsage.promptTokens === "number") {
322
+ inputTokens = rawUsage.promptTokens;
323
+ } else if (typeof rawUsage.inputTokens === "number") {
324
+ inputTokens = rawUsage.inputTokens;
325
+ } else {
326
+ inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokenCount ?? 0;
327
+ }
328
+ if (typeof rawUsage.outputTokens === "object" && rawUsage.outputTokens !== null) {
329
+ outputTokens = rawUsage.outputTokens.total ?? rawUsage.outputTokens.text ?? 0;
330
+ reasoningTokens = rawUsage.outputTokens.reasoning ?? 0;
331
+ } else if (typeof rawUsage.completionTokens === "number") {
332
+ outputTokens = rawUsage.completionTokens;
333
+ } else if (typeof rawUsage.outputTokens === "number") {
334
+ outputTokens = rawUsage.outputTokens;
335
+ } else {
336
+ outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.candidatesTokenCount ?? 0;
337
+ }
338
+ if (!reasoningTokens) {
339
+ reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? rawUsage.reasoning_tokens ?? rawUsage.reasoningTokens ?? rawUsage.thoughtsTokenCount ?? 0;
340
+ }
341
+ if (!cachedTokens) {
342
+ 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;
343
+ }
318
344
  return {
319
345
  model,
320
346
  usage: {
@@ -329,11 +355,11 @@ function inspectOpenAIStreamChunk(chunk) {
329
355
  }
330
356
  if (chunk.type === "response.completed" || chunk.type === "response.done") {
331
357
  if (chunk.response?.usage) {
332
- const rawUsage = chunk.response.usage;
333
- const inputTokens = rawUsage.input_tokens ?? 0;
334
- const outputTokens = rawUsage.output_tokens ?? 0;
335
- const reasoningTokens = rawUsage.output_token_details?.reasoning_tokens ?? 0;
336
- const cachedTokens = rawUsage.input_token_details?.cached_tokens ?? 0;
358
+ const rawUsage2 = chunk.response.usage;
359
+ const inputTokens = rawUsage2.input_tokens ?? 0;
360
+ const outputTokens = rawUsage2.output_tokens ?? 0;
361
+ const reasoningTokens = rawUsage2.output_token_details?.reasoning_tokens ?? 0;
362
+ const cachedTokens = rawUsage2.input_token_details?.cached_tokens ?? 0;
337
363
  return {
338
364
  model: chunk.response.model || model,
339
365
  usage: {
@@ -460,10 +486,36 @@ function extractGenericResponseUsage(response, fallbackModel = "generic-llm", fa
460
486
  if (!response || typeof response !== "object") return null;
461
487
  const usage = response.usage || response.token_usage || response.usageMetadata;
462
488
  if (usage) {
463
- const inputTokens = usage.prompt_tokens ?? usage.input_tokens ?? usage.promptTokenCount ?? usage.prompt_eval_count ?? 0;
464
- const outputTokens = usage.completion_tokens ?? usage.output_tokens ?? usage.candidatesTokenCount ?? usage.eval_count ?? 0;
465
- const reasoningTokens = usage.reasoning_tokens ?? usage.thoughtsTokenCount ?? usage.completion_tokens_details?.reasoning_tokens ?? 0;
466
- const cachedTokens = usage.prompt_tokens_details?.cached_tokens ?? usage.cached_tokens ?? usage.cachedContentTokenCount ?? 0;
489
+ let inputTokens = 0;
490
+ let outputTokens = 0;
491
+ let reasoningTokens = 0;
492
+ let cachedTokens = 0;
493
+ if (typeof usage.inputTokens === "object" && usage.inputTokens !== null) {
494
+ inputTokens = usage.inputTokens.total ?? usage.inputTokens.noCache ?? 0;
495
+ cachedTokens = usage.inputTokens.cacheRead ?? 0;
496
+ } else if (typeof usage.promptTokens === "number") {
497
+ inputTokens = usage.promptTokens;
498
+ } else if (typeof usage.inputTokens === "number") {
499
+ inputTokens = usage.inputTokens;
500
+ } else {
501
+ inputTokens = usage.prompt_tokens ?? usage.input_tokens ?? usage.promptTokenCount ?? usage.prompt_eval_count ?? 0;
502
+ }
503
+ if (typeof usage.outputTokens === "object" && usage.outputTokens !== null) {
504
+ outputTokens = usage.outputTokens.total ?? usage.outputTokens.text ?? 0;
505
+ reasoningTokens = usage.outputTokens.reasoning ?? 0;
506
+ } else if (typeof usage.completionTokens === "number") {
507
+ outputTokens = usage.completionTokens;
508
+ } else if (typeof usage.outputTokens === "number") {
509
+ outputTokens = usage.outputTokens;
510
+ } else {
511
+ outputTokens = usage.completion_tokens ?? usage.output_tokens ?? usage.candidatesTokenCount ?? usage.eval_count ?? 0;
512
+ }
513
+ if (!reasoningTokens) {
514
+ reasoningTokens = usage.reasoning_tokens ?? usage.thoughtsTokenCount ?? usage.completion_tokens_details?.reasoning_tokens ?? 0;
515
+ }
516
+ if (!cachedTokens) {
517
+ cachedTokens = usage.prompt_tokens_details?.cached_tokens ?? usage.cached_tokens ?? usage.cachedContentTokenCount ?? 0;
518
+ }
467
519
  const model = response.model || fallbackModel;
468
520
  const provider = response.provider || fallbackProvider;
469
521
  return {
@@ -498,7 +550,7 @@ function detectAndExtractUsage(response, fallbackModel, fallbackProvider) {
498
550
 
499
551
  // src/pricing/table.ts
500
552
  var MODEL_PRICING_TABLE = {
501
- // --- OpenAI ---
553
+ // --- OpenAI (Modern & Reasoning) ---
502
554
  "gpt-5.6-sol": { inputPer1M: 4, outputPer1M: 20, cachedInputPer1M: 0.4 },
503
555
  "gpt-5.6-terra": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.2 },
504
556
  "gpt-5.6-luna": { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },
@@ -510,11 +562,26 @@ var MODEL_PRICING_TABLE = {
510
562
  "o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },
511
563
  "gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cachedInputPer1M: 1.25 },
512
564
  "gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.075 },
565
+ "gpt-4.5": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
566
+ "gpt-4.5-preview": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
567
+ "chatgpt-4o-latest": { inputPer1M: 5, outputPer1M: 15 },
513
568
  "gpt-4.1": { inputPer1M: 2, outputPer1M: 8, cachedInputPer1M: 1 },
514
569
  "gpt-4.1-nano": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.05 },
570
+ "gpt-6-astra": { inputPer1M: 5, outputPer1M: 25, cachedInputPer1M: 0.5 },
571
+ "gpt-6-astra-fast": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
572
+ "gpt-image-2.5-flare": { inputPer1M: 0, outputPer1M: 0.04 },
573
+ "gpt-image-2.5-sunburst": { inputPer1M: 0, outputPer1M: 0.08 },
574
+ // --- OpenAI (Legacy & Backward Compatibility) ---
575
+ "gpt-4-turbo": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
576
+ "gpt-4-turbo-preview": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
577
+ "gpt-4": { inputPer1M: 30, outputPer1M: 60 },
578
+ "gpt-4-32k": { inputPer1M: 60, outputPer1M: 120 },
579
+ "gpt-3.5-turbo": { inputPer1M: 0.5, outputPer1M: 1.5 },
580
+ "gpt-3.5-turbo-16k": { inputPer1M: 3, outputPer1M: 4 },
515
581
  "text-embedding-3-small": { inputPer1M: 0.02, outputPer1M: 0 },
516
582
  "text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0 },
517
- // --- Anthropic ---
583
+ "text-embedding-ada-002": { inputPer1M: 0.1, outputPer1M: 0 },
584
+ // --- Anthropic (Modern & Extended Thinking) ---
518
585
  "claude-3-7-sonnet": { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },
519
586
  "claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.3 },
520
587
  "claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
@@ -522,48 +589,172 @@ var MODEL_PRICING_TABLE = {
522
589
  "haiku-4.5": { inputPer1M: 1, outputPer1M: 5, cachedInputPer1M: 0.1 },
523
590
  "claude-opus-5": { inputPer1M: 5, outputPer1M: 25, cachedInputPer1M: 1.5 },
524
591
  "claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cachedInputPer1M: 1.5 },
525
- // --- Google Gemini ---
592
+ // --- Anthropic (Legacy & Backward Compatibility) ---
593
+ "claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
594
+ "claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cachedInputPer1M: 0.025 },
595
+ "claude-2.1": { inputPer1M: 8, outputPer1M: 24 },
596
+ "claude-2.0": { inputPer1M: 8, outputPer1M: 24 },
597
+ "claude-instant-1.2": { inputPer1M: 1.63, outputPer1M: 5.51 },
598
+ // --- Google Gemini (Modern & Thoughts) ---
526
599
  "gemini-3.7-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },
527
600
  "gemini-3.1-pro": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.5 },
528
601
  "gemini-3.5-flash": { inputPer1M: 1.5, outputPer1M: 9, cachedInputPer1M: 0.38 },
529
602
  "gemini-3.1-flash-lite": { inputPer1M: 0.25, outputPer1M: 1.5, cachedInputPer1M: 0.06 },
603
+ "gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
604
+ "gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.0375 },
530
605
  "gemini-2.0-flash": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.025 },
606
+ "gemini-2.0-flash-lite": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
607
+ "gemini-2.0-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
608
+ // --- Google Gemini (Legacy & Backward Compatibility) ---
531
609
  "gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
532
610
  "gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
611
+ "gemini-1.5-flash-8b": { inputPer1M: 0.0375, outputPer1M: 0.15, cachedInputPer1M: 9375e-6 },
612
+ "gemini-1.0-pro": { inputPer1M: 0.5, outputPer1M: 1.5 },
533
613
  // --- xAI Grok ---
534
614
  "grok-4.6": { inputPer1M: 3, outputPer1M: 15 },
615
+ "grok-3": { inputPer1M: 3, outputPer1M: 15 },
616
+ "grok-3-mini": { inputPer1M: 0.3, outputPer1M: 1.5 },
535
617
  "grok-2": { inputPer1M: 2, outputPer1M: 10 },
536
618
  "grok-2-vision": { inputPer1M: 2, outputPer1M: 10 },
537
619
  "grok-beta": { inputPer1M: 5, outputPer1M: 15 },
538
620
  // --- Mistral ---
539
621
  "mistral-large-3": { inputPer1M: 2, outputPer1M: 6 },
540
622
  "mistral-large-latest": { inputPer1M: 2, outputPer1M: 6 },
623
+ "mistral-large-2411": { inputPer1M: 2, outputPer1M: 6 },
541
624
  "codestral-latest": { inputPer1M: 0.3, outputPer1M: 0.9 },
625
+ "mistral-medium-latest": { inputPer1M: 2.7, outputPer1M: 8.1 },
626
+ "mistral-medium-3-5": { inputPer1M: 2, outputPer1M: 6, cachedInputPer1M: 0.4 },
627
+ "mistral-medium-2604": { inputPer1M: 2, outputPer1M: 6, cachedInputPer1M: 0.4 },
628
+ "magistral-small-latest": { inputPer1M: 0.5, outputPer1M: 1.5, cachedInputPer1M: 0.1 },
629
+ "magistral-medium-latest": { inputPer1M: 2, outputPer1M: 6, cachedInputPer1M: 0.4 },
542
630
  "mistral-small-latest": { inputPer1M: 0.2, outputPer1M: 0.6 },
631
+ "mistral-small-2603": { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },
632
+ "mistral-vibe-cli-fast": { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },
633
+ "mistral-vibe-cli-latest": { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },
634
+ "codestral-2508": { inputPer1M: 0.3, outputPer1M: 0.9, cachedInputPer1M: 0.08 },
635
+ "codestral-embed": { inputPer1M: 0.1, outputPer1M: 0 },
636
+ "mistral-embed-2312": { inputPer1M: 0.1, outputPer1M: 0 },
637
+ "zai-glm-5-2": { inputPer1M: 0.6, outputPer1M: 2.2, cachedInputPer1M: 0.15 },
638
+ "glm-5-2": { inputPer1M: 0.6, outputPer1M: 2.2, cachedInputPer1M: 0.15 },
639
+ "labs-leanstral-1-5": { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },
543
640
  "ministral-8b-latest": { inputPer1M: 0.1, outputPer1M: 0.1 },
544
- // --- Groq LPUs ---
641
+ "ministral-3b-latest": { inputPer1M: 0.04, outputPer1M: 0.04 },
642
+ "open-mistral-7b": { inputPer1M: 0.2, outputPer1M: 0.2 },
643
+ "open-mixtral-8x7b": { inputPer1M: 0.7, outputPer1M: 0.7 },
644
+ "open-mixtral-8x22b": { inputPer1M: 2, outputPer1M: 6 },
645
+ // --- Groq & Meta Llama LPUs ---
545
646
  "llama-3.3-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
647
+ "llama-3.1-405b": { inputPer1M: 3, outputPer1M: 3 },
648
+ "llama-3.1-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
546
649
  "llama-3.1-8b-instant": { inputPer1M: 0.05, outputPer1M: 0.08 },
650
+ "llama-3.2-1b-preview": { inputPer1M: 0.04, outputPer1M: 0.04 },
651
+ "llama-3.2-3b-preview": { inputPer1M: 0.06, outputPer1M: 0.06 },
652
+ "llama-3.2-11b-vision": { inputPer1M: 0.18, outputPer1M: 0.18 },
653
+ "llama-3.2-90b-vision": { inputPer1M: 0.9, outputPer1M: 0.9 },
547
654
  "deepseek-r1-distill-llama-70b": { inputPer1M: 0.75, outputPer1M: 0.99 },
655
+ "deepseek-r1-distill-qwen-32b": { inputPer1M: 0.49, outputPer1M: 0.49 },
548
656
  "qwen-2.5-32b": { inputPer1M: 0.29, outputPer1M: 0.39 },
657
+ "qwen-2.5-72b": { inputPer1M: 0.35, outputPer1M: 0.4 },
658
+ "mixtral-8x7b-32768": { inputPer1M: 0.24, outputPer1M: 0.24 },
659
+ "gemma2-9b-it": { inputPer1M: 0.2, outputPer1M: 0.2 },
549
660
  // --- DeepSeek ---
550
661
  "deepseek-v4-pro": { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },
662
+ "deepseek-v4.1-flash": { inputPer1M: 0.2, outputPer1M: 0.6, cachedInputPer1M: 0.05 },
551
663
  "deepseek-v4-flash": { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },
552
- "deepseek-chat": { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },
553
- "deepseek-reasoner": { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },
664
+ "deepseek-v3": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
665
+ "deepseek-chat": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
666
+ "deepseek-r1": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
667
+ "deepseek-reasoner": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
668
+ // --- Gateway, Inception & InclusionAI Models ---
669
+ "mercury-2.5": { inputPer1M: 0.25, outputPer1M: 0.75, cachedInputPer1M: 0.05 },
670
+ "mercury-2": { inputPer1M: 0.25, outputPer1M: 0.75, cachedInputPer1M: 0.05 },
671
+ "ling-3.0-flash-sante": { inputPer1M: 0.15, outputPer1M: 0.45, cachedInputPer1M: 0.03 },
672
+ "ling-3.0-flash": { inputPer1M: 0.15, outputPer1M: 0.45, cachedInputPer1M: 0.03 },
554
673
  // --- Cohere ---
555
674
  "command-r-plus": { inputPer1M: 2.5, outputPer1M: 10 },
556
- "command-r": { inputPer1M: 0.15, outputPer1M: 0.6 }
675
+ "command-r": { inputPer1M: 0.15, outputPer1M: 0.6 },
676
+ "command": { inputPer1M: 1, outputPer1M: 2 },
677
+ "command-light": { inputPer1M: 0.3, outputPer1M: 0.6 },
678
+ "embed-english-v3.0": { inputPer1M: 0.1, outputPer1M: 0 },
679
+ // --- Perplexity ---
680
+ "sonar": { inputPer1M: 1, outputPer1M: 1 },
681
+ "sonar-pro": { inputPer1M: 3, outputPer1M: 15 },
682
+ "sonar-reasoning": { inputPer1M: 1, outputPer1M: 5 },
683
+ "sonar-reasoning-pro": { inputPer1M: 2, outputPer1M: 8 }
684
+ };
685
+ var MODEL_ALIASES = {
686
+ // OpenAI Shorthands & Aliases
687
+ "gpt4": "gpt-4",
688
+ "gpt4o": "gpt-4o",
689
+ "gpt-4-preview": "gpt-4-turbo",
690
+ "gpt-4-0125-preview": "gpt-4-turbo",
691
+ "gpt-4-1106-preview": "gpt-4-turbo",
692
+ "gpt-3.5": "gpt-3.5-turbo",
693
+ "gpt-3.5-turbo-0125": "gpt-3.5-turbo",
694
+ "gpt-3.5-turbo-1106": "gpt-3.5-turbo",
695
+ "gpt-3.5-turbo-16k-0613": "gpt-3.5-turbo-16k",
696
+ // Anthropic Shorthands
697
+ "sonnet": "claude-3-5-sonnet",
698
+ "sonnet-3.7": "claude-3-7-sonnet",
699
+ "sonnet-3.5": "claude-3-5-sonnet",
700
+ "haiku": "claude-3-5-haiku",
701
+ "haiku-3.5": "claude-3-5-haiku",
702
+ "opus": "claude-3-opus",
703
+ "claude-2": "claude-2.0",
704
+ "claude-instant": "claude-instant-1.2",
705
+ // DeepSeek Shorthands
706
+ "r1": "deepseek-r1",
707
+ "v3": "deepseek-v3",
708
+ // Gemini Shorthands
709
+ "flash": "gemini-2.0-flash",
710
+ "pro": "gemini-1.5-pro",
711
+ // Meta / Groq Shorthands
712
+ "llama-3.3-70b": "llama-3.3-70b-versatile",
713
+ "llama-3.1-70b": "llama-3.1-70b-versatile",
714
+ "llama-3.1-8b": "llama-3.1-8b-instant",
715
+ "llama-3-70b": "llama-3.1-70b-versatile",
716
+ "llama-3-8b": "llama-3.1-8b-instant",
717
+ // Mistral Shorthands
718
+ "codestral": "codestral-latest",
719
+ "mistral-large": "mistral-large-latest",
720
+ "mistral-small": "mistral-small-latest",
721
+ "magistral": "magistral-small-latest",
722
+ "magistral-small": "magistral-small-latest",
723
+ "magistral-medium": "magistral-medium-latest",
724
+ "mistral-3.5": "mistral-medium-3-5",
725
+ "mistral-medium-3.5": "mistral-medium-3-5",
726
+ "gpt-image-2.5": "gpt-image-2.5-flare",
727
+ "gpt-image-sunburst": "gpt-image-2.5-sunburst",
728
+ "gpt-image-flare": "gpt-image-2.5-flare"
557
729
  };
558
730
  var customPricingRegistry = {};
559
731
  function normalizeModelKey(rawModel) {
560
732
  if (!rawModel) return "unknown";
561
733
  let model = rawModel.toLowerCase().trim();
734
+ model = model.replace(/^[a-z0-9_-]+\.(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
735
+ model = model.replace(/^(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
736
+ model = model.replace(/-v\d+(:\d+)?$/, "");
737
+ model = model.replace(/:\d+$/, "");
562
738
  if (model.includes("/")) {
563
- model = model.split("/")[1] || model;
739
+ model = model.split("/").slice(1).join("/");
564
740
  }
741
+ model = model.replace(/:(latest|free|beta)$/, "");
565
742
  model = model.replace(/-\d{8}$/, "");
566
743
  model = model.replace(/-\d{4}-\d{2}-\d{2}$/, "");
744
+ model = model.replace(/llama(\d+)-(\d+)-/g, "llama-$1.$2-");
745
+ model = model.replace(/llama(\d+)\.(\d+)-/g, "llama-$1.$2-");
746
+ if (MODEL_ALIASES[model]) {
747
+ return MODEL_ALIASES[model];
748
+ }
749
+ if (!MODEL_PRICING_TABLE[model]) {
750
+ const withoutInstruct = model.replace(/-(instruct|chat|preview)$/, "");
751
+ if (MODEL_PRICING_TABLE[withoutInstruct]) {
752
+ return withoutInstruct;
753
+ }
754
+ if (MODEL_ALIASES[withoutInstruct]) {
755
+ return MODEL_ALIASES[withoutInstruct];
756
+ }
757
+ }
567
758
  return model;
568
759
  }
569
760
  function getModelPricing(modelName) {
@@ -580,6 +771,10 @@ function getModelPricing(modelName) {
580
771
  if (MODEL_PRICING_TABLE[modelName]) {
581
772
  return MODEL_PRICING_TABLE[modelName];
582
773
  }
774
+ const alias = MODEL_ALIASES[modelName.toLowerCase().trim()];
775
+ if (alias && MODEL_PRICING_TABLE[alias]) {
776
+ return MODEL_PRICING_TABLE[alias];
777
+ }
583
778
  return {
584
779
  inputPer1M: 1,
585
780
  outputPer1M: 3,
@@ -858,7 +1053,7 @@ function wrapUniversalStream(stream, options = {}, onComplete) {
858
1053
  return wrapGeminiStream(stream, options, onComplete);
859
1054
  }
860
1055
  if (Symbol.asyncIterator in stream) {
861
- if (options.provider === "anthropic") {
1056
+ if (options.provider === "anthropic" || options.model?.toLowerCase().includes("claude")) {
862
1057
  return wrapAnthropicStream(stream, options, onComplete);
863
1058
  }
864
1059
  return wrapOpenAIStream(stream, options, onComplete);
@@ -880,7 +1075,7 @@ var VibezMeter = class {
880
1075
  this.stripeClient = new import_stripe.default(key, {
881
1076
  appInfo: {
882
1077
  name: "vibezcheck",
883
- version: "0.5.0",
1078
+ version: "0.5.3",
884
1079
  url: "https://vibezcheck.xyz"
885
1080
  }
886
1081
  });
@@ -987,10 +1182,20 @@ function createMeter(options = {}) {
987
1182
  }
988
1183
 
989
1184
  // src/ai-sdk/with-billing.ts
990
- function withBilling(model, options = {}) {
1185
+ function withBilling(model, optionsOrCustomer, extraOptions = {}) {
991
1186
  if (!model || typeof model !== "object") {
992
1187
  return model;
993
1188
  }
1189
+ let options = {};
1190
+ if (typeof optionsOrCustomer === "string") {
1191
+ options = { ...extraOptions, customer: optionsOrCustomer };
1192
+ } else if (typeof optionsOrCustomer === "object" && optionsOrCustomer !== null) {
1193
+ if ("userId" in optionsOrCustomer || "email" in optionsOrCustomer || "id" in optionsOrCustomer) {
1194
+ options = { ...extraOptions, customer: optionsOrCustomer };
1195
+ } else {
1196
+ options = { ...optionsOrCustomer, ...extraOptions };
1197
+ }
1198
+ }
994
1199
  const meter = options.meter || createMeter({
995
1200
  apiKey: options.stripeApiKey,
996
1201
  eventName: options.eventName
@@ -1019,17 +1224,49 @@ function withBilling(model, options = {}) {
1019
1224
  };
1020
1225
  const handleUsage = (rawUsage, extraMeta) => {
1021
1226
  if (!rawUsage) return;
1022
- const inputTokens = rawUsage.promptTokens ?? rawUsage.inputTokens ?? 0;
1023
- const outputTokens = rawUsage.completionTokens ?? rawUsage.outputTokens ?? 0;
1024
- const reasoningTokens = rawUsage.reasoningTokens ?? rawUsage.completionTokensDetails?.reasoningTokens ?? rawUsage.outputTokenDetails?.reasoningTokens ?? 0;
1025
- const cachedTokens = rawUsage.promptTokensDetails?.cachedTokens ?? rawUsage.inputTokenDetails?.cachedTokens ?? 0;
1227
+ let inputTokens = 0;
1228
+ let outputTokens = 0;
1229
+ let reasoningTokens = 0;
1230
+ let cachedTokens = 0;
1231
+ let cacheWriteTokens = 0;
1232
+ if (typeof rawUsage.inputTokens === "object" && rawUsage.inputTokens !== null) {
1233
+ inputTokens = rawUsage.inputTokens.total ?? rawUsage.inputTokens.noCache ?? 0;
1234
+ cachedTokens = rawUsage.inputTokens.cacheRead ?? 0;
1235
+ cacheWriteTokens = rawUsage.inputTokens.cacheWrite ?? 0;
1236
+ } else if (typeof rawUsage.promptTokens === "number") {
1237
+ inputTokens = rawUsage.promptTokens;
1238
+ } else if (typeof rawUsage.inputTokens === "number") {
1239
+ inputTokens = rawUsage.inputTokens;
1240
+ } else {
1241
+ inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokenCount ?? 0;
1242
+ }
1243
+ if (typeof rawUsage.outputTokens === "object" && rawUsage.outputTokens !== null) {
1244
+ outputTokens = rawUsage.outputTokens.total ?? rawUsage.outputTokens.text ?? 0;
1245
+ reasoningTokens = rawUsage.outputTokens.reasoning ?? 0;
1246
+ } else if (typeof rawUsage.completionTokens === "number") {
1247
+ outputTokens = rawUsage.completionTokens;
1248
+ } else if (typeof rawUsage.outputTokens === "number") {
1249
+ outputTokens = rawUsage.outputTokens;
1250
+ } else {
1251
+ outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.candidatesTokenCount ?? 0;
1252
+ }
1253
+ if (!reasoningTokens) {
1254
+ reasoningTokens = rawUsage.reasoningTokens ?? rawUsage.completionTokensDetails?.reasoningTokens ?? rawUsage.outputTokenDetails?.reasoningTokens ?? rawUsage.reasoning_tokens ?? rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? rawUsage.thoughtsTokenCount ?? 0;
1255
+ }
1256
+ if (!cachedTokens) {
1257
+ cachedTokens = rawUsage.promptTokensDetails?.cachedTokens ?? rawUsage.inputTokenDetails?.cachedTokens ?? rawUsage.cachedTokens ?? rawUsage.cached_tokens ?? rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.input_token_details?.cached_tokens ?? rawUsage.cachedContentTokenCount ?? rawUsage.cache_read_input_tokens ?? 0;
1258
+ }
1259
+ if (!cacheWriteTokens) {
1260
+ cacheWriteTokens = rawUsage.cacheWriteTokens ?? rawUsage.cache_creation_input_tokens ?? rawUsage.cacheCreationTokens ?? 0;
1261
+ }
1026
1262
  const usage = {
1027
1263
  inputTokens,
1028
1264
  outputTokens,
1029
1265
  totalTokens: inputTokens + outputTokens,
1030
1266
  reasoningTokens: reasoningTokens > 0 ? reasoningTokens : void 0,
1031
1267
  visibleOutputTokens: Math.max(0, outputTokens - reasoningTokens),
1032
- cachedTokens: cachedTokens > 0 ? cachedTokens : void 0
1268
+ cachedTokens: cachedTokens > 0 ? cachedTokens : void 0,
1269
+ cacheWriteTokens: cacheWriteTokens > 0 ? cacheWriteTokens : void 0
1033
1270
  };
1034
1271
  const cost = calculateUsageCost(modelId, usage, {
1035
1272
  markupMultiplier: options.pricing?.margin,
@@ -1130,7 +1367,9 @@ function withBilling(model, options = {}) {
1130
1367
  return;
1131
1368
  }
1132
1369
  } catch (err) {
1133
- console.warn(`[vibezcheck] Database record failed safely:`, err?.message || err);
1370
+ if (process.env.NODE_ENV !== "test" && !options.silent) {
1371
+ console.warn(`[vibezcheck] Database record failed safely:`, err?.message || err);
1372
+ }
1134
1373
  }
1135
1374
  };
1136
1375
  if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
@@ -1146,7 +1385,9 @@ function withBilling(model, options = {}) {
1146
1385
  try {
1147
1386
  await chargeFn(cost.totalUSD, event);
1148
1387
  } catch (err) {
1149
- console.warn(`[vibezcheck] Custom charge handler failed safely:`, err?.message || err);
1388
+ if (process.env.NODE_ENV !== "test" && !options.silent) {
1389
+ console.warn(`[vibezcheck] Custom charge handler failed safely:`, err?.message || err);
1390
+ }
1150
1391
  }
1151
1392
  };
1152
1393
  if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
@@ -1161,7 +1402,9 @@ function withBilling(model, options = {}) {
1161
1402
  try {
1162
1403
  await providerCharge(cost.totalUSD, event);
1163
1404
  } catch (err) {
1164
- console.warn(`[vibezcheck] Payment provider charge failed safely:`, err?.message || err);
1405
+ if (process.env.NODE_ENV !== "test" && !options.silent) {
1406
+ console.warn(`[vibezcheck] Payment provider charge failed safely:`, err?.message || err);
1407
+ }
1165
1408
  }
1166
1409
  };
1167
1410
  if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
@@ -1216,14 +1459,25 @@ function withBilling(model, options = {}) {
1216
1459
  const transformStream = new TransformStream({
1217
1460
  transform(chunk, controller) {
1218
1461
  controller.enqueue(chunk);
1219
- if (chunk.type === "text-delta" && chunk.textDelta) {
1220
- accumulatedChars += chunk.textDelta.length;
1221
- } else if (chunk.type === "reasoning" && (chunk.textDelta || chunk.reasoning)) {
1222
- accumulatedChars += (chunk.textDelta || chunk.reasoning || "").length;
1462
+ if (chunk.type === "text-delta" && typeof chunk.delta === "string") {
1463
+ accumulatedChars += chunk.delta.length;
1464
+ } else if (chunk.type === "reasoning-delta" && typeof chunk.delta === "string") {
1465
+ accumulatedChars += chunk.delta.length;
1466
+ } else {
1467
+ const delta = chunk.textDelta || chunk.text || chunk.delta;
1468
+ if (delta && typeof delta === "string") {
1469
+ accumulatedChars += delta.length;
1470
+ } else if (chunk.type === "reasoning" || chunk.type === "reasoning-delta") {
1471
+ const reasoning = chunk.reasoning || chunk.textDelta || chunk.text || chunk.delta || "";
1472
+ if (typeof reasoning === "string") {
1473
+ accumulatedChars += reasoning.length;
1474
+ }
1475
+ }
1223
1476
  }
1224
- if (chunk.type === "finish" && chunk.usage) {
1477
+ const chunkUsage = (chunk.type === "finish" ? chunk.usage : null) || chunk.usage || chunk.token_usage || chunk.usageMetadata;
1478
+ if (chunkUsage) {
1225
1479
  streamCompleted = true;
1226
- handleUsage(chunk.usage);
1480
+ handleUsage(chunkUsage);
1227
1481
  }
1228
1482
  },
1229
1483
  flush() {
@@ -1249,13 +1503,29 @@ function withBilling(model, options = {}) {
1249
1503
  if (prop === "doGenerate" && typeof originalValue === "function") {
1250
1504
  return async function(...args) {
1251
1505
  const result = await originalValue.apply(target, args);
1252
- if (result && result.usage) {
1253
- handleUsage(result.usage);
1506
+ const usage = result?.usage || result?.tokenUsage || result?.usageMetadata;
1507
+ if (usage) {
1508
+ handleUsage(usage);
1254
1509
  }
1255
1510
  return result;
1256
1511
  };
1257
1512
  }
1258
1513
  return originalValue;
1514
+ },
1515
+ apply(target, thisArg, argArray) {
1516
+ if (typeof target === "function") {
1517
+ return Reflect.apply(target, thisArg, argArray);
1518
+ }
1519
+ return target;
1520
+ },
1521
+ has(target, prop) {
1522
+ return Reflect.has(target, prop);
1523
+ },
1524
+ ownKeys(target) {
1525
+ return Reflect.ownKeys(target);
1526
+ },
1527
+ getPrototypeOf(target) {
1528
+ return Reflect.getPrototypeOf(target);
1259
1529
  }
1260
1530
  };
1261
1531
  return new Proxy(model, handler);
@@ -1279,8 +1549,22 @@ function createVibezModel(modelOrId, options = {}) {
1279
1549
  providerName = "anthropic";
1280
1550
  } else if (rawId.startsWith("gemini-")) {
1281
1551
  providerName = "google";
1552
+ } else if (rawId.startsWith("deepseek-")) {
1553
+ providerName = "deepseek";
1554
+ } else if (rawId.startsWith("grok-")) {
1555
+ providerName = "xai";
1556
+ } else if (rawId.startsWith("mistral-") || rawId.startsWith("codestral-") || rawId.startsWith("ministral-") || rawId.startsWith("magistral-") || rawId.startsWith("voxtral-") || rawId.startsWith("devstral-") || rawId.startsWith("open-mistral") || rawId.startsWith("open-mixtral")) {
1557
+ providerName = "mistral";
1558
+ } else if (rawId.startsWith("llama-") || rawId.startsWith("mixtral-") || rawId.startsWith("gemma") || rawId.startsWith("qwen-")) {
1559
+ providerName = "groq";
1560
+ } else if (rawId.startsWith("command-")) {
1561
+ providerName = "cohere";
1562
+ } else if (rawId.startsWith("mercury-") || rawId.startsWith("ling-")) {
1563
+ providerName = "gateway";
1564
+ } else if (rawId.startsWith("gpt-image-") || rawId.startsWith("gpt-6-")) {
1565
+ providerName = "openai";
1282
1566
  }
1283
- const apiKey = options.apiKey || process.env.AI_GATEWAY_API_KEY || (providerName === "anthropic" ? process.env.ANTHROPIC_API_KEY : void 0) || (providerName === "google" ? process.env.GOOGLE_GENERATIVE_AI_API_KEY : void 0) || process.env.OPENAI_API_KEY;
1567
+ const apiKey = options.apiKey || process.env.AI_GATEWAY_API_KEY || (providerName === "anthropic" ? process.env.ANTHROPIC_API_KEY : void 0) || (providerName === "google" ? process.env.GOOGLE_GENERATIVE_AI_API_KEY : void 0) || (providerName === "mistral" ? process.env.MISTRAL_API_KEY : void 0) || (providerName === "groq" ? process.env.GROQ_API_KEY : void 0) || (providerName === "deepseek" ? process.env.DEEPSEEK_API_KEY : void 0) || (providerName === "xai" ? process.env.XAI_API_KEY : void 0) || (providerName === "cohere" ? process.env.COHERE_API_KEY : void 0) || process.env.OPENAI_API_KEY;
1284
1568
  const baseURL = options.baseURL || process.env.AI_GATEWAY_BASE_URL || (providerName === "openai" ? "https://api.openai.com/v1" : void 0);
1285
1569
  let baseModelInstance = null;
1286
1570
  try {
@@ -1317,6 +1601,36 @@ function createVibezModel(modelOrId, options = {}) {
1317
1601
  baseModelInstance = factory(cleanModelId);
1318
1602
  }
1319
1603
  }
1604
+ } else if (providerName === "mistral") {
1605
+ const mod = require("@ai-sdk/mistral");
1606
+ const factory = mod.createMistral || mod.mistral || mod.default?.createMistral || mod.default?.mistral;
1607
+ if (typeof factory === "function") {
1608
+ baseModelInstance = mod.createMistral ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
1609
+ }
1610
+ } else if (providerName === "groq") {
1611
+ const mod = require("@ai-sdk/groq");
1612
+ const factory = mod.createGroq || mod.groq || mod.default?.createGroq || mod.default?.groq;
1613
+ if (typeof factory === "function") {
1614
+ baseModelInstance = mod.createGroq ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
1615
+ }
1616
+ } else if (providerName === "deepseek") {
1617
+ const mod = require("@ai-sdk/deepseek");
1618
+ const factory = mod.createDeepSeek || mod.deepseek || mod.default?.createDeepSeek || mod.default?.deepseek;
1619
+ if (typeof factory === "function") {
1620
+ baseModelInstance = mod.createDeepSeek ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
1621
+ }
1622
+ } else if (providerName === "xai") {
1623
+ const mod = require("@ai-sdk/xai");
1624
+ const factory = mod.createXai || mod.xai || mod.default?.createXai || mod.default?.xai;
1625
+ if (typeof factory === "function") {
1626
+ baseModelInstance = mod.createXai ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
1627
+ }
1628
+ } else if (providerName === "cohere") {
1629
+ const mod = require("@ai-sdk/cohere");
1630
+ const factory = mod.createCohere || mod.cohere || mod.default?.createCohere || mod.default?.cohere;
1631
+ if (typeof factory === "function") {
1632
+ baseModelInstance = mod.createCohere ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
1633
+ }
1320
1634
  }
1321
1635
  } catch {
1322
1636
  baseModelInstance = {