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.mjs
CHANGED
|
@@ -276,12 +276,12 @@ function extractOpenAIResponseUsage(response) {
|
|
|
276
276
|
function inspectOpenAIStreamChunk(chunk) {
|
|
277
277
|
if (!chunk || typeof chunk !== "object") return {};
|
|
278
278
|
const model = chunk.model;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? 0;
|
|
282
|
-
const outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? 0;
|
|
283
|
-
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? 0;
|
|
284
|
-
const cachedTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.input_token_details?.cached_tokens ?? 0;
|
|
279
|
+
const rawUsage = chunk.usage || chunk.token_usage || chunk.x_groq?.usage || chunk.usageMetadata;
|
|
280
|
+
if (rawUsage) {
|
|
281
|
+
const inputTokens = rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokens ?? rawUsage.inputTokens ?? rawUsage.promptTokenCount ?? 0;
|
|
282
|
+
const outputTokens = rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.completionTokens ?? rawUsage.outputTokens ?? rawUsage.candidatesTokenCount ?? 0;
|
|
283
|
+
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens ?? rawUsage.output_token_details?.reasoning_tokens ?? rawUsage.reasoning_tokens ?? rawUsage.reasoningTokens ?? rawUsage.thoughtsTokenCount ?? 0;
|
|
284
|
+
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;
|
|
285
285
|
return {
|
|
286
286
|
model,
|
|
287
287
|
usage: {
|
|
@@ -296,11 +296,11 @@ function inspectOpenAIStreamChunk(chunk) {
|
|
|
296
296
|
}
|
|
297
297
|
if (chunk.type === "response.completed" || chunk.type === "response.done") {
|
|
298
298
|
if (chunk.response?.usage) {
|
|
299
|
-
const
|
|
300
|
-
const inputTokens =
|
|
301
|
-
const outputTokens =
|
|
302
|
-
const reasoningTokens =
|
|
303
|
-
const cachedTokens =
|
|
299
|
+
const rawUsage2 = chunk.response.usage;
|
|
300
|
+
const inputTokens = rawUsage2.input_tokens ?? 0;
|
|
301
|
+
const outputTokens = rawUsage2.output_tokens ?? 0;
|
|
302
|
+
const reasoningTokens = rawUsage2.output_token_details?.reasoning_tokens ?? 0;
|
|
303
|
+
const cachedTokens = rawUsage2.input_token_details?.cached_tokens ?? 0;
|
|
304
304
|
return {
|
|
305
305
|
model: chunk.response.model || model,
|
|
306
306
|
usage: {
|
|
@@ -465,7 +465,7 @@ function detectAndExtractUsage(response, fallbackModel, fallbackProvider) {
|
|
|
465
465
|
|
|
466
466
|
// src/pricing/table.ts
|
|
467
467
|
var MODEL_PRICING_TABLE = {
|
|
468
|
-
// --- OpenAI ---
|
|
468
|
+
// --- OpenAI (Modern & Reasoning) ---
|
|
469
469
|
"gpt-5.6-sol": { inputPer1M: 4, outputPer1M: 20, cachedInputPer1M: 0.4 },
|
|
470
470
|
"gpt-5.6-terra": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.2 },
|
|
471
471
|
"gpt-5.6-luna": { inputPer1M: 0.2, outputPer1M: 1.2, cachedInputPer1M: 0.02 },
|
|
@@ -477,11 +477,22 @@ var MODEL_PRICING_TABLE = {
|
|
|
477
477
|
"o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4, cachedInputPer1M: 0.55 },
|
|
478
478
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cachedInputPer1M: 1.25 },
|
|
479
479
|
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.075 },
|
|
480
|
+
"gpt-4.5": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
|
|
481
|
+
"gpt-4.5-preview": { inputPer1M: 75, outputPer1M: 150, cachedInputPer1M: 37.5 },
|
|
482
|
+
"chatgpt-4o-latest": { inputPer1M: 5, outputPer1M: 15 },
|
|
480
483
|
"gpt-4.1": { inputPer1M: 2, outputPer1M: 8, cachedInputPer1M: 1 },
|
|
481
484
|
"gpt-4.1-nano": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.05 },
|
|
485
|
+
// --- OpenAI (Legacy & Backward Compatibility) ---
|
|
486
|
+
"gpt-4-turbo": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
|
|
487
|
+
"gpt-4-turbo-preview": { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 5 },
|
|
488
|
+
"gpt-4": { inputPer1M: 30, outputPer1M: 60 },
|
|
489
|
+
"gpt-4-32k": { inputPer1M: 60, outputPer1M: 120 },
|
|
490
|
+
"gpt-3.5-turbo": { inputPer1M: 0.5, outputPer1M: 1.5 },
|
|
491
|
+
"gpt-3.5-turbo-16k": { inputPer1M: 3, outputPer1M: 4 },
|
|
482
492
|
"text-embedding-3-small": { inputPer1M: 0.02, outputPer1M: 0 },
|
|
483
493
|
"text-embedding-3-large": { inputPer1M: 0.13, outputPer1M: 0 },
|
|
484
|
-
|
|
494
|
+
"text-embedding-ada-002": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
495
|
+
// --- Anthropic (Modern & Extended Thinking) ---
|
|
485
496
|
"claude-3-7-sonnet": { inputPer1M: 0.59, outputPer1M: 2.93, cachedInputPer1M: 0.3 },
|
|
486
497
|
"claude-sonnet-5": { inputPer1M: 2, outputPer1M: 10, cachedInputPer1M: 0.3 },
|
|
487
498
|
"claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
@@ -489,48 +500,145 @@ var MODEL_PRICING_TABLE = {
|
|
|
489
500
|
"haiku-4.5": { inputPer1M: 1, outputPer1M: 5, cachedInputPer1M: 0.1 },
|
|
490
501
|
"claude-opus-5": { inputPer1M: 5, outputPer1M: 25, cachedInputPer1M: 1.5 },
|
|
491
502
|
"claude-3-opus": { inputPer1M: 15, outputPer1M: 75, cachedInputPer1M: 1.5 },
|
|
492
|
-
// ---
|
|
503
|
+
// --- Anthropic (Legacy & Backward Compatibility) ---
|
|
504
|
+
"claude-3-sonnet": { inputPer1M: 3, outputPer1M: 15, cachedInputPer1M: 0.3 },
|
|
505
|
+
"claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25, cachedInputPer1M: 0.025 },
|
|
506
|
+
"claude-2.1": { inputPer1M: 8, outputPer1M: 24 },
|
|
507
|
+
"claude-2.0": { inputPer1M: 8, outputPer1M: 24 },
|
|
508
|
+
"claude-instant-1.2": { inputPer1M: 1.63, outputPer1M: 5.51 },
|
|
509
|
+
// --- Google Gemini (Modern & Thoughts) ---
|
|
493
510
|
"gemini-3.7-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachedInputPer1M: 0.18 },
|
|
494
511
|
"gemini-3.1-pro": { inputPer1M: 2, outputPer1M: 12, cachedInputPer1M: 0.5 },
|
|
495
512
|
"gemini-3.5-flash": { inputPer1M: 1.5, outputPer1M: 9, cachedInputPer1M: 0.38 },
|
|
496
513
|
"gemini-3.1-flash-lite": { inputPer1M: 0.25, outputPer1M: 1.5, cachedInputPer1M: 0.06 },
|
|
514
|
+
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
515
|
+
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cachedInputPer1M: 0.0375 },
|
|
497
516
|
"gemini-2.0-flash": { inputPer1M: 0.1, outputPer1M: 0.4, cachedInputPer1M: 0.025 },
|
|
517
|
+
"gemini-2.0-flash-lite": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
|
|
518
|
+
"gemini-2.0-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
519
|
+
// --- Google Gemini (Legacy & Backward Compatibility) ---
|
|
498
520
|
"gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5, cachedInputPer1M: 0.3125 },
|
|
499
521
|
"gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3, cachedInputPer1M: 0.01875 },
|
|
522
|
+
"gemini-1.5-flash-8b": { inputPer1M: 0.0375, outputPer1M: 0.15, cachedInputPer1M: 9375e-6 },
|
|
523
|
+
"gemini-1.0-pro": { inputPer1M: 0.5, outputPer1M: 1.5 },
|
|
500
524
|
// --- xAI Grok ---
|
|
501
525
|
"grok-4.6": { inputPer1M: 3, outputPer1M: 15 },
|
|
526
|
+
"grok-3": { inputPer1M: 3, outputPer1M: 15 },
|
|
527
|
+
"grok-3-mini": { inputPer1M: 0.3, outputPer1M: 1.5 },
|
|
502
528
|
"grok-2": { inputPer1M: 2, outputPer1M: 10 },
|
|
503
529
|
"grok-2-vision": { inputPer1M: 2, outputPer1M: 10 },
|
|
504
530
|
"grok-beta": { inputPer1M: 5, outputPer1M: 15 },
|
|
505
531
|
// --- Mistral ---
|
|
506
532
|
"mistral-large-3": { inputPer1M: 2, outputPer1M: 6 },
|
|
507
533
|
"mistral-large-latest": { inputPer1M: 2, outputPer1M: 6 },
|
|
534
|
+
"mistral-large-2411": { inputPer1M: 2, outputPer1M: 6 },
|
|
508
535
|
"codestral-latest": { inputPer1M: 0.3, outputPer1M: 0.9 },
|
|
536
|
+
"mistral-medium-latest": { inputPer1M: 2.7, outputPer1M: 8.1 },
|
|
509
537
|
"mistral-small-latest": { inputPer1M: 0.2, outputPer1M: 0.6 },
|
|
510
538
|
"ministral-8b-latest": { inputPer1M: 0.1, outputPer1M: 0.1 },
|
|
511
|
-
|
|
539
|
+
"ministral-3b-latest": { inputPer1M: 0.04, outputPer1M: 0.04 },
|
|
540
|
+
"open-mistral-7b": { inputPer1M: 0.2, outputPer1M: 0.2 },
|
|
541
|
+
"open-mixtral-8x7b": { inputPer1M: 0.7, outputPer1M: 0.7 },
|
|
542
|
+
"open-mixtral-8x22b": { inputPer1M: 2, outputPer1M: 6 },
|
|
543
|
+
// --- Groq & Meta Llama LPUs ---
|
|
512
544
|
"llama-3.3-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
|
|
545
|
+
"llama-3.1-405b": { inputPer1M: 3, outputPer1M: 3 },
|
|
546
|
+
"llama-3.1-70b-versatile": { inputPer1M: 0.59, outputPer1M: 0.79 },
|
|
513
547
|
"llama-3.1-8b-instant": { inputPer1M: 0.05, outputPer1M: 0.08 },
|
|
548
|
+
"llama-3.2-1b-preview": { inputPer1M: 0.04, outputPer1M: 0.04 },
|
|
549
|
+
"llama-3.2-3b-preview": { inputPer1M: 0.06, outputPer1M: 0.06 },
|
|
550
|
+
"llama-3.2-11b-vision": { inputPer1M: 0.18, outputPer1M: 0.18 },
|
|
551
|
+
"llama-3.2-90b-vision": { inputPer1M: 0.9, outputPer1M: 0.9 },
|
|
514
552
|
"deepseek-r1-distill-llama-70b": { inputPer1M: 0.75, outputPer1M: 0.99 },
|
|
553
|
+
"deepseek-r1-distill-qwen-32b": { inputPer1M: 0.49, outputPer1M: 0.49 },
|
|
515
554
|
"qwen-2.5-32b": { inputPer1M: 0.29, outputPer1M: 0.39 },
|
|
555
|
+
"qwen-2.5-72b": { inputPer1M: 0.35, outputPer1M: 0.4 },
|
|
556
|
+
"mixtral-8x7b-32768": { inputPer1M: 0.24, outputPer1M: 0.24 },
|
|
557
|
+
"gemma2-9b-it": { inputPer1M: 0.2, outputPer1M: 0.2 },
|
|
516
558
|
// --- DeepSeek ---
|
|
517
559
|
"deepseek-v4-pro": { inputPer1M: 0.66, outputPer1M: 1.98, cachedInputPer1M: 0.15 },
|
|
518
560
|
"deepseek-v4-flash": { inputPer1M: 0.22, outputPer1M: 0.66, cachedInputPer1M: 0.05 },
|
|
519
|
-
"deepseek-
|
|
520
|
-
"deepseek-
|
|
561
|
+
"deepseek-v3": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
|
|
562
|
+
"deepseek-chat": { inputPer1M: 0.14, outputPer1M: 0.28, cachedInputPer1M: 0.014 },
|
|
563
|
+
"deepseek-r1": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
|
|
564
|
+
"deepseek-reasoner": { inputPer1M: 0.55, outputPer1M: 2.19, cachedInputPer1M: 0.14 },
|
|
521
565
|
// --- Cohere ---
|
|
522
566
|
"command-r-plus": { inputPer1M: 2.5, outputPer1M: 10 },
|
|
523
|
-
"command-r": { inputPer1M: 0.15, outputPer1M: 0.6 }
|
|
567
|
+
"command-r": { inputPer1M: 0.15, outputPer1M: 0.6 },
|
|
568
|
+
"command": { inputPer1M: 1, outputPer1M: 2 },
|
|
569
|
+
"command-light": { inputPer1M: 0.3, outputPer1M: 0.6 },
|
|
570
|
+
"embed-english-v3.0": { inputPer1M: 0.1, outputPer1M: 0 },
|
|
571
|
+
// --- Perplexity ---
|
|
572
|
+
"sonar": { inputPer1M: 1, outputPer1M: 1 },
|
|
573
|
+
"sonar-pro": { inputPer1M: 3, outputPer1M: 15 },
|
|
574
|
+
"sonar-reasoning": { inputPer1M: 1, outputPer1M: 5 },
|
|
575
|
+
"sonar-reasoning-pro": { inputPer1M: 2, outputPer1M: 8 }
|
|
576
|
+
};
|
|
577
|
+
var MODEL_ALIASES = {
|
|
578
|
+
// OpenAI Shorthands & Aliases
|
|
579
|
+
"gpt4": "gpt-4",
|
|
580
|
+
"gpt4o": "gpt-4o",
|
|
581
|
+
"gpt-4-preview": "gpt-4-turbo",
|
|
582
|
+
"gpt-4-0125-preview": "gpt-4-turbo",
|
|
583
|
+
"gpt-4-1106-preview": "gpt-4-turbo",
|
|
584
|
+
"gpt-3.5": "gpt-3.5-turbo",
|
|
585
|
+
"gpt-3.5-turbo-0125": "gpt-3.5-turbo",
|
|
586
|
+
"gpt-3.5-turbo-1106": "gpt-3.5-turbo",
|
|
587
|
+
"gpt-3.5-turbo-16k-0613": "gpt-3.5-turbo-16k",
|
|
588
|
+
// Anthropic Shorthands
|
|
589
|
+
"sonnet": "claude-3-5-sonnet",
|
|
590
|
+
"sonnet-3.7": "claude-3-7-sonnet",
|
|
591
|
+
"sonnet-3.5": "claude-3-5-sonnet",
|
|
592
|
+
"haiku": "claude-3-5-haiku",
|
|
593
|
+
"haiku-3.5": "claude-3-5-haiku",
|
|
594
|
+
"opus": "claude-3-opus",
|
|
595
|
+
"claude-2": "claude-2.0",
|
|
596
|
+
"claude-instant": "claude-instant-1.2",
|
|
597
|
+
// DeepSeek Shorthands
|
|
598
|
+
"r1": "deepseek-r1",
|
|
599
|
+
"v3": "deepseek-v3",
|
|
600
|
+
// Gemini Shorthands
|
|
601
|
+
"flash": "gemini-2.0-flash",
|
|
602
|
+
"pro": "gemini-1.5-pro",
|
|
603
|
+
// Meta / Groq Shorthands
|
|
604
|
+
"llama-3.3-70b": "llama-3.3-70b-versatile",
|
|
605
|
+
"llama-3.1-70b": "llama-3.1-70b-versatile",
|
|
606
|
+
"llama-3.1-8b": "llama-3.1-8b-instant",
|
|
607
|
+
"llama-3-70b": "llama-3.1-70b-versatile",
|
|
608
|
+
"llama-3-8b": "llama-3.1-8b-instant",
|
|
609
|
+
// Mistral Shorthands
|
|
610
|
+
"codestral": "codestral-latest",
|
|
611
|
+
"mistral-large": "mistral-large-latest",
|
|
612
|
+
"mistral-small": "mistral-small-latest"
|
|
524
613
|
};
|
|
525
614
|
var customPricingRegistry = {};
|
|
526
615
|
function normalizeModelKey(rawModel) {
|
|
527
616
|
if (!rawModel) return "unknown";
|
|
528
617
|
let model = rawModel.toLowerCase().trim();
|
|
618
|
+
model = model.replace(/^[a-z0-9_-]+\.(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
|
|
619
|
+
model = model.replace(/^(anthropic|meta|amazon|cohere|mistral|ai21)\./i, "");
|
|
620
|
+
model = model.replace(/-v\d+(:\d+)?$/, "");
|
|
621
|
+
model = model.replace(/:\d+$/, "");
|
|
529
622
|
if (model.includes("/")) {
|
|
530
|
-
model = model.split("/")
|
|
623
|
+
model = model.split("/").slice(1).join("/");
|
|
531
624
|
}
|
|
625
|
+
model = model.replace(/:(latest|free|beta)$/, "");
|
|
532
626
|
model = model.replace(/-\d{8}$/, "");
|
|
533
627
|
model = model.replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
628
|
+
model = model.replace(/llama(\d+)-(\d+)-/g, "llama-$1.$2-");
|
|
629
|
+
model = model.replace(/llama(\d+)\.(\d+)-/g, "llama-$1.$2-");
|
|
630
|
+
if (MODEL_ALIASES[model]) {
|
|
631
|
+
return MODEL_ALIASES[model];
|
|
632
|
+
}
|
|
633
|
+
if (!MODEL_PRICING_TABLE[model]) {
|
|
634
|
+
const withoutInstruct = model.replace(/-(instruct|chat|preview)$/, "");
|
|
635
|
+
if (MODEL_PRICING_TABLE[withoutInstruct]) {
|
|
636
|
+
return withoutInstruct;
|
|
637
|
+
}
|
|
638
|
+
if (MODEL_ALIASES[withoutInstruct]) {
|
|
639
|
+
return MODEL_ALIASES[withoutInstruct];
|
|
640
|
+
}
|
|
641
|
+
}
|
|
534
642
|
return model;
|
|
535
643
|
}
|
|
536
644
|
function getModelPricing(modelName) {
|
|
@@ -547,6 +655,10 @@ function getModelPricing(modelName) {
|
|
|
547
655
|
if (MODEL_PRICING_TABLE[modelName]) {
|
|
548
656
|
return MODEL_PRICING_TABLE[modelName];
|
|
549
657
|
}
|
|
658
|
+
const alias = MODEL_ALIASES[modelName.toLowerCase().trim()];
|
|
659
|
+
if (alias && MODEL_PRICING_TABLE[alias]) {
|
|
660
|
+
return MODEL_PRICING_TABLE[alias];
|
|
661
|
+
}
|
|
550
662
|
return {
|
|
551
663
|
inputPer1M: 1,
|
|
552
664
|
outputPer1M: 3,
|
|
@@ -569,35 +681,57 @@ function calculateCost(params) {
|
|
|
569
681
|
} else {
|
|
570
682
|
rates = getModelPricing(params.model);
|
|
571
683
|
}
|
|
572
|
-
const inputTokens = params.inputTokens ?? 0;
|
|
573
|
-
const outputTokens = params.outputTokens ?? 0;
|
|
574
|
-
const reasoningTokens = params.reasoningTokens ?? 0;
|
|
575
|
-
const cachedTokens = params.cachedTokens ?? 0;
|
|
576
|
-
const regularInputTokens =
|
|
577
|
-
const
|
|
578
|
-
const
|
|
579
|
-
const
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
const
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
const
|
|
586
|
-
|
|
684
|
+
const inputTokens = BigInt(Math.max(0, params.inputTokens ?? 0));
|
|
685
|
+
const outputTokens = BigInt(Math.max(0, params.outputTokens ?? 0));
|
|
686
|
+
const reasoningTokens = BigInt(Math.max(0, params.reasoningTokens ?? 0));
|
|
687
|
+
const cachedTokens = BigInt(Math.max(0, params.cachedTokens ?? 0));
|
|
688
|
+
const regularInputTokens = inputTokens > cachedTokens ? inputTokens - cachedTokens : 0n;
|
|
689
|
+
const rateInputNano = BigInt(Math.round(rates.inputPer1M * 1e3));
|
|
690
|
+
const cachedPer1M = rates.cachedInputPer1M ?? rates.inputPer1M * 0.15;
|
|
691
|
+
const rateCachedNano = BigInt(Math.round(cachedPer1M * 1e3));
|
|
692
|
+
const rateOutputNano = BigInt(Math.round(rates.outputPer1M * 1e3));
|
|
693
|
+
const reasoningPer1M = rates.reasoningPer1M ?? rates.outputPer1M;
|
|
694
|
+
const rateReasoningNano = BigInt(Math.round(reasoningPer1M * 1e3));
|
|
695
|
+
const regularInputCostNano = regularInputTokens * rateInputNano;
|
|
696
|
+
const cachedInputCostNano = cachedTokens * rateCachedNano;
|
|
697
|
+
const inputCostNano = regularInputCostNano + cachedInputCostNano;
|
|
698
|
+
const outputCostNano = outputTokens * rateOutputNano;
|
|
699
|
+
const reasoningCostNano = reasoningTokens * rateReasoningNano;
|
|
700
|
+
const standardCacheCostNano = cachedTokens * rateInputNano;
|
|
701
|
+
const cachedDiscountNano = standardCacheCostNano > cachedInputCostNano ? standardCacheCostNano - cachedInputCostNano : 0n;
|
|
702
|
+
const wholesaleNano = inputCostNano + outputCostNano;
|
|
587
703
|
const markup = params.markupMultiplier ?? 1;
|
|
588
|
-
let
|
|
704
|
+
let billedNano = wholesaleNano;
|
|
705
|
+
let hasRetail = false;
|
|
589
706
|
if (markup !== 1 || params.minimumChargeUSD !== void 0) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
707
|
+
hasRetail = true;
|
|
708
|
+
const markupMultiplierNano = BigInt(Math.round(markup * 1e3));
|
|
709
|
+
billedNano = wholesaleNano * markupMultiplierNano / 1000n;
|
|
710
|
+
if (params.minimumChargeUSD !== void 0 && params.minimumChargeUSD > 0) {
|
|
711
|
+
const minChargeNano = BigInt(Math.round(params.minimumChargeUSD * 1e9));
|
|
712
|
+
if (billedNano < minChargeNano) {
|
|
713
|
+
billedNano = minChargeNano;
|
|
714
|
+
}
|
|
593
715
|
}
|
|
594
716
|
}
|
|
717
|
+
const inputCostUSD = Number(inputCostNano) / 1e9;
|
|
718
|
+
const outputCostUSD = Number(outputCostNano) / 1e9;
|
|
719
|
+
const reasoningCostUSD = Number(reasoningCostNano) / 1e9;
|
|
720
|
+
const cachedDiscountUSD = Number(cachedDiscountNano) / 1e9;
|
|
721
|
+
const totalUSD = Number(wholesaleNano) / 1e9;
|
|
722
|
+
const wholesaleTotalUSD = totalUSD;
|
|
723
|
+
const billedUSD = Number(billedNano) / 1e9;
|
|
724
|
+
const profitUSD = Math.max(0, billedUSD - wholesaleTotalUSD);
|
|
725
|
+
const retailUSD = hasRetail ? billedUSD : void 0;
|
|
595
726
|
return {
|
|
596
727
|
inputCostUSD: Number(inputCostUSD.toFixed(8)),
|
|
597
728
|
outputCostUSD: Number(outputCostUSD.toFixed(8)),
|
|
598
|
-
reasoningCostUSD: reasoningTokens >
|
|
599
|
-
cachedDiscountUSD: cachedTokens >
|
|
729
|
+
reasoningCostUSD: reasoningTokens > 0n ? Number(reasoningCostUSD.toFixed(8)) : void 0,
|
|
730
|
+
cachedDiscountUSD: cachedTokens > 0n ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
|
|
600
731
|
totalUSD: Number(totalUSD.toFixed(8)),
|
|
732
|
+
wholesaleTotalUSD: Number(wholesaleTotalUSD.toFixed(8)),
|
|
733
|
+
billedUSD: Number(billedUSD.toFixed(8)),
|
|
734
|
+
profitUSD: Number(profitUSD.toFixed(8)),
|
|
601
735
|
retailUSD: retailUSD !== void 0 ? Number(retailUSD.toFixed(8)) : void 0,
|
|
602
736
|
currency: rates.currency || "USD"
|
|
603
737
|
};
|
|
@@ -803,7 +937,7 @@ function wrapUniversalStream(stream, options = {}, onComplete) {
|
|
|
803
937
|
return wrapGeminiStream(stream, options, onComplete);
|
|
804
938
|
}
|
|
805
939
|
if (Symbol.asyncIterator in stream) {
|
|
806
|
-
if (options.provider === "anthropic") {
|
|
940
|
+
if (options.provider === "anthropic" || options.model?.toLowerCase().includes("claude")) {
|
|
807
941
|
return wrapAnthropicStream(stream, options, onComplete);
|
|
808
942
|
}
|
|
809
943
|
return wrapOpenAIStream(stream, options, onComplete);
|
|
@@ -825,7 +959,7 @@ var VibezMeter = class {
|
|
|
825
959
|
this.stripeClient = new Stripe(key, {
|
|
826
960
|
appInfo: {
|
|
827
961
|
name: "vibezcheck",
|
|
828
|
-
version: "0.
|
|
962
|
+
version: "0.5.3",
|
|
829
963
|
url: "https://vibezcheck.xyz"
|
|
830
964
|
}
|
|
831
965
|
});
|
|
@@ -932,10 +1066,20 @@ function createMeter(options = {}) {
|
|
|
932
1066
|
}
|
|
933
1067
|
|
|
934
1068
|
// src/ai-sdk/with-billing.ts
|
|
935
|
-
function withBilling(model,
|
|
1069
|
+
function withBilling(model, optionsOrCustomer, extraOptions = {}) {
|
|
936
1070
|
if (!model || typeof model !== "object") {
|
|
937
1071
|
return model;
|
|
938
1072
|
}
|
|
1073
|
+
let options = {};
|
|
1074
|
+
if (typeof optionsOrCustomer === "string") {
|
|
1075
|
+
options = { ...extraOptions, customer: optionsOrCustomer };
|
|
1076
|
+
} else if (typeof optionsOrCustomer === "object" && optionsOrCustomer !== null) {
|
|
1077
|
+
if ("userId" in optionsOrCustomer || "email" in optionsOrCustomer || "id" in optionsOrCustomer) {
|
|
1078
|
+
options = { ...extraOptions, customer: optionsOrCustomer };
|
|
1079
|
+
} else {
|
|
1080
|
+
options = { ...optionsOrCustomer, ...extraOptions };
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
939
1083
|
const meter = options.meter || createMeter({
|
|
940
1084
|
apiKey: options.stripeApiKey,
|
|
941
1085
|
eventName: options.eventName
|
|
@@ -964,17 +1108,19 @@ function withBilling(model, options = {}) {
|
|
|
964
1108
|
};
|
|
965
1109
|
const handleUsage = (rawUsage, extraMeta) => {
|
|
966
1110
|
if (!rawUsage) return;
|
|
967
|
-
const inputTokens = rawUsage.promptTokens ?? rawUsage.inputTokens ?? 0;
|
|
968
|
-
const outputTokens = rawUsage.completionTokens ?? rawUsage.outputTokens ?? 0;
|
|
969
|
-
const reasoningTokens = rawUsage.reasoningTokens ?? rawUsage.completionTokensDetails?.reasoningTokens ?? rawUsage.outputTokenDetails?.reasoningTokens ?? 0;
|
|
970
|
-
const cachedTokens = rawUsage.promptTokensDetails?.cachedTokens ?? rawUsage.inputTokenDetails?.cachedTokens ?? 0;
|
|
1111
|
+
const inputTokens = rawUsage.promptTokens ?? rawUsage.inputTokens ?? rawUsage.prompt_tokens ?? rawUsage.input_tokens ?? rawUsage.promptTokenCount ?? 0;
|
|
1112
|
+
const outputTokens = rawUsage.completionTokens ?? rawUsage.outputTokens ?? rawUsage.completion_tokens ?? rawUsage.output_tokens ?? rawUsage.candidatesTokenCount ?? 0;
|
|
1113
|
+
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;
|
|
1114
|
+
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;
|
|
1115
|
+
const cacheWriteTokens = rawUsage.cacheWriteTokens ?? rawUsage.cache_creation_input_tokens ?? rawUsage.cacheCreationTokens ?? 0;
|
|
971
1116
|
const usage = {
|
|
972
1117
|
inputTokens,
|
|
973
1118
|
outputTokens,
|
|
974
1119
|
totalTokens: inputTokens + outputTokens,
|
|
975
1120
|
reasoningTokens: reasoningTokens > 0 ? reasoningTokens : void 0,
|
|
976
1121
|
visibleOutputTokens: Math.max(0, outputTokens - reasoningTokens),
|
|
977
|
-
cachedTokens: cachedTokens > 0 ? cachedTokens : void 0
|
|
1122
|
+
cachedTokens: cachedTokens > 0 ? cachedTokens : void 0,
|
|
1123
|
+
cacheWriteTokens: cacheWriteTokens > 0 ? cacheWriteTokens : void 0
|
|
978
1124
|
};
|
|
979
1125
|
const cost = calculateUsageCost(modelId, usage, {
|
|
980
1126
|
markupMultiplier: options.pricing?.margin,
|
|
@@ -1075,7 +1221,9 @@ function withBilling(model, options = {}) {
|
|
|
1075
1221
|
return;
|
|
1076
1222
|
}
|
|
1077
1223
|
} catch (err) {
|
|
1078
|
-
|
|
1224
|
+
if (process.env.NODE_ENV !== "test" && !options.silent) {
|
|
1225
|
+
console.warn(`[vibezcheck] Database record failed safely:`, err?.message || err);
|
|
1226
|
+
}
|
|
1079
1227
|
}
|
|
1080
1228
|
};
|
|
1081
1229
|
if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
|
|
@@ -1091,7 +1239,9 @@ function withBilling(model, options = {}) {
|
|
|
1091
1239
|
try {
|
|
1092
1240
|
await chargeFn(cost.totalUSD, event);
|
|
1093
1241
|
} catch (err) {
|
|
1094
|
-
|
|
1242
|
+
if (process.env.NODE_ENV !== "test" && !options.silent) {
|
|
1243
|
+
console.warn(`[vibezcheck] Custom charge handler failed safely:`, err?.message || err);
|
|
1244
|
+
}
|
|
1095
1245
|
}
|
|
1096
1246
|
};
|
|
1097
1247
|
if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
|
|
@@ -1106,7 +1256,9 @@ function withBilling(model, options = {}) {
|
|
|
1106
1256
|
try {
|
|
1107
1257
|
await providerCharge(cost.totalUSD, event);
|
|
1108
1258
|
} catch (err) {
|
|
1109
|
-
|
|
1259
|
+
if (process.env.NODE_ENV !== "test" && !options.silent) {
|
|
1260
|
+
console.warn(`[vibezcheck] Payment provider charge failed safely:`, err?.message || err);
|
|
1261
|
+
}
|
|
1110
1262
|
}
|
|
1111
1263
|
};
|
|
1112
1264
|
if (typeof globalThis !== "undefined" && typeof globalThis.after === "function") {
|
|
@@ -1161,14 +1313,19 @@ function withBilling(model, options = {}) {
|
|
|
1161
1313
|
const transformStream = new TransformStream({
|
|
1162
1314
|
transform(chunk, controller) {
|
|
1163
1315
|
controller.enqueue(chunk);
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1316
|
+
const delta = chunk.textDelta || chunk.text || chunk.delta;
|
|
1317
|
+
if (delta && typeof delta === "string") {
|
|
1318
|
+
accumulatedChars += delta.length;
|
|
1319
|
+
} else if (chunk.type === "reasoning" || chunk.type === "reasoning-delta") {
|
|
1320
|
+
const reasoning = chunk.reasoning || chunk.textDelta || chunk.text || chunk.delta || "";
|
|
1321
|
+
if (typeof reasoning === "string") {
|
|
1322
|
+
accumulatedChars += reasoning.length;
|
|
1323
|
+
}
|
|
1168
1324
|
}
|
|
1169
|
-
|
|
1325
|
+
const chunkUsage = chunk.usage || chunk.token_usage || chunk.usageMetadata;
|
|
1326
|
+
if (chunkUsage) {
|
|
1170
1327
|
streamCompleted = true;
|
|
1171
|
-
handleUsage(
|
|
1328
|
+
handleUsage(chunkUsage);
|
|
1172
1329
|
}
|
|
1173
1330
|
},
|
|
1174
1331
|
flush() {
|
|
@@ -1194,13 +1351,29 @@ function withBilling(model, options = {}) {
|
|
|
1194
1351
|
if (prop === "doGenerate" && typeof originalValue === "function") {
|
|
1195
1352
|
return async function(...args) {
|
|
1196
1353
|
const result = await originalValue.apply(target, args);
|
|
1197
|
-
|
|
1198
|
-
|
|
1354
|
+
const usage = result?.usage || result?.tokenUsage || result?.usageMetadata;
|
|
1355
|
+
if (usage) {
|
|
1356
|
+
handleUsage(usage);
|
|
1199
1357
|
}
|
|
1200
1358
|
return result;
|
|
1201
1359
|
};
|
|
1202
1360
|
}
|
|
1203
1361
|
return originalValue;
|
|
1362
|
+
},
|
|
1363
|
+
apply(target, thisArg, argArray) {
|
|
1364
|
+
if (typeof target === "function") {
|
|
1365
|
+
return Reflect.apply(target, thisArg, argArray);
|
|
1366
|
+
}
|
|
1367
|
+
return target;
|
|
1368
|
+
},
|
|
1369
|
+
has(target, prop) {
|
|
1370
|
+
return Reflect.has(target, prop);
|
|
1371
|
+
},
|
|
1372
|
+
ownKeys(target) {
|
|
1373
|
+
return Reflect.ownKeys(target);
|
|
1374
|
+
},
|
|
1375
|
+
getPrototypeOf(target) {
|
|
1376
|
+
return Reflect.getPrototypeOf(target);
|
|
1204
1377
|
}
|
|
1205
1378
|
};
|
|
1206
1379
|
return new Proxy(model, handler);
|
|
@@ -1220,23 +1393,88 @@ function createVibezModel(modelOrId, options = {}) {
|
|
|
1220
1393
|
const parts = rawId.split("/");
|
|
1221
1394
|
providerName = parts[0].toLowerCase();
|
|
1222
1395
|
cleanModelId = parts.slice(1).join("/");
|
|
1396
|
+
} else if (rawId.startsWith("claude-")) {
|
|
1397
|
+
providerName = "anthropic";
|
|
1398
|
+
} else if (rawId.startsWith("gemini-")) {
|
|
1399
|
+
providerName = "google";
|
|
1400
|
+
} else if (rawId.startsWith("deepseek-")) {
|
|
1401
|
+
providerName = "deepseek";
|
|
1402
|
+
} else if (rawId.startsWith("grok-")) {
|
|
1403
|
+
providerName = "xai";
|
|
1404
|
+
} else if (rawId.startsWith("mistral-") || rawId.startsWith("codestral-") || rawId.startsWith("ministral-") || rawId.startsWith("open-mistral") || rawId.startsWith("open-mixtral")) {
|
|
1405
|
+
providerName = "mistral";
|
|
1406
|
+
} else if (rawId.startsWith("llama-") || rawId.startsWith("mixtral-") || rawId.startsWith("gemma") || rawId.startsWith("qwen-")) {
|
|
1407
|
+
providerName = "groq";
|
|
1408
|
+
} else if (rawId.startsWith("command-")) {
|
|
1409
|
+
providerName = "cohere";
|
|
1223
1410
|
}
|
|
1224
|
-
const apiKey = options.apiKey || process.env.AI_GATEWAY_API_KEY || process.env.
|
|
1411
|
+
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;
|
|
1225
1412
|
const baseURL = options.baseURL || process.env.AI_GATEWAY_BASE_URL || (providerName === "openai" ? "https://api.openai.com/v1" : void 0);
|
|
1226
1413
|
let baseModelInstance = null;
|
|
1227
1414
|
try {
|
|
1228
1415
|
if (providerName === "openai" || providerName === "gateway" || !providerName) {
|
|
1229
|
-
const
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1416
|
+
const mod = __require("@ai-sdk/openai");
|
|
1417
|
+
const factory = mod.createOpenAI || mod.openai || mod.default?.createOpenAI || mod.default?.openai;
|
|
1418
|
+
if (typeof factory === "function") {
|
|
1419
|
+
if (mod.createOpenAI) {
|
|
1420
|
+
const provider = factory({ apiKey, baseURL });
|
|
1421
|
+
baseModelInstance = provider(cleanModelId);
|
|
1422
|
+
} else {
|
|
1423
|
+
baseModelInstance = factory(cleanModelId);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1232
1426
|
} else if (providerName === "anthropic") {
|
|
1233
|
-
const
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1427
|
+
const mod = __require("@ai-sdk/anthropic");
|
|
1428
|
+
const factory = mod.createAnthropic || mod.anthropic || mod.default?.createAnthropic || mod.default?.anthropic;
|
|
1429
|
+
if (typeof factory === "function") {
|
|
1430
|
+
if (mod.createAnthropic) {
|
|
1431
|
+
const provider = factory({ apiKey, baseURL });
|
|
1432
|
+
baseModelInstance = provider(cleanModelId);
|
|
1433
|
+
} else {
|
|
1434
|
+
baseModelInstance = factory(cleanModelId);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1236
1437
|
} else if (providerName === "google") {
|
|
1237
|
-
const
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1438
|
+
const mod = __require("@ai-sdk/google");
|
|
1439
|
+
const factory = mod.createGoogleGenerativeAI || mod.google || mod.default?.createGoogleGenerativeAI || mod.default?.google;
|
|
1440
|
+
if (typeof factory === "function") {
|
|
1441
|
+
if (mod.createGoogleGenerativeAI) {
|
|
1442
|
+
const provider = factory({ apiKey, baseURL });
|
|
1443
|
+
baseModelInstance = provider(cleanModelId);
|
|
1444
|
+
} else {
|
|
1445
|
+
baseModelInstance = factory(cleanModelId);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
} else if (providerName === "mistral") {
|
|
1449
|
+
const mod = __require("@ai-sdk/mistral");
|
|
1450
|
+
const factory = mod.createMistral || mod.mistral || mod.default?.createMistral || mod.default?.mistral;
|
|
1451
|
+
if (typeof factory === "function") {
|
|
1452
|
+
baseModelInstance = mod.createMistral ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1453
|
+
}
|
|
1454
|
+
} else if (providerName === "groq") {
|
|
1455
|
+
const mod = __require("@ai-sdk/groq");
|
|
1456
|
+
const factory = mod.createGroq || mod.groq || mod.default?.createGroq || mod.default?.groq;
|
|
1457
|
+
if (typeof factory === "function") {
|
|
1458
|
+
baseModelInstance = mod.createGroq ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1459
|
+
}
|
|
1460
|
+
} else if (providerName === "deepseek") {
|
|
1461
|
+
const mod = __require("@ai-sdk/deepseek");
|
|
1462
|
+
const factory = mod.createDeepSeek || mod.deepseek || mod.default?.createDeepSeek || mod.default?.deepseek;
|
|
1463
|
+
if (typeof factory === "function") {
|
|
1464
|
+
baseModelInstance = mod.createDeepSeek ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1465
|
+
}
|
|
1466
|
+
} else if (providerName === "xai") {
|
|
1467
|
+
const mod = __require("@ai-sdk/xai");
|
|
1468
|
+
const factory = mod.createXai || mod.xai || mod.default?.createXai || mod.default?.xai;
|
|
1469
|
+
if (typeof factory === "function") {
|
|
1470
|
+
baseModelInstance = mod.createXai ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1471
|
+
}
|
|
1472
|
+
} else if (providerName === "cohere") {
|
|
1473
|
+
const mod = __require("@ai-sdk/cohere");
|
|
1474
|
+
const factory = mod.createCohere || mod.cohere || mod.default?.createCohere || mod.default?.cohere;
|
|
1475
|
+
if (typeof factory === "function") {
|
|
1476
|
+
baseModelInstance = mod.createCohere ? factory({ apiKey, baseURL })(cleanModelId) : factory(cleanModelId);
|
|
1477
|
+
}
|
|
1240
1478
|
}
|
|
1241
1479
|
} catch {
|
|
1242
1480
|
baseModelInstance = {
|