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/ai-sdk/index.js
CHANGED
|
@@ -309,12 +309,12 @@ function extractOpenAIResponseUsage(response) {
|
|
|
309
309
|
function inspectOpenAIStreamChunk(chunk) {
|
|
310
310
|
if (!chunk || typeof chunk !== "object") return {};
|
|
311
311
|
const model = chunk.model;
|
|
312
|
-
|
|
313
|
-
|
|
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.usage || chunk.token_usage || chunk.x_groq?.usage || chunk.usageMetadata;
|
|
313
|
+
if (rawUsage) {
|
|
314
|
+
const inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokens ?? rawUsage.inputTokens ?? rawUsage.promptTokenCount ?? 0;
|
|
315
|
+
const outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.completionTokens ?? rawUsage.outputTokens ?? rawUsage.candidatesTokenCount ?? 0;
|
|
316
|
+
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? rawUsage.reasoning_tokens ?? rawUsage.reasoningTokens ?? rawUsage.thoughtsTokenCount ?? 0;
|
|
317
|
+
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;
|
|
318
318
|
return {
|
|
319
319
|
model,
|
|
320
320
|
usage: {
|
|
@@ -329,11 +329,11 @@ function inspectOpenAIStreamChunk(chunk) {
|
|
|
329
329
|
}
|
|
330
330
|
if (chunk.type === "response.completed" || chunk.type === "response.done") {
|
|
331
331
|
if (chunk.response?.usage) {
|
|
332
|
-
const
|
|
333
|
-
const inputTokens =
|
|
334
|
-
const outputTokens =
|
|
335
|
-
const reasoningTokens =
|
|
336
|
-
const cachedTokens =
|
|
332
|
+
const rawUsage2 = chunk.response.usage;
|
|
333
|
+
const inputTokens = rawUsage2.input_tokens ?? 0;
|
|
334
|
+
const outputTokens = rawUsage2.output_tokens ?? 0;
|
|
335
|
+
const reasoningTokens = rawUsage2.output_token_details?.reasoning_tokens ?? 0;
|
|
336
|
+
const cachedTokens = rawUsage2.input_token_details?.cached_tokens ?? 0;
|
|
337
337
|
return {
|
|
338
338
|
model: chunk.response.model || model,
|
|
339
339
|
usage: {
|
|
@@ -498,7 +498,7 @@ function detectAndExtractUsage(response, fallbackModel, fallbackProvider) {
|
|
|
498
498
|
|
|
499
499
|
// src/pricing/table.ts
|
|
500
500
|
var MODEL_PRICING_TABLE = {
|
|
501
|
-
// --- OpenAI ---
|
|
501
|
+
// --- OpenAI (Modern & Reasoning) ---
|
|
502
502
|
"gpt-5.6-sol": { inputPer1M: 4, outputPer1M: 20, cachedInputPer1M: 0.4 },
|
|
503
503
|
"gpt-5.6-terra": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.2 },
|
|
504
504
|
"gpt-5.6-luna": { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },
|
|
@@ -510,11 +510,22 @@ var MODEL_PRICING_TABLE = {
|
|
|
510
510
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },
|
|
511
511
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cachedInputPer1M: 1.25 },
|
|
512
512
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.075 },
|
|
513
|
+
"gpt-4.5": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
|
|
514
|
+
"gpt-4.5-preview": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
|
|
515
|
+
"chatgpt-4o-latest": { inputPer1M: 5, outputPer1M: 15 },
|
|
513
516
|
"gpt-4.1": { inputPer1M: 2, outputPer1M: 8, cachedInputPer1M: 1 },
|
|
514
517
|
"gpt-4.1-nano": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.05 },
|
|
518
|
+
// --- OpenAI (Legacy & Backward Compatibility) ---
|
|
519
|
+
"gpt-4-turbo": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
|
|
520
|
+
"gpt-4-turbo-preview": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
|
|
521
|
+
"gpt-4": { inputPer1M: 30, outputPer1M: 60 },
|
|
522
|
+
"gpt-4-32k": { inputPer1M: 60, outputPer1M: 120 },
|
|
523
|
+
"gpt-3.5-turbo": { inputPer1M: 0.5, outputPer1M: 1.5 },
|
|
524
|
+
"gpt-3.5-turbo-16k": { inputPer1M: 3, outputPer1M: 4 },
|
|
515
525
|
"text-embedding-3-small": { inputPer1M: 0.02, outputPer1M: 0 },
|
|
516
526
|
"text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0 },
|
|
517
|
-
|
|
527
|
+
"text-embedding-ada-002": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
528
|
+
// --- Anthropic (Modern & Extended Thinking) ---
|
|
518
529
|
"claude-3-7-sonnet": { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },
|
|
519
530
|
"claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.3 },
|
|
520
531
|
"claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
@@ -522,48 +533,145 @@ var MODEL_PRICING_TABLE = {
|
|
|
522
533
|
"haiku-4.5": { inputPer1M: 1, outputPer1M: 5, cachedInputPer1M: 0.1 },
|
|
523
534
|
"claude-opus-5": { inputPer1M: 5, outputPer1M: 25, cachedInputPer1M: 1.5 },
|
|
524
535
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cachedInputPer1M: 1.5 },
|
|
525
|
-
// ---
|
|
536
|
+
// --- Anthropic (Legacy & Backward Compatibility) ---
|
|
537
|
+
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
538
|
+
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cachedInputPer1M: 0.025 },
|
|
539
|
+
"claude-2.1": { inputPer1M: 8, outputPer1M: 24 },
|
|
540
|
+
"claude-2.0": { inputPer1M: 8, outputPer1M: 24 },
|
|
541
|
+
"claude-instant-1.2": { inputPer1M: 1.63, outputPer1M: 5.51 },
|
|
542
|
+
// --- Google Gemini (Modern & Thoughts) ---
|
|
526
543
|
"gemini-3.7-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },
|
|
527
544
|
"gemini-3.1-pro": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.5 },
|
|
528
545
|
"gemini-3.5-flash": { inputPer1M: 1.5, outputPer1M: 9, cachedInputPer1M: 0.38 },
|
|
529
546
|
"gemini-3.1-flash-lite": { inputPer1M: 0.25, outputPer1M: 1.5, cachedInputPer1M: 0.06 },
|
|
547
|
+
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
548
|
+
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.0375 },
|
|
530
549
|
"gemini-2.0-flash": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.025 },
|
|
550
|
+
"gemini-2.0-flash-lite": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
|
|
551
|
+
"gemini-2.0-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
552
|
+
// --- Google Gemini (Legacy & Backward Compatibility) ---
|
|
531
553
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
532
554
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
|
|
555
|
+
"gemini-1.5-flash-8b": { inputPer1M: 0.0375, outputPer1M: 0.15, cachedInputPer1M: 9375e-6 },
|
|
556
|
+
"gemini-1.0-pro": { inputPer1M: 0.5, outputPer1M: 1.5 },
|
|
533
557
|
// --- xAI Grok ---
|
|
534
558
|
"grok-4.6": { inputPer1M: 3, outputPer1M: 15 },
|
|
559
|
+
"grok-3": { inputPer1M: 3, outputPer1M: 15 },
|
|
560
|
+
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 1.5 },
|
|
535
561
|
"grok-2": { inputPer1M: 2, outputPer1M: 10 },
|
|
536
562
|
"grok-2-vision": { inputPer1M: 2, outputPer1M: 10 },
|
|
537
563
|
"grok-beta": { inputPer1M: 5, outputPer1M: 15 },
|
|
538
564
|
// --- Mistral ---
|
|
539
565
|
"mistral-large-3": { inputPer1M: 2, outputPer1M: 6 },
|
|
540
566
|
"mistral-large-latest": { inputPer1M: 2, outputPer1M: 6 },
|
|
567
|
+
"mistral-large-2411": { inputPer1M: 2, outputPer1M: 6 },
|
|
541
568
|
"codestral-latest": { inputPer1M: 0.3, outputPer1M: 0.9 },
|
|
569
|
+
"mistral-medium-latest": { inputPer1M: 2.7, outputPer1M: 8.1 },
|
|
542
570
|
"mistral-small-latest": { inputPer1M: 0.2, outputPer1M: 0.6 },
|
|
543
571
|
"ministral-8b-latest": { inputPer1M: 0.1, outputPer1M: 0.1 },
|
|
544
|
-
|
|
572
|
+
"ministral-3b-latest": { inputPer1M: 0.04, outputPer1M: 0.04 },
|
|
573
|
+
"open-mistral-7b": { inputPer1M: 0.2, outputPer1M: 0.2 },
|
|
574
|
+
"open-mixtral-8x7b": { inputPer1M: 0.7, outputPer1M: 0.7 },
|
|
575
|
+
"open-mixtral-8x22b": { inputPer1M: 2, outputPer1M: 6 },
|
|
576
|
+
// --- Groq & Meta Llama LPUs ---
|
|
545
577
|
"llama-3.3-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
|
|
578
|
+
"llama-3.1-405b": { inputPer1M: 3, outputPer1M: 3 },
|
|
579
|
+
"llama-3.1-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
|
|
546
580
|
"llama-3.1-8b-instant": { inputPer1M: 0.05, outputPer1M: 0.08 },
|
|
581
|
+
"llama-3.2-1b-preview": { inputPer1M: 0.04, outputPer1M: 0.04 },
|
|
582
|
+
"llama-3.2-3b-preview": { inputPer1M: 0.06, outputPer1M: 0.06 },
|
|
583
|
+
"llama-3.2-11b-vision": { inputPer1M: 0.18, outputPer1M: 0.18 },
|
|
584
|
+
"llama-3.2-90b-vision": { inputPer1M: 0.9, outputPer1M: 0.9 },
|
|
547
585
|
"deepseek-r1-distill-llama-70b": { inputPer1M: 0.75, outputPer1M: 0.99 },
|
|
586
|
+
"deepseek-r1-distill-qwen-32b": { inputPer1M: 0.49, outputPer1M: 0.49 },
|
|
548
587
|
"qwen-2.5-32b": { inputPer1M: 0.29, outputPer1M: 0.39 },
|
|
588
|
+
"qwen-2.5-72b": { inputPer1M: 0.35, outputPer1M: 0.4 },
|
|
589
|
+
"mixtral-8x7b-32768": { inputPer1M: 0.24, outputPer1M: 0.24 },
|
|
590
|
+
"gemma2-9b-it": { inputPer1M: 0.2, outputPer1M: 0.2 },
|
|
549
591
|
// --- DeepSeek ---
|
|
550
592
|
"deepseek-v4-pro": { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },
|
|
551
593
|
"deepseek-v4-flash": { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },
|
|
552
|
-
"deepseek-
|
|
553
|
-
"deepseek-
|
|
594
|
+
"deepseek-v3": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
|
|
595
|
+
"deepseek-chat": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
|
|
596
|
+
"deepseek-r1": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
|
|
597
|
+
"deepseek-reasoner": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
|
|
554
598
|
// --- Cohere ---
|
|
555
599
|
"command-r-plus": { inputPer1M: 2.5, outputPer1M: 10 },
|
|
556
|
-
"command-r": { inputPer1M: 0.15, outputPer1M: 0.6 }
|
|
600
|
+
"command-r": { inputPer1M: 0.15, outputPer1M: 0.6 },
|
|
601
|
+
"command": { inputPer1M: 1, outputPer1M: 2 },
|
|
602
|
+
"command-light": { inputPer1M: 0.3, outputPer1M: 0.6 },
|
|
603
|
+
"embed-english-v3.0": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
604
|
+
// --- Perplexity ---
|
|
605
|
+
"sonar": { inputPer1M: 1, outputPer1M: 1 },
|
|
606
|
+
"sonar-pro": { inputPer1M: 3, outputPer1M: 15 },
|
|
607
|
+
"sonar-reasoning": { inputPer1M: 1, outputPer1M: 5 },
|
|
608
|
+
"sonar-reasoning-pro": { inputPer1M: 2, outputPer1M: 8 }
|
|
609
|
+
};
|
|
610
|
+
var MODEL_ALIASES = {
|
|
611
|
+
// OpenAI Shorthands & Aliases
|
|
612
|
+
"gpt4": "gpt-4",
|
|
613
|
+
"gpt4o": "gpt-4o",
|
|
614
|
+
"gpt-4-preview": "gpt-4-turbo",
|
|
615
|
+
"gpt-4-0125-preview": "gpt-4-turbo",
|
|
616
|
+
"gpt-4-1106-preview": "gpt-4-turbo",
|
|
617
|
+
"gpt-3.5": "gpt-3.5-turbo",
|
|
618
|
+
"gpt-3.5-turbo-0125": "gpt-3.5-turbo",
|
|
619
|
+
"gpt-3.5-turbo-1106": "gpt-3.5-turbo",
|
|
620
|
+
"gpt-3.5-turbo-16k-0613": "gpt-3.5-turbo-16k",
|
|
621
|
+
// Anthropic Shorthands
|
|
622
|
+
"sonnet": "claude-3-5-sonnet",
|
|
623
|
+
"sonnet-3.7": "claude-3-7-sonnet",
|
|
624
|
+
"sonnet-3.5": "claude-3-5-sonnet",
|
|
625
|
+
"haiku": "claude-3-5-haiku",
|
|
626
|
+
"haiku-3.5": "claude-3-5-haiku",
|
|
627
|
+
"opus": "claude-3-opus",
|
|
628
|
+
"claude-2": "claude-2.0",
|
|
629
|
+
"claude-instant": "claude-instant-1.2",
|
|
630
|
+
// DeepSeek Shorthands
|
|
631
|
+
"r1": "deepseek-r1",
|
|
632
|
+
"v3": "deepseek-v3",
|
|
633
|
+
// Gemini Shorthands
|
|
634
|
+
"flash": "gemini-2.0-flash",
|
|
635
|
+
"pro": "gemini-1.5-pro",
|
|
636
|
+
// Meta / Groq Shorthands
|
|
637
|
+
"llama-3.3-70b": "llama-3.3-70b-versatile",
|
|
638
|
+
"llama-3.1-70b": "llama-3.1-70b-versatile",
|
|
639
|
+
"llama-3.1-8b": "llama-3.1-8b-instant",
|
|
640
|
+
"llama-3-70b": "llama-3.1-70b-versatile",
|
|
641
|
+
"llama-3-8b": "llama-3.1-8b-instant",
|
|
642
|
+
// Mistral Shorthands
|
|
643
|
+
"codestral": "codestral-latest",
|
|
644
|
+
"mistral-large": "mistral-large-latest",
|
|
645
|
+
"mistral-small": "mistral-small-latest"
|
|
557
646
|
};
|
|
558
647
|
var customPricingRegistry = {};
|
|
559
648
|
function normalizeModelKey(rawModel) {
|
|
560
649
|
if (!rawModel) return "unknown";
|
|
561
650
|
let model = rawModel.toLowerCase().trim();
|
|
651
|
+
model = model.replace(/^[a-z0-9_-]+\.(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
|
|
652
|
+
model = model.replace(/^(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
|
|
653
|
+
model = model.replace(/-v\d+(:\d+)?$/, "");
|
|
654
|
+
model = model.replace(/:\d+$/, "");
|
|
562
655
|
if (model.includes("/")) {
|
|
563
|
-
model = model.split("/")
|
|
656
|
+
model = model.split("/").slice(1).join("/");
|
|
564
657
|
}
|
|
658
|
+
model = model.replace(/:(latest|free|beta)$/, "");
|
|
565
659
|
model = model.replace(/-\d{8}$/, "");
|
|
566
660
|
model = model.replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
661
|
+
model = model.replace(/llama(\d+)-(\d+)-/g, "llama-$1.$2-");
|
|
662
|
+
model = model.replace(/llama(\d+)\.(\d+)-/g, "llama-$1.$2-");
|
|
663
|
+
if (MODEL_ALIASES[model]) {
|
|
664
|
+
return MODEL_ALIASES[model];
|
|
665
|
+
}
|
|
666
|
+
if (!MODEL_PRICING_TABLE[model]) {
|
|
667
|
+
const withoutInstruct = model.replace(/-(instruct|chat|preview)$/, "");
|
|
668
|
+
if (MODEL_PRICING_TABLE[withoutInstruct]) {
|
|
669
|
+
return withoutInstruct;
|
|
670
|
+
}
|
|
671
|
+
if (MODEL_ALIASES[withoutInstruct]) {
|
|
672
|
+
return MODEL_ALIASES[withoutInstruct];
|
|
673
|
+
}
|
|
674
|
+
}
|
|
567
675
|
return model;
|
|
568
676
|
}
|
|
569
677
|
function getModelPricing(modelName) {
|
|
@@ -580,6 +688,10 @@ function getModelPricing(modelName) {
|
|
|
580
688
|
if (MODEL_PRICING_TABLE[modelName]) {
|
|
581
689
|
return MODEL_PRICING_TABLE[modelName];
|
|
582
690
|
}
|
|
691
|
+
const alias = MODEL_ALIASES[modelName.toLowerCase().trim()];
|
|
692
|
+
if (alias && MODEL_PRICING_TABLE[alias]) {
|
|
693
|
+
return MODEL_PRICING_TABLE[alias];
|
|
694
|
+
}
|
|
583
695
|
return {
|
|
584
696
|
inputPer1M: 1,
|
|
585
697
|
outputPer1M: 3,
|
|
@@ -602,35 +714,57 @@ function calculateCost(params) {
|
|
|
602
714
|
} else {
|
|
603
715
|
rates = getModelPricing(params.model);
|
|
604
716
|
}
|
|
605
|
-
const inputTokens = params.inputTokens ?? 0;
|
|
606
|
-
const outputTokens = params.outputTokens ?? 0;
|
|
607
|
-
const reasoningTokens = params.reasoningTokens ?? 0;
|
|
608
|
-
const cachedTokens = params.cachedTokens ?? 0;
|
|
609
|
-
const regularInputTokens =
|
|
610
|
-
const
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
|
|
717
|
+
const inputTokens = BigInt(Math.max(0, params.inputTokens ?? 0));
|
|
718
|
+
const outputTokens = BigInt(Math.max(0, params.outputTokens ?? 0));
|
|
719
|
+
const reasoningTokens = BigInt(Math.max(0, params.reasoningTokens ?? 0));
|
|
720
|
+
const cachedTokens = BigInt(Math.max(0, params.cachedTokens ?? 0));
|
|
721
|
+
const regularInputTokens = inputTokens > cachedTokens ? inputTokens - cachedTokens : 0n;
|
|
722
|
+
const rateInputNano = BigInt(Math.round(rates.inputPer1M * 1e3));
|
|
723
|
+
const cachedPer1M = rates.cachedInputPer1M ?? rates.inputPer1M * 0.15;
|
|
724
|
+
const rateCachedNano = BigInt(Math.round(cachedPer1M * 1e3));
|
|
725
|
+
const rateOutputNano = BigInt(Math.round(rates.outputPer1M * 1e3));
|
|
726
|
+
const reasoningPer1M = rates.reasoningPer1M ?? rates.outputPer1M;
|
|
727
|
+
const rateReasoningNano = BigInt(Math.round(reasoningPer1M * 1e3));
|
|
728
|
+
const regularInputCostNano = regularInputTokens * rateInputNano;
|
|
729
|
+
const cachedInputCostNano = cachedTokens * rateCachedNano;
|
|
730
|
+
const inputCostNano = regularInputCostNano + cachedInputCostNano;
|
|
731
|
+
const outputCostNano = outputTokens * rateOutputNano;
|
|
732
|
+
const reasoningCostNano = reasoningTokens * rateReasoningNano;
|
|
733
|
+
const standardCacheCostNano = cachedTokens * rateInputNano;
|
|
734
|
+
const cachedDiscountNano = standardCacheCostNano > cachedInputCostNano ? standardCacheCostNano - cachedInputCostNano : 0n;
|
|
735
|
+
const wholesaleNano = inputCostNano + outputCostNano;
|
|
620
736
|
const markup = params.markupMultiplier ?? 1;
|
|
621
|
-
let
|
|
737
|
+
let billedNano = wholesaleNano;
|
|
738
|
+
let hasRetail = false;
|
|
622
739
|
if (markup !== 1 || params.minimumChargeUSD !== void 0) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
740
|
+
hasRetail = true;
|
|
741
|
+
const markupMultiplierNano = BigInt(Math.round(markup * 1e3));
|
|
742
|
+
billedNano = wholesaleNano * markupMultiplierNano / 1000n;
|
|
743
|
+
if (params.minimumChargeUSD !== void 0 && params.minimumChargeUSD > 0) {
|
|
744
|
+
const minChargeNano = BigInt(Math.round(params.minimumChargeUSD * 1e9));
|
|
745
|
+
if (billedNano < minChargeNano) {
|
|
746
|
+
billedNano = minChargeNano;
|
|
747
|
+
}
|
|
626
748
|
}
|
|
627
749
|
}
|
|
750
|
+
const inputCostUSD = Number(inputCostNano) / 1e9;
|
|
751
|
+
const outputCostUSD = Number(outputCostNano) / 1e9;
|
|
752
|
+
const reasoningCostUSD = Number(reasoningCostNano) / 1e9;
|
|
753
|
+
const cachedDiscountUSD = Number(cachedDiscountNano) / 1e9;
|
|
754
|
+
const totalUSD = Number(wholesaleNano) / 1e9;
|
|
755
|
+
const wholesaleTotalUSD = totalUSD;
|
|
756
|
+
const billedUSD = Number(billedNano) / 1e9;
|
|
757
|
+
const profitUSD = Math.max(0, billedUSD - wholesaleTotalUSD);
|
|
758
|
+
const retailUSD = hasRetail ? billedUSD : void 0;
|
|
628
759
|
return {
|
|
629
760
|
inputCostUSD: Number(inputCostUSD.toFixed(8)),
|
|
630
761
|
outputCostUSD: Number(outputCostUSD.toFixed(8)),
|
|
631
|
-
reasoningCostUSD: reasoningTokens >
|
|
632
|
-
cachedDiscountUSD: cachedTokens >
|
|
762
|
+
reasoningCostUSD: reasoningTokens > 0n ? Number(reasoningCostUSD.toFixed(8)) : void 0,
|
|
763
|
+
cachedDiscountUSD: cachedTokens > 0n ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
|
|
633
764
|
totalUSD: Number(totalUSD.toFixed(8)),
|
|
765
|
+
wholesaleTotalUSD: Number(wholesaleTotalUSD.toFixed(8)),
|
|
766
|
+
billedUSD: Number(billedUSD.toFixed(8)),
|
|
767
|
+
profitUSD: Number(profitUSD.toFixed(8)),
|
|
634
768
|
retailUSD: retailUSD !== void 0 ? Number(retailUSD.toFixed(8)) : void 0,
|
|
635
769
|
currency: rates.currency || "USD"
|
|
636
770
|
};
|
|
@@ -836,7 +970,7 @@ function wrapUniversalStream(stream, options = {}, onComplete) {
|
|
|
836
970
|
return wrapGeminiStream(stream, options, onComplete);
|
|
837
971
|
}
|
|
838
972
|
if (Symbol.asyncIterator in stream) {
|
|
839
|
-
if (options.provider === "anthropic") {
|
|
973
|
+
if (options.provider === "anthropic" || options.model?.toLowerCase().includes("claude")) {
|
|
840
974
|
return wrapAnthropicStream(stream, options, onComplete);
|
|
841
975
|
}
|
|
842
976
|
return wrapOpenAIStream(stream, options, onComplete);
|
|
@@ -858,7 +992,7 @@ var VibezMeter = class {
|
|
|
858
992
|
this.stripeClient = new import_stripe.default(key, {
|
|
859
993
|
appInfo: {
|
|
860
994
|
name: "vibezcheck",
|
|
861
|
-
version: "0.
|
|
995
|
+
version: "0.5.3",
|
|
862
996
|
url: "https://vibezcheck.xyz"
|
|
863
997
|
}
|
|
864
998
|
});
|
|
@@ -965,10 +1099,20 @@ function createMeter(options = {}) {
|
|
|
965
1099
|
}
|
|
966
1100
|
|
|
967
1101
|
// src/ai-sdk/with-billing.ts
|
|
968
|
-
function withBilling(model,
|
|
1102
|
+
function withBilling(model, optionsOrCustomer, extraOptions = {}) {
|
|
969
1103
|
if (!model || typeof model !== "object") {
|
|
970
1104
|
return model;
|
|
971
1105
|
}
|
|
1106
|
+
let options = {};
|
|
1107
|
+
if (typeof optionsOrCustomer === "string") {
|
|
1108
|
+
options = { ...extraOptions, customer: optionsOrCustomer };
|
|
1109
|
+
} else if (typeof optionsOrCustomer === "object" && optionsOrCustomer !== null) {
|
|
1110
|
+
if ("userId" in optionsOrCustomer || "email" in optionsOrCustomer || "id" in optionsOrCustomer) {
|
|
1111
|
+
options = { ...extraOptions, customer: optionsOrCustomer };
|
|
1112
|
+
} else {
|
|
1113
|
+
options = { ...optionsOrCustomer, ...extraOptions };
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
972
1116
|
const meter = options.meter || createMeter({
|
|
973
1117
|
apiKey: options.stripeApiKey,
|
|
974
1118
|
eventName: options.eventName
|
|
@@ -997,17 +1141,19 @@ function withBilling(model, options = {}) {
|
|
|
997
1141
|
};
|
|
998
1142
|
const handleUsage = (rawUsage, extraMeta) => {
|
|
999
1143
|
if (!rawUsage) return;
|
|
1000
|
-
const inputTokens = rawUsage.promptTokens ?? rawUsage.inputTokens ?? 0;
|
|
1001
|
-
const outputTokens = rawUsage.completionTokens ?? rawUsage.outputTokens ?? 0;
|
|
1002
|
-
const reasoningTokens = rawUsage.reasoningTokens ?? rawUsage.completionTokensDetails?.reasoningTokens ?? rawUsage.outputTokenDetails?.reasoningTokens ?? 0;
|
|
1003
|
-
const cachedTokens = rawUsage.promptTokensDetails?.cachedTokens ?? rawUsage.inputTokenDetails?.cachedTokens ?? 0;
|
|
1144
|
+
const inputTokens = rawUsage.promptTokens ?? rawUsage.inputTokens ?? rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokenCount ?? 0;
|
|
1145
|
+
const outputTokens = rawUsage.completionTokens ?? rawUsage.outputTokens ?? rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.candidatesTokenCount ?? 0;
|
|
1146
|
+
const 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;
|
|
1147
|
+
const 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;
|
|
1148
|
+
const cacheWriteTokens = rawUsage.cacheWriteTokens ?? rawUsage.cache_creation_input_tokens ?? rawUsage.cacheCreationTokens ?? 0;
|
|
1004
1149
|
const usage = {
|
|
1005
1150
|
inputTokens,
|
|
1006
1151
|
outputTokens,
|
|
1007
1152
|
totalTokens: inputTokens + outputTokens,
|
|
1008
1153
|
reasoningTokens: reasoningTokens > 0 ? reasoningTokens : void 0,
|
|
1009
1154
|
visibleOutputTokens: Math.max(0, outputTokens - reasoningTokens),
|
|
1010
|
-
cachedTokens: cachedTokens > 0 ? cachedTokens : void 0
|
|
1155
|
+
cachedTokens: cachedTokens > 0 ? cachedTokens : void 0,
|
|
1156
|
+
cacheWriteTokens: cacheWriteTokens > 0 ? cacheWriteTokens : void 0
|
|
1011
1157
|
};
|
|
1012
1158
|
const cost = calculateUsageCost(modelId, usage, {
|
|
1013
1159
|
markupMultiplier: options.pricing?.margin,
|
|
@@ -1108,7 +1254,9 @@ function withBilling(model, options = {}) {
|
|
|
1108
1254
|
return;
|
|
1109
1255
|
}
|
|
1110
1256
|
} catch (err) {
|
|
1111
|
-
|
|
1257
|
+
if (process.env.NODE_ENV !== "test" && !options.silent) {
|
|
1258
|
+
console.warn(`[vibezcheck] Database record failed safely:`, err?.message || err);
|
|
1259
|
+
}
|
|
1112
1260
|
}
|
|
1113
1261
|
};
|
|
1114
1262
|
if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
|
|
@@ -1124,7 +1272,9 @@ function withBilling(model, options = {}) {
|
|
|
1124
1272
|
try {
|
|
1125
1273
|
await chargeFn(cost.totalUSD, event);
|
|
1126
1274
|
} catch (err) {
|
|
1127
|
-
|
|
1275
|
+
if (process.env.NODE_ENV !== "test" && !options.silent) {
|
|
1276
|
+
console.warn(`[vibezcheck] Custom charge handler failed safely:`, err?.message || err);
|
|
1277
|
+
}
|
|
1128
1278
|
}
|
|
1129
1279
|
};
|
|
1130
1280
|
if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
|
|
@@ -1139,7 +1289,9 @@ function withBilling(model, options = {}) {
|
|
|
1139
1289
|
try {
|
|
1140
1290
|
await providerCharge(cost.totalUSD, event);
|
|
1141
1291
|
} catch (err) {
|
|
1142
|
-
|
|
1292
|
+
if (process.env.NODE_ENV !== "test" && !options.silent) {
|
|
1293
|
+
console.warn(`[vibezcheck] Payment provider charge failed safely:`, err?.message || err);
|
|
1294
|
+
}
|
|
1143
1295
|
}
|
|
1144
1296
|
};
|
|
1145
1297
|
if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
|
|
@@ -1194,14 +1346,19 @@ function withBilling(model, options = {}) {
|
|
|
1194
1346
|
const transformStream = new TransformStream({
|
|
1195
1347
|
transform(chunk, controller) {
|
|
1196
1348
|
controller.enqueue(chunk);
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1349
|
+
const delta = chunk.textDelta || chunk.text || chunk.delta;
|
|
1350
|
+
if (delta && typeof delta === "string") {
|
|
1351
|
+
accumulatedChars += delta.length;
|
|
1352
|
+
} else if (chunk.type === "reasoning" || chunk.type === "reasoning-delta") {
|
|
1353
|
+
const reasoning = chunk.reasoning || chunk.textDelta || chunk.text || chunk.delta || "";
|
|
1354
|
+
if (typeof reasoning === "string") {
|
|
1355
|
+
accumulatedChars += reasoning.length;
|
|
1356
|
+
}
|
|
1201
1357
|
}
|
|
1202
|
-
|
|
1358
|
+
const chunkUsage = chunk.usage || chunk.token_usage || chunk.usageMetadata;
|
|
1359
|
+
if (chunkUsage) {
|
|
1203
1360
|
streamCompleted = true;
|
|
1204
|
-
handleUsage(
|
|
1361
|
+
handleUsage(chunkUsage);
|
|
1205
1362
|
}
|
|
1206
1363
|
},
|
|
1207
1364
|
flush() {
|
|
@@ -1227,13 +1384,29 @@ function withBilling(model, options = {}) {
|
|
|
1227
1384
|
if (prop === "doGenerate" && typeof originalValue === "function") {
|
|
1228
1385
|
return async function(...args) {
|
|
1229
1386
|
const result = await originalValue.apply(target, args);
|
|
1230
|
-
|
|
1231
|
-
|
|
1387
|
+
const usage = result?.usage || result?.tokenUsage || result?.usageMetadata;
|
|
1388
|
+
if (usage) {
|
|
1389
|
+
handleUsage(usage);
|
|
1232
1390
|
}
|
|
1233
1391
|
return result;
|
|
1234
1392
|
};
|
|
1235
1393
|
}
|
|
1236
1394
|
return originalValue;
|
|
1395
|
+
},
|
|
1396
|
+
apply(target, thisArg, argArray) {
|
|
1397
|
+
if (typeof target === "function") {
|
|
1398
|
+
return Reflect.apply(target, thisArg, argArray);
|
|
1399
|
+
}
|
|
1400
|
+
return target;
|
|
1401
|
+
},
|
|
1402
|
+
has(target, prop) {
|
|
1403
|
+
return Reflect.has(target, prop);
|
|
1404
|
+
},
|
|
1405
|
+
ownKeys(target) {
|
|
1406
|
+
return Reflect.ownKeys(target);
|
|
1407
|
+
},
|
|
1408
|
+
getPrototypeOf(target) {
|
|
1409
|
+
return Reflect.getPrototypeOf(target);
|
|
1237
1410
|
}
|
|
1238
1411
|
};
|
|
1239
1412
|
return new Proxy(model, handler);
|
|
@@ -1253,23 +1426,88 @@ function createVibezModel(modelOrId, options = {}) {
|
|
|
1253
1426
|
const parts = rawId.split("/");
|
|
1254
1427
|
providerName = parts[0].toLowerCase();
|
|
1255
1428
|
cleanModelId = parts.slice(1).join("/");
|
|
1429
|
+
} else if (rawId.startsWith("claude-")) {
|
|
1430
|
+
providerName = "anthropic";
|
|
1431
|
+
} else if (rawId.startsWith("gemini-")) {
|
|
1432
|
+
providerName = "google";
|
|
1433
|
+
} else if (rawId.startsWith("deepseek-")) {
|
|
1434
|
+
providerName = "deepseek";
|
|
1435
|
+
} else if (rawId.startsWith("grok-")) {
|
|
1436
|
+
providerName = "xai";
|
|
1437
|
+
} else if (rawId.startsWith("mistral-") || rawId.startsWith("codestral-") || rawId.startsWith("ministral-") || rawId.startsWith("open-mistral") || rawId.startsWith("open-mixtral")) {
|
|
1438
|
+
providerName = "mistral";
|
|
1439
|
+
} else if (rawId.startsWith("llama-") || rawId.startsWith("mixtral-") || rawId.startsWith("gemma") || rawId.startsWith("qwen-")) {
|
|
1440
|
+
providerName = "groq";
|
|
1441
|
+
} else if (rawId.startsWith("command-")) {
|
|
1442
|
+
providerName = "cohere";
|
|
1256
1443
|
}
|
|
1257
|
-
const apiKey = options.apiKey || process.env.AI_GATEWAY_API_KEY || process.env.
|
|
1444
|
+
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;
|
|
1258
1445
|
const baseURL = options.baseURL || process.env.AI_GATEWAY_BASE_URL || (providerName === "openai" ? "https://api.openai.com/v1" : void 0);
|
|
1259
1446
|
let baseModelInstance = null;
|
|
1260
1447
|
try {
|
|
1261
1448
|
if (providerName === "openai" || providerName === "gateway" || !providerName) {
|
|
1262
|
-
const
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1449
|
+
const mod = require("@ai-sdk/openai");
|
|
1450
|
+
const factory = mod.createOpenAI || mod.openai || mod.default?.createOpenAI || mod.default?.openai;
|
|
1451
|
+
if (typeof factory === "function") {
|
|
1452
|
+
if (mod.createOpenAI) {
|
|
1453
|
+
const provider = factory({ apiKey, baseURL });
|
|
1454
|
+
baseModelInstance = provider(cleanModelId);
|
|
1455
|
+
} else {
|
|
1456
|
+
baseModelInstance = factory(cleanModelId);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1265
1459
|
} else if (providerName === "anthropic") {
|
|
1266
|
-
const
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1460
|
+
const mod = require("@ai-sdk/anthropic");
|
|
1461
|
+
const factory = mod.createAnthropic || mod.anthropic || mod.default?.createAnthropic || mod.default?.anthropic;
|
|
1462
|
+
if (typeof factory === "function") {
|
|
1463
|
+
if (mod.createAnthropic) {
|
|
1464
|
+
const provider = factory({ apiKey, baseURL });
|
|
1465
|
+
baseModelInstance = provider(cleanModelId);
|
|
1466
|
+
} else {
|
|
1467
|
+
baseModelInstance = factory(cleanModelId);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1269
1470
|
} else if (providerName === "google") {
|
|
1270
|
-
const
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1471
|
+
const mod = require("@ai-sdk/google");
|
|
1472
|
+
const factory = mod.createGoogleGenerativeAI || mod.google || mod.default?.createGoogleGenerativeAI || mod.default?.google;
|
|
1473
|
+
if (typeof factory === "function") {
|
|
1474
|
+
if (mod.createGoogleGenerativeAI) {
|
|
1475
|
+
const provider = factory({ apiKey, baseURL });
|
|
1476
|
+
baseModelInstance = provider(cleanModelId);
|
|
1477
|
+
} else {
|
|
1478
|
+
baseModelInstance = factory(cleanModelId);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
} else if (providerName === "mistral") {
|
|
1482
|
+
const mod = require("@ai-sdk/mistral");
|
|
1483
|
+
const factory = mod.createMistral || mod.mistral || mod.default?.createMistral || mod.default?.mistral;
|
|
1484
|
+
if (typeof factory === "function") {
|
|
1485
|
+
baseModelInstance = mod.createMistral ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1486
|
+
}
|
|
1487
|
+
} else if (providerName === "groq") {
|
|
1488
|
+
const mod = require("@ai-sdk/groq");
|
|
1489
|
+
const factory = mod.createGroq || mod.groq || mod.default?.createGroq || mod.default?.groq;
|
|
1490
|
+
if (typeof factory === "function") {
|
|
1491
|
+
baseModelInstance = mod.createGroq ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1492
|
+
}
|
|
1493
|
+
} else if (providerName === "deepseek") {
|
|
1494
|
+
const mod = require("@ai-sdk/deepseek");
|
|
1495
|
+
const factory = mod.createDeepSeek || mod.deepseek || mod.default?.createDeepSeek || mod.default?.deepseek;
|
|
1496
|
+
if (typeof factory === "function") {
|
|
1497
|
+
baseModelInstance = mod.createDeepSeek ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1498
|
+
}
|
|
1499
|
+
} else if (providerName === "xai") {
|
|
1500
|
+
const mod = require("@ai-sdk/xai");
|
|
1501
|
+
const factory = mod.createXai || mod.xai || mod.default?.createXai || mod.default?.xai;
|
|
1502
|
+
if (typeof factory === "function") {
|
|
1503
|
+
baseModelInstance = mod.createXai ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1504
|
+
}
|
|
1505
|
+
} else if (providerName === "cohere") {
|
|
1506
|
+
const mod = require("@ai-sdk/cohere");
|
|
1507
|
+
const factory = mod.createCohere || mod.cohere || mod.default?.createCohere || mod.default?.cohere;
|
|
1508
|
+
if (typeof factory === "function") {
|
|
1509
|
+
baseModelInstance = mod.createCohere ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1510
|
+
}
|
|
1273
1511
|
}
|
|
1274
1512
|
} catch {
|
|
1275
1513
|
baseModelInstance = {
|