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.
- package/LICENSE +21 -21
- package/README.md +230 -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 +79 -32
- package/dist/ai-sdk/index.js.map +1 -1
- package/dist/ai-sdk/index.mjs +79 -32
- 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 +1280 -0
- package/dist/ai-sdk/middleware.js.map +1 -0
- package/dist/ai-sdk/middleware.mjs +1243 -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 +1391 -2
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +1386 -1
- package/dist/billing/index.mjs.map +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{client-ynfWcHX6.d.ts → client-CJ2Dj8ID.d.ts} +1 -1
- package/dist/{client-w_hWhQ6g.d.mts → client-Dmwb3hQt.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 +1281 -0
- package/dist/compat/stripe-meter.js.map +1 -0
- package/dist/compat/stripe-meter.mjs +1244 -0
- package/dist/compat/stripe-meter.mjs.map +1 -0
- package/dist/compat/stripe-provider.d.mts +54 -0
- package/dist/compat/stripe-provider.d.ts +54 -0
- package/dist/compat/stripe-provider.js +1304 -0
- package/dist/compat/stripe-provider.js.map +1 -0
- package/dist/compat/stripe-provider.mjs +1264 -0
- package/dist/compat/stripe-provider.mjs.map +1 -0
- package/dist/compat/token-meter.d.mts +16 -0
- package/dist/compat/token-meter.d.ts +16 -0
- package/dist/compat/token-meter.js +1095 -0
- package/dist/compat/token-meter.js.map +1 -0
- package/dist/compat/token-meter.mjs +1058 -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 +22 -11
- package/dist/index.d.ts +22 -11
- package/dist/index.js +269 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -33
- 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 +44 -22
- package/dist/meter/index.js.map +1 -1
- package/dist/meter/index.mjs +44 -22
- package/dist/meter/index.mjs.map +1 -1
- package/dist/pricing/index.d.mts +5 -2
- package/dist/pricing/index.d.ts +5 -2
- package/dist/pricing/index.js +43 -21
- package/dist/pricing/index.js.map +1 -1
- package/dist/pricing/index.mjs +43 -21
- 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 +351 -21
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +349 -21
- package/dist/react/index.mjs.map +1 -1
- package/dist/{types-Mozk4-Mr.d.mts → types-BVGqbKnY.d.mts} +6 -0
- package/dist/{types-Mozk4-Mr.d.ts → types-BVGqbKnY.d.ts} +6 -0
- package/dist/with-billing-CDqKIAQ6.d.ts +47 -0
- package/dist/with-billing-mci2vtFS.d.mts +47 -0
- package/package.json +26 -1
package/dist/ai-sdk/index.d.mts
CHANGED
|
@@ -1,54 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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 /
|
|
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 {
|
|
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.
|
|
81
|
-
* const
|
|
82
|
-
* model: vibezcheck('
|
|
83
|
-
*
|
|
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.
|
|
87
|
-
* const
|
|
88
|
-
* model: vibezcheck('
|
|
89
|
-
*
|
|
90
|
-
*
|
|
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,
|
|
74
|
+
export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, WithBillingOptions, createVibezModel, createVibezSession, vibezcheck };
|
package/dist/ai-sdk/index.d.ts
CHANGED
|
@@ -1,54 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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 /
|
|
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 {
|
|
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.
|
|
81
|
-
* const
|
|
82
|
-
* model: vibezcheck('
|
|
83
|
-
*
|
|
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.
|
|
87
|
-
* const
|
|
88
|
-
* model: vibezcheck('
|
|
89
|
-
*
|
|
90
|
-
*
|
|
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,
|
|
74
|
+
export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, WithBillingOptions, createVibezModel, createVibezSession, vibezcheck };
|
package/dist/ai-sdk/index.js
CHANGED
|
@@ -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 =
|
|
610
|
-
const
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
|
|
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
|
|
625
|
+
let billedNano = wholesaleNano;
|
|
626
|
+
let hasRetail = false;
|
|
622
627
|
if (markup !== 1 || params.minimumChargeUSD !== void 0) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
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 >
|
|
632
|
-
cachedDiscountUSD: cachedTokens >
|
|
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.
|
|
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.
|
|
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
|
|
1263
|
-
const
|
|
1264
|
-
|
|
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
|
|
1267
|
-
const
|
|
1268
|
-
|
|
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
|
|
1271
|
-
const
|
|
1272
|
-
|
|
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 = {
|