vibezcheck 0.4.2 → 0.5.0

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 (78) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +230 -273
  3. package/bin/vibezcheck.js +4 -4
  4. package/dist/ai-sdk/index.d.mts +28 -59
  5. package/dist/ai-sdk/index.d.ts +28 -59
  6. package/dist/ai-sdk/index.js +79 -32
  7. package/dist/ai-sdk/index.js.map +1 -1
  8. package/dist/ai-sdk/index.mjs +79 -32
  9. package/dist/ai-sdk/index.mjs.map +1 -1
  10. package/dist/ai-sdk/middleware.d.mts +15 -0
  11. package/dist/ai-sdk/middleware.d.ts +15 -0
  12. package/dist/ai-sdk/middleware.js +1280 -0
  13. package/dist/ai-sdk/middleware.js.map +1 -0
  14. package/dist/ai-sdk/middleware.mjs +1243 -0
  15. package/dist/ai-sdk/middleware.mjs.map +1 -0
  16. package/dist/auth/index.js.map +1 -1
  17. package/dist/auth/index.mjs.map +1 -1
  18. package/dist/billing/index.d.mts +90 -1
  19. package/dist/billing/index.d.ts +90 -1
  20. package/dist/billing/index.js +1391 -2
  21. package/dist/billing/index.js.map +1 -1
  22. package/dist/billing/index.mjs +1386 -1
  23. package/dist/billing/index.mjs.map +1 -1
  24. package/dist/cli/index.js.map +1 -1
  25. package/dist/cli/index.mjs.map +1 -1
  26. package/dist/{client-ynfWcHX6.d.ts → client-CJ2Dj8ID.d.ts} +1 -1
  27. package/dist/{client-w_hWhQ6g.d.mts → client-Dmwb3hQt.d.mts} +1 -1
  28. package/dist/compat/stripe-meter.d.mts +21 -0
  29. package/dist/compat/stripe-meter.d.ts +21 -0
  30. package/dist/compat/stripe-meter.js +1281 -0
  31. package/dist/compat/stripe-meter.js.map +1 -0
  32. package/dist/compat/stripe-meter.mjs +1244 -0
  33. package/dist/compat/stripe-meter.mjs.map +1 -0
  34. package/dist/compat/stripe-provider.d.mts +54 -0
  35. package/dist/compat/stripe-provider.d.ts +54 -0
  36. package/dist/compat/stripe-provider.js +1304 -0
  37. package/dist/compat/stripe-provider.js.map +1 -0
  38. package/dist/compat/stripe-provider.mjs +1264 -0
  39. package/dist/compat/stripe-provider.mjs.map +1 -0
  40. package/dist/compat/token-meter.d.mts +16 -0
  41. package/dist/compat/token-meter.d.ts +16 -0
  42. package/dist/compat/token-meter.js +1095 -0
  43. package/dist/compat/token-meter.js.map +1 -0
  44. package/dist/compat/token-meter.mjs +1058 -0
  45. package/dist/compat/token-meter.mjs.map +1 -0
  46. package/dist/customers/index.d.mts +1 -1
  47. package/dist/customers/index.d.ts +1 -1
  48. package/dist/customers/index.js.map +1 -1
  49. package/dist/customers/index.mjs.map +1 -1
  50. package/dist/index.d.mts +22 -11
  51. package/dist/index.d.ts +22 -11
  52. package/dist/index.js +269 -33
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +265 -33
  55. package/dist/index.mjs.map +1 -1
  56. package/dist/meter/index.d.mts +2 -2
  57. package/dist/meter/index.d.ts +2 -2
  58. package/dist/meter/index.js +44 -22
  59. package/dist/meter/index.js.map +1 -1
  60. package/dist/meter/index.mjs +44 -22
  61. package/dist/meter/index.mjs.map +1 -1
  62. package/dist/pricing/index.d.mts +5 -2
  63. package/dist/pricing/index.d.ts +5 -2
  64. package/dist/pricing/index.js +43 -21
  65. package/dist/pricing/index.js.map +1 -1
  66. package/dist/pricing/index.mjs +43 -21
  67. package/dist/pricing/index.mjs.map +1 -1
  68. package/dist/react/index.d.mts +46 -2
  69. package/dist/react/index.d.ts +46 -2
  70. package/dist/react/index.js +351 -21
  71. package/dist/react/index.js.map +1 -1
  72. package/dist/react/index.mjs +349 -21
  73. package/dist/react/index.mjs.map +1 -1
  74. package/dist/{types-Mozk4-Mr.d.mts → types-BVGqbKnY.d.mts} +6 -0
  75. package/dist/{types-Mozk4-Mr.d.ts → types-BVGqbKnY.d.ts} +6 -0
  76. package/dist/with-billing-CDqKIAQ6.d.ts +47 -0
  77. package/dist/with-billing-mci2vtFS.d.mts +47 -0
  78. package/package.json +26 -1
@@ -1,54 +1,13 @@
1
- import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, g as PricingConfig, e as InlineRateConfig, U as UsageEvent } from '../types-Mozk4-Mr.mjs';
2
- import { V as VibezMeter } from '../client-w_hWhQ6g.mjs';
1
+ import { W as WithBillingOptions } from '../with-billing-mci2vtFS.mjs';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-mci2vtFS.mjs';
3
+ import { C as CustomerParam } from '../types-BVGqbKnY.mjs';
4
+ import { V as VibezMeter } from '../client-Dmwb3hQt.mjs';
3
5
  import 'stripe';
4
6
 
5
- interface WithBillingOptions extends CircuitBreakerOptions {
6
- /** Customer email, user ID, or rich customer object with metadata */
7
- customer?: CustomerParam;
8
- /** Direct Stripe customer ID */
9
- customerId?: string;
10
- /** Billing mode configuration (Universal Auto-Debit, postpaid vs prepaid, pluggable providers) */
11
- billing?: BillingConfig;
12
- /** Profit margin & minimum charge configuration */
13
- pricing?: PricingConfig;
14
- /** 1-line inline pricing rate card */
15
- rate?: InlineRateConfig;
16
- /** Pluggable Database Sink (Supabase, Postgres, Firebase, or 1-line callback) */
17
- database?: any | ((event: UsageEvent) => void | Promise<void>);
18
- /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
19
- captureOnAbort?: boolean;
20
- /** Execution runtime environment (default: 'auto') */
21
- runtime?: 'auto' | 'serverless' | 'edge' | 'node';
22
- /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
23
- stripeApiKey?: string;
24
- /** Existing VibezMeter instance (optional) */
25
- meter?: VibezMeter;
26
- /** Custom meter event name */
27
- eventName?: string;
28
- /** Usage callback fired upon generation/stream completion */
29
- onUsage?: (event: UsageEvent) => void | Promise<void>;
30
- /** Custom developer metadata */
31
- metadata?: Record<string, string | number | boolean>;
32
- }
33
- /**
34
- * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
35
- *
36
- * Sane Defaults Built-In:
37
- * - $0.50 safety ceiling per call (overridable)
38
- * - Automatic in-flight token capture on abort
39
- * - Automatic prompt caching discount parsing
40
- * - Serverless lifecycle preservation
41
- */
42
- declare function withBilling<T extends object>(model: T, options?: WithBillingOptions): T;
43
- /**
44
- * Convenient alias for withBilling
45
- */
46
- declare const meteredModel: typeof withBilling;
47
-
48
7
  interface VibezCheckModelOptions extends WithBillingOptions {
49
- /** OpenAI / AI Gateway API Key override */
8
+ /** OpenAI / Anthropic / AI Gateway API Key override */
50
9
  apiKey?: string;
51
- /** AI Gateway / OpenAI Base URL override */
10
+ /** AI Gateway / Provider Base URL override */
52
11
  baseURL?: string;
53
12
  }
54
13
  interface VibezSessionOptions {
@@ -72,23 +31,33 @@ interface VibezSession {
72
31
  /**
73
32
  * Creates or resolves an AI SDK compatible LanguageModel with built-in VibezCheck billing & metering.
74
33
  *
34
+ * Supports:
35
+ * - Direct instances: `vibezcheck(openai('gpt-4o'))`, `vibezcheck(anthropic('claude-3-7-sonnet'))`
36
+ * - String identifiers: `vibezcheck('openai/gpt-4o-mini')`, `vibezcheck('anthropic/claude-3-5-sonnet')`, `vibezcheck('gpt-4o')`
37
+ * - Vercel AI SDK primitives: `generateText`, `streamText`, `generateObject`, `streamObject`
38
+ *
75
39
  * @example
76
40
  * ```typescript
77
- * import { generateText, streamText } from 'ai';
41
+ * import { streamText } from 'ai';
42
+ * import { openai } from '@ai-sdk/openai';
43
+ * import { anthropic } from '@ai-sdk/anthropic';
78
44
  * import { vibezcheck } from 'vibezcheck';
79
45
  *
80
- * // 1. Declarative string model identifier:
81
- * const { text } = await generateText({
82
- * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
83
- * prompt: 'What is love?',
46
+ * // 1. Pass wrapped OpenAI instance:
47
+ * const result = streamText({
48
+ * model: vibezcheck(openai('gpt-4o-mini'), { customer: 'alex@example.com' }),
49
+ * messages,
84
50
  * });
85
51
  *
86
- * // 2. Works with all Vercel AI SDK primitives (streamText, generateObject, streamObject):
87
- * const result = streamText({
88
- * model: vibezcheck('gpt-4o', {
89
- * customer: 'alex@example.com',
90
- * pricing: { margin: 1.5 }, // 50% profit margin
91
- * }),
52
+ * // 2. Pass wrapped Anthropic instance:
53
+ * const result2 = streamText({
54
+ * model: vibezcheck(anthropic('claude-3-7-sonnet'), { customer: 'alex@example.com' }),
55
+ * messages,
56
+ * });
57
+ *
58
+ * // 3. Use 1-line string identifier:
59
+ * const result3 = streamText({
60
+ * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
92
61
  * messages,
93
62
  * });
94
63
  * ```
@@ -102,4 +71,4 @@ declare const vibezcheck: typeof createVibezModel & {
102
71
  session: typeof createVibezSession;
103
72
  };
104
73
 
105
- export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, type WithBillingOptions, createVibezModel, createVibezSession, meteredModel, vibezcheck, withBilling };
74
+ export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, WithBillingOptions, createVibezModel, createVibezSession, vibezcheck };
@@ -1,54 +1,13 @@
1
- import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, g as PricingConfig, e as InlineRateConfig, U as UsageEvent } from '../types-Mozk4-Mr.js';
2
- import { V as VibezMeter } from '../client-ynfWcHX6.js';
1
+ import { W as WithBillingOptions } from '../with-billing-CDqKIAQ6.js';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-CDqKIAQ6.js';
3
+ import { C as CustomerParam } from '../types-BVGqbKnY.js';
4
+ import { V as VibezMeter } from '../client-CJ2Dj8ID.js';
3
5
  import 'stripe';
4
6
 
5
- interface WithBillingOptions extends CircuitBreakerOptions {
6
- /** Customer email, user ID, or rich customer object with metadata */
7
- customer?: CustomerParam;
8
- /** Direct Stripe customer ID */
9
- customerId?: string;
10
- /** Billing mode configuration (Universal Auto-Debit, postpaid vs prepaid, pluggable providers) */
11
- billing?: BillingConfig;
12
- /** Profit margin & minimum charge configuration */
13
- pricing?: PricingConfig;
14
- /** 1-line inline pricing rate card */
15
- rate?: InlineRateConfig;
16
- /** Pluggable Database Sink (Supabase, Postgres, Firebase, or 1-line callback) */
17
- database?: any | ((event: UsageEvent) => void | Promise<void>);
18
- /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
19
- captureOnAbort?: boolean;
20
- /** Execution runtime environment (default: 'auto') */
21
- runtime?: 'auto' | 'serverless' | 'edge' | 'node';
22
- /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
23
- stripeApiKey?: string;
24
- /** Existing VibezMeter instance (optional) */
25
- meter?: VibezMeter;
26
- /** Custom meter event name */
27
- eventName?: string;
28
- /** Usage callback fired upon generation/stream completion */
29
- onUsage?: (event: UsageEvent) => void | Promise<void>;
30
- /** Custom developer metadata */
31
- metadata?: Record<string, string | number | boolean>;
32
- }
33
- /**
34
- * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
35
- *
36
- * Sane Defaults Built-In:
37
- * - $0.50 safety ceiling per call (overridable)
38
- * - Automatic in-flight token capture on abort
39
- * - Automatic prompt caching discount parsing
40
- * - Serverless lifecycle preservation
41
- */
42
- declare function withBilling<T extends object>(model: T, options?: WithBillingOptions): T;
43
- /**
44
- * Convenient alias for withBilling
45
- */
46
- declare const meteredModel: typeof withBilling;
47
-
48
7
  interface VibezCheckModelOptions extends WithBillingOptions {
49
- /** OpenAI / AI Gateway API Key override */
8
+ /** OpenAI / Anthropic / AI Gateway API Key override */
50
9
  apiKey?: string;
51
- /** AI Gateway / OpenAI Base URL override */
10
+ /** AI Gateway / Provider Base URL override */
52
11
  baseURL?: string;
53
12
  }
54
13
  interface VibezSessionOptions {
@@ -72,23 +31,33 @@ interface VibezSession {
72
31
  /**
73
32
  * Creates or resolves an AI SDK compatible LanguageModel with built-in VibezCheck billing & metering.
74
33
  *
34
+ * Supports:
35
+ * - Direct instances: `vibezcheck(openai('gpt-4o'))`, `vibezcheck(anthropic('claude-3-7-sonnet'))`
36
+ * - String identifiers: `vibezcheck('openai/gpt-4o-mini')`, `vibezcheck('anthropic/claude-3-5-sonnet')`, `vibezcheck('gpt-4o')`
37
+ * - Vercel AI SDK primitives: `generateText`, `streamText`, `generateObject`, `streamObject`
38
+ *
75
39
  * @example
76
40
  * ```typescript
77
- * import { generateText, streamText } from 'ai';
41
+ * import { streamText } from 'ai';
42
+ * import { openai } from '@ai-sdk/openai';
43
+ * import { anthropic } from '@ai-sdk/anthropic';
78
44
  * import { vibezcheck } from 'vibezcheck';
79
45
  *
80
- * // 1. Declarative string model identifier:
81
- * const { text } = await generateText({
82
- * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
83
- * prompt: 'What is love?',
46
+ * // 1. Pass wrapped OpenAI instance:
47
+ * const result = streamText({
48
+ * model: vibezcheck(openai('gpt-4o-mini'), { customer: 'alex@example.com' }),
49
+ * messages,
84
50
  * });
85
51
  *
86
- * // 2. Works with all Vercel AI SDK primitives (streamText, generateObject, streamObject):
87
- * const result = streamText({
88
- * model: vibezcheck('gpt-4o', {
89
- * customer: 'alex@example.com',
90
- * pricing: { margin: 1.5 }, // 50% profit margin
91
- * }),
52
+ * // 2. Pass wrapped Anthropic instance:
53
+ * const result2 = streamText({
54
+ * model: vibezcheck(anthropic('claude-3-7-sonnet'), { customer: 'alex@example.com' }),
55
+ * messages,
56
+ * });
57
+ *
58
+ * // 3. Use 1-line string identifier:
59
+ * const result3 = streamText({
60
+ * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
92
61
  * messages,
93
62
  * });
94
63
  * ```
@@ -102,4 +71,4 @@ declare const vibezcheck: typeof createVibezModel & {
102
71
  session: typeof createVibezSession;
103
72
  };
104
73
 
105
- export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, type WithBillingOptions, createVibezModel, createVibezSession, meteredModel, vibezcheck, withBilling };
74
+ export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, WithBillingOptions, createVibezModel, createVibezSession, vibezcheck };
@@ -602,35 +602,57 @@ function calculateCost(params) {
602
602
  } else {
603
603
  rates = getModelPricing(params.model);
604
604
  }
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 = Math.max(0, inputTokens - cachedTokens);
610
- const regularInputCost = regularInputTokens / 1e6 * rates.inputPer1M;
611
- const cachedRate = rates.cachedInputPer1M ?? rates.inputPer1M * 0.15;
612
- const cachedInputCost = cachedTokens / 1e6 * cachedRate;
613
- const inputCostUSD = regularInputCost + cachedInputCost;
614
- const outputCostUSD = outputTokens / 1e6 * rates.outputPer1M;
615
- const reasoningRate = rates.reasoningPer1M ?? rates.outputPer1M;
616
- const reasoningCostUSD = reasoningTokens / 1e6 * reasoningRate;
617
- const standardCacheCost = cachedTokens / 1e6 * rates.inputPer1M;
618
- const cachedDiscountUSD = Math.max(0, standardCacheCost - cachedInputCost);
619
- let totalUSD = inputCostUSD + outputCostUSD;
605
+ const inputTokens = BigInt(Math.max(0, params.inputTokens ?? 0));
606
+ const outputTokens = BigInt(Math.max(0, params.outputTokens ?? 0));
607
+ const reasoningTokens = BigInt(Math.max(0, params.reasoningTokens ?? 0));
608
+ const cachedTokens = BigInt(Math.max(0, params.cachedTokens ?? 0));
609
+ const regularInputTokens = inputTokens > cachedTokens ? inputTokens - cachedTokens : 0n;
610
+ const rateInputNano = BigInt(Math.round(rates.inputPer1M * 1e3));
611
+ const cachedPer1M = rates.cachedInputPer1M ?? rates.inputPer1M * 0.15;
612
+ const rateCachedNano = BigInt(Math.round(cachedPer1M * 1e3));
613
+ const rateOutputNano = BigInt(Math.round(rates.outputPer1M * 1e3));
614
+ const reasoningPer1M = rates.reasoningPer1M ?? rates.outputPer1M;
615
+ const rateReasoningNano = BigInt(Math.round(reasoningPer1M * 1e3));
616
+ const regularInputCostNano = regularInputTokens * rateInputNano;
617
+ const cachedInputCostNano = cachedTokens * rateCachedNano;
618
+ const inputCostNano = regularInputCostNano + cachedInputCostNano;
619
+ const outputCostNano = outputTokens * rateOutputNano;
620
+ const reasoningCostNano = reasoningTokens * rateReasoningNano;
621
+ const standardCacheCostNano = cachedTokens * rateInputNano;
622
+ const cachedDiscountNano = standardCacheCostNano > cachedInputCostNano ? standardCacheCostNano - cachedInputCostNano : 0n;
623
+ const wholesaleNano = inputCostNano + outputCostNano;
620
624
  const markup = params.markupMultiplier ?? 1;
621
- let retailUSD = void 0;
625
+ let billedNano = wholesaleNano;
626
+ let hasRetail = false;
622
627
  if (markup !== 1 || params.minimumChargeUSD !== void 0) {
623
- retailUSD = totalUSD * markup;
624
- if (params.minimumChargeUSD !== void 0 && retailUSD < params.minimumChargeUSD) {
625
- retailUSD = params.minimumChargeUSD;
628
+ hasRetail = true;
629
+ const markupMultiplierNano = BigInt(Math.round(markup * 1e3));
630
+ billedNano = wholesaleNano * markupMultiplierNano / 1000n;
631
+ if (params.minimumChargeUSD !== void 0 && params.minimumChargeUSD > 0) {
632
+ const minChargeNano = BigInt(Math.round(params.minimumChargeUSD * 1e9));
633
+ if (billedNano < minChargeNano) {
634
+ billedNano = minChargeNano;
635
+ }
626
636
  }
627
637
  }
638
+ const inputCostUSD = Number(inputCostNano) / 1e9;
639
+ const outputCostUSD = Number(outputCostNano) / 1e9;
640
+ const reasoningCostUSD = Number(reasoningCostNano) / 1e9;
641
+ const cachedDiscountUSD = Number(cachedDiscountNano) / 1e9;
642
+ const totalUSD = Number(wholesaleNano) / 1e9;
643
+ const wholesaleTotalUSD = totalUSD;
644
+ const billedUSD = Number(billedNano) / 1e9;
645
+ const profitUSD = Math.max(0, billedUSD - wholesaleTotalUSD);
646
+ const retailUSD = hasRetail ? billedUSD : void 0;
628
647
  return {
629
648
  inputCostUSD: Number(inputCostUSD.toFixed(8)),
630
649
  outputCostUSD: Number(outputCostUSD.toFixed(8)),
631
- reasoningCostUSD: reasoningTokens > 0 ? Number(reasoningCostUSD.toFixed(8)) : void 0,
632
- cachedDiscountUSD: cachedTokens > 0 ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
650
+ reasoningCostUSD: reasoningTokens > 0n ? Number(reasoningCostUSD.toFixed(8)) : void 0,
651
+ cachedDiscountUSD: cachedTokens > 0n ? Number(cachedDiscountUSD.toFixed(8)) : void 0,
633
652
  totalUSD: Number(totalUSD.toFixed(8)),
653
+ wholesaleTotalUSD: Number(wholesaleTotalUSD.toFixed(8)),
654
+ billedUSD: Number(billedUSD.toFixed(8)),
655
+ profitUSD: Number(profitUSD.toFixed(8)),
634
656
  retailUSD: retailUSD !== void 0 ? Number(retailUSD.toFixed(8)) : void 0,
635
657
  currency: rates.currency || "USD"
636
658
  };
@@ -858,7 +880,7 @@ var VibezMeter = class {
858
880
  this.stripeClient = new import_stripe.default(key, {
859
881
  appInfo: {
860
882
  name: "vibezcheck",
861
- version: "0.4.2",
883
+ version: "0.5.0",
862
884
  url: "https://vibezcheck.xyz"
863
885
  }
864
886
  });
@@ -1253,23 +1275,48 @@ function createVibezModel(modelOrId, options = {}) {
1253
1275
  const parts = rawId.split("/");
1254
1276
  providerName = parts[0].toLowerCase();
1255
1277
  cleanModelId = parts.slice(1).join("/");
1278
+ } else if (rawId.startsWith("claude-")) {
1279
+ providerName = "anthropic";
1280
+ } else if (rawId.startsWith("gemini-")) {
1281
+ providerName = "google";
1256
1282
  }
1257
- const apiKey = options.apiKey || process.env.AI_GATEWAY_API_KEY || process.env.OPENAI_API_KEY || process.env.ANTHROPIC_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY;
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;
1258
1284
  const baseURL = options.baseURL || process.env.AI_GATEWAY_BASE_URL || (providerName === "openai" ? "https://api.openai.com/v1" : void 0);
1259
1285
  let baseModelInstance = null;
1260
1286
  try {
1261
1287
  if (providerName === "openai" || providerName === "gateway" || !providerName) {
1262
- const { createOpenAI } = require("@ai-sdk/openai");
1263
- const openaiProvider = createOpenAI({ apiKey, baseURL });
1264
- baseModelInstance = openaiProvider(cleanModelId);
1288
+ const mod = require("@ai-sdk/openai");
1289
+ const factory = mod.createOpenAI || mod.openai || mod.default?.createOpenAI || mod.default?.openai;
1290
+ if (typeof factory === "function") {
1291
+ if (mod.createOpenAI) {
1292
+ const provider = factory({ apiKey, baseURL });
1293
+ baseModelInstance = provider(cleanModelId);
1294
+ } else {
1295
+ baseModelInstance = factory(cleanModelId);
1296
+ }
1297
+ }
1265
1298
  } else if (providerName === "anthropic") {
1266
- const { createAnthropic } = require("@ai-sdk/anthropic");
1267
- const anthropicProvider = createAnthropic({ apiKey, baseURL });
1268
- baseModelInstance = anthropicProvider(cleanModelId);
1299
+ const mod = require("@ai-sdk/anthropic");
1300
+ const factory = mod.createAnthropic || mod.anthropic || mod.default?.createAnthropic || mod.default?.anthropic;
1301
+ if (typeof factory === "function") {
1302
+ if (mod.createAnthropic) {
1303
+ const provider = factory({ apiKey, baseURL });
1304
+ baseModelInstance = provider(cleanModelId);
1305
+ } else {
1306
+ baseModelInstance = factory(cleanModelId);
1307
+ }
1308
+ }
1269
1309
  } else if (providerName === "google") {
1270
- const { createGoogleGenerativeAI } = require("@ai-sdk/google");
1271
- const googleProvider = createGoogleGenerativeAI({ apiKey, baseURL });
1272
- baseModelInstance = googleProvider(cleanModelId);
1310
+ const mod = require("@ai-sdk/google");
1311
+ const factory = mod.createGoogleGenerativeAI || mod.google || mod.default?.createGoogleGenerativeAI || mod.default?.google;
1312
+ if (typeof factory === "function") {
1313
+ if (mod.createGoogleGenerativeAI) {
1314
+ const provider = factory({ apiKey, baseURL });
1315
+ baseModelInstance = provider(cleanModelId);
1316
+ } else {
1317
+ baseModelInstance = factory(cleanModelId);
1318
+ }
1319
+ }
1273
1320
  }
1274
1321
  } catch {
1275
1322
  baseModelInstance = {