@zorveus/sdk 0.1.9 → 0.2.1

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.
@@ -0,0 +1,347 @@
1
+ type ProductUserStatus = "active" | "suspended";
2
+ /**
3
+ * App connection credit enforcement mode.
4
+ */
5
+ type CreditMode = "disabled" | "track_only" | "enforce_if_present" | "enforce";
6
+ type AppConnectionCreditMode = CreditMode;
7
+ /**
8
+ * Error parameters returned by the gateway when an enforced allowance is insufficient.
9
+ */
10
+ interface ProductUserAllowanceInsufficientParams {
11
+ cap_rule_id: string;
12
+ cap_period: "daily" | "weekly" | "monthly" | "lifetime" | string;
13
+ currency: string;
14
+ cap_amount: string;
15
+ settled_spend_this_period: string;
16
+ active_reservations_amount: string;
17
+ remaining_base_allowance: string;
18
+ promotional_credit_balance: string;
19
+ available_allowance: string;
20
+ estimated_request_cost: string;
21
+ shortfall: string;
22
+ [key: string]: unknown;
23
+ }
24
+ interface ProductUserCapResponse {
25
+ source: string;
26
+ cap_rule_id: string;
27
+ amount: string;
28
+ currency: string;
29
+ period: "daily" | "weekly" | "monthly" | "lifetime" | string;
30
+ spent_this_period: string;
31
+ reset_at: string | null;
32
+ status: string;
33
+ updated_at: string;
34
+ }
35
+ interface ProductUserUsageMetrics {
36
+ sell_cost: string;
37
+ /** Reference-priced usage consumed against caps and credits. */
38
+ virtual_spend?: string;
39
+ /** Upstream provider cost, when the caller may view it. */
40
+ provider_cost?: string;
41
+ /** Usage beyond available allowance in track-only or overrun cases. */
42
+ uncovered_virtual_spend?: string;
43
+ input_tokens: number;
44
+ output_tokens: number;
45
+ total_tokens: number;
46
+ request_count: number;
47
+ }
48
+ interface ProductUserUsageSummary {
49
+ this_month: ProductUserUsageMetrics;
50
+ total: ProductUserUsageMetrics;
51
+ }
52
+ interface ProductUserCreditSummaryResponse {
53
+ currency: string;
54
+ available_credits: string;
55
+ active_grant_count: number;
56
+ expiring_soon_amount: string;
57
+ spent_this_month: string;
58
+ spent_total: string;
59
+ last_grant_at?: string | null;
60
+ last_used_at?: string | null;
61
+ product_end_user_id?: string;
62
+ total_granted?: string;
63
+ total_remaining?: string;
64
+ active_grants_count?: number;
65
+ }
66
+ interface ProductUserResponse {
67
+ product_end_user_id: string;
68
+ org_id: string;
69
+ app_id: string;
70
+ external_user_id: string;
71
+ display_name: string | null;
72
+ email_hash: string | null;
73
+ status: ProductUserStatus;
74
+ metadata: Record<string, unknown> | null;
75
+ usage?: ProductUserUsageSummary | Record<string, unknown>;
76
+ cap?: ProductUserCapResponse | null;
77
+ credits?: ProductUserCreditSummaryResponse | null;
78
+ }
79
+ type ProductUser = ProductUserResponse;
80
+ interface UpsertProductUserResponse {
81
+ product_user: ProductUserResponse;
82
+ created: boolean;
83
+ }
84
+ interface ProductUserListResponse {
85
+ product_users: ProductUserResponse[];
86
+ }
87
+ interface UpsertProductUserParams {
88
+ orgId?: string;
89
+ appId?: string;
90
+ externalUserId: string;
91
+ displayName?: string | null;
92
+ email?: string | null;
93
+ metadata?: Record<string, unknown> | null;
94
+ }
95
+ interface GetProductUserByExternalIdParams {
96
+ appId: string;
97
+ externalUserId: string;
98
+ orgId?: string;
99
+ }
100
+ interface GetProductUserCreditSummaryByExternalIdParams {
101
+ appId: string;
102
+ externalUserId: string;
103
+ currency?: string;
104
+ orgId?: string;
105
+ }
106
+ type CreditGrantStatus = "active" | "exhausted" | "expired" | "revoked";
107
+ type CreditGrantSource = "admin_adjustment" | "service_key" | "purchase" | "promotion" | "monthly_allowance" | "support_credit" | "import" | (string & {});
108
+ interface ProductUserCreditGrantResponse {
109
+ credit_grant_id: string;
110
+ org_id: string;
111
+ app_id: string;
112
+ product_end_user_id: string;
113
+ amount: string;
114
+ remaining_amount: string;
115
+ currency: string;
116
+ source: string;
117
+ reason: string | null;
118
+ status: CreditGrantStatus;
119
+ expires_at: string | null;
120
+ metadata: Record<string, unknown> | null;
121
+ created_at: string;
122
+ updated_at: string;
123
+ }
124
+ type CreditGrant = ProductUserCreditGrantResponse;
125
+ interface GrantProductUserCreditsResponse {
126
+ product_user: ProductUserResponse;
127
+ credit_grant: ProductUserCreditGrantResponse;
128
+ credit_summary: ProductUserCreditSummaryResponse;
129
+ }
130
+ interface ProductUserCreditGrantListResponse {
131
+ credit_grants: ProductUserCreditGrantResponse[];
132
+ }
133
+ interface RevokeProductUserCreditGrantResponse {
134
+ credit_grant: ProductUserCreditGrantResponse;
135
+ credit_summary: ProductUserCreditSummaryResponse;
136
+ revoked: boolean;
137
+ }
138
+ interface GrantCreditParams {
139
+ orgId?: string;
140
+ appId?: string;
141
+ amount: string;
142
+ currency?: string;
143
+ reason?: string | null;
144
+ expiresAt?: string | null;
145
+ metadata?: Record<string, unknown> | null;
146
+ }
147
+ interface GrantCreditByExternalIdParams {
148
+ appId: string;
149
+ externalUserId: string;
150
+ amount: string;
151
+ displayName?: string | null;
152
+ email?: string | null;
153
+ currency?: string;
154
+ source?: CreditGrantSource;
155
+ reason?: string | null;
156
+ expiresAt?: string | null;
157
+ metadata?: Record<string, unknown> | null;
158
+ orgId?: string;
159
+ }
160
+ interface ListCreditGrantsParams {
161
+ appId?: string;
162
+ orgId?: string;
163
+ limit?: number;
164
+ offset?: number;
165
+ }
166
+ interface ListCreditGrantsByExternalIdParams {
167
+ appId: string;
168
+ externalUserId: string;
169
+ status?: CreditGrantStatus;
170
+ source?: CreditGrantSource;
171
+ limit?: number;
172
+ orgId?: string;
173
+ }
174
+ interface ProductUserListParams {
175
+ orgId?: string;
176
+ appId?: string;
177
+ limit?: number;
178
+ offset?: number;
179
+ }
180
+
181
+ /**
182
+ * Base class for all Zorveus SDK errors.
183
+ */
184
+ declare class ZorveusError extends Error {
185
+ readonly status?: number;
186
+ readonly code?: string;
187
+ readonly param?: string;
188
+ readonly type?: string;
189
+ readonly params?: Record<string, unknown>;
190
+ readonly headers?: Record<string, string>;
191
+ readonly rawBody?: unknown;
192
+ constructor(message: string, options?: {
193
+ status?: number;
194
+ code?: string;
195
+ param?: string;
196
+ type?: string;
197
+ params?: Record<string, unknown>;
198
+ headers?: Record<string, string>;
199
+ rawBody?: unknown;
200
+ cause?: unknown;
201
+ });
202
+ }
203
+ /**
204
+ * Thrown when an HTTP request fails before receiving a response (network drops, DNS failures, aborts/timeouts).
205
+ */
206
+ declare class APIConnectionError extends ZorveusError {
207
+ constructor(message?: string, options?: {
208
+ cause?: unknown;
209
+ });
210
+ }
211
+ /**
212
+ * Base class for all HTTP 4xx and 5xx responses from the Zorveus API.
213
+ */
214
+ declare class APIStatusError extends ZorveusError {
215
+ constructor(message: string, options: {
216
+ status: number;
217
+ code?: string;
218
+ param?: string;
219
+ type?: string;
220
+ params?: Record<string, unknown>;
221
+ headers?: Record<string, string>;
222
+ rawBody?: unknown;
223
+ });
224
+ }
225
+ /**
226
+ * HTTP 401: Invalid or expired API key, Service key, or OAuth access token.
227
+ */
228
+ declare class AuthenticationError extends APIStatusError {
229
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
230
+ status?: number;
231
+ });
232
+ }
233
+ /**
234
+ * HTTP 403: Forbidden access, insufficient scope, or model not permitted.
235
+ */
236
+ declare class PermissionDeniedError extends APIStatusError {
237
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
238
+ status?: number;
239
+ });
240
+ }
241
+ /**
242
+ * HTTP 404: Requested resource (app, user, credential, model) was not found.
243
+ */
244
+ declare class NotFoundError extends APIStatusError {
245
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
246
+ status?: number;
247
+ });
248
+ }
249
+ /**
250
+ * HTTP 422: Request schema validation failure.
251
+ */
252
+ declare class UnprocessableEntityError extends APIStatusError {
253
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
254
+ status?: number;
255
+ });
256
+ }
257
+ /**
258
+ * HTTP 429: Rate limit exceeded or quota exhausted.
259
+ */
260
+ declare class RateLimitError extends APIStatusError {
261
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
262
+ status?: number;
263
+ });
264
+ }
265
+ /**
266
+ * HTTP 500, 502, 503, 504: Zorveus internal server or upstream gateway error.
267
+ */
268
+ declare class InternalServerError extends APIStatusError {
269
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
270
+ status?: number;
271
+ });
272
+ }
273
+ /**
274
+ * Base class for Zorveus financial and business constraint errors.
275
+ */
276
+ declare class ZorveusBusinessError extends APIStatusError {
277
+ constructor(message: string, options: {
278
+ status: number;
279
+ code?: string;
280
+ param?: string;
281
+ type?: string;
282
+ params?: Record<string, unknown>;
283
+ headers?: Record<string, string>;
284
+ rawBody?: unknown;
285
+ });
286
+ }
287
+ /**
288
+ * HTTP 402: Organization wallet balance is exhausted or insufficient for estimated charge/fee.
289
+ */
290
+ declare class InsufficientFundsError extends ZorveusBusinessError {
291
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
292
+ status?: number;
293
+ });
294
+ }
295
+ /**
296
+ * HTTP 403: Spending cap limit reached for inference key or member.
297
+ */
298
+ declare class CapExceededError extends ZorveusBusinessError {
299
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
300
+ status?: number;
301
+ });
302
+ }
303
+ /**
304
+ * HTTP 403: Enforced AI allowance exhausted for a product user on an inference key.
305
+ * Contains shortfall and breakdown between base cap and promotional credits.
306
+ */
307
+ declare class ProductUserAllowanceInsufficientError extends ZorveusBusinessError {
308
+ readonly params?: ProductUserAllowanceInsufficientParams;
309
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
310
+ status?: number;
311
+ params?: ProductUserAllowanceInsufficientParams;
312
+ });
313
+ }
314
+ /**
315
+ * HTTP 403: Product user credit grant has expired.
316
+ */
317
+ declare class CreditGrantExpiredError extends ZorveusBusinessError {
318
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
319
+ status?: number;
320
+ });
321
+ }
322
+ /**
323
+ * HTTP 403: Supplied inference key or connected app is invalid or revoked.
324
+ */
325
+ declare class AppConnectionNotFoundError extends ZorveusBusinessError {
326
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
327
+ status?: number;
328
+ });
329
+ }
330
+ /**
331
+ * HTTP 409: Idempotency key reused with mismatched request parameters.
332
+ */
333
+ declare class ReservationConflictError extends ZorveusBusinessError {
334
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
335
+ status?: number;
336
+ });
337
+ }
338
+ /**
339
+ * Factory that parses HTTP status code and response payload into the most specific ZorveusError subclass.
340
+ */
341
+ declare function createAPIError(status: number, body: unknown, headers?: Record<string, string>): APIStatusError;
342
+ /**
343
+ * Parses errors thrown by OpenAI SDK or Vercel AI SDK into typed Zorveus errors.
344
+ */
345
+ declare function parseZorveusGatewayError(error: unknown): ZorveusError | unknown;
346
+
347
+ export { APIConnectionError as A, type ProductUserCreditGrantResponse as B, CapExceededError as C, type ProductUserStatus as D, type ProductUserUsageMetrics as E, type ProductUserUsageSummary as F, type GetProductUserByExternalIdParams as G, RateLimitError as H, InsufficientFundsError as I, ReservationConflictError as J, UnprocessableEntityError as K, type ListCreditGrantsParams as L, ZorveusError as M, NotFoundError as N, createAPIError as O, type ProductUserResponse as P, type RevokeProductUserCreditGrantResponse as R, type UpsertProductUserParams as U, ZorveusBusinessError as Z, type UpsertProductUserResponse as a, type GetProductUserCreditSummaryByExternalIdParams as b, type ProductUserCreditSummaryResponse as c, type ProductUserListParams as d, type ProductUserListResponse as e, type GrantCreditParams as f, type GrantProductUserCreditsResponse as g, type GrantCreditByExternalIdParams as h, type ProductUserCreditGrantListResponse as i, type ListCreditGrantsByExternalIdParams as j, APIStatusError as k, type AppConnectionCreditMode as l, AppConnectionNotFoundError as m, AuthenticationError as n, type CreditGrant as o, parseZorveusGatewayError as p, CreditGrantExpiredError as q, type CreditGrantSource as r, type CreditGrantStatus as s, type CreditMode as t, InternalServerError as u, PermissionDeniedError as v, type ProductUser as w, ProductUserAllowanceInsufficientError as x, type ProductUserAllowanceInsufficientParams as y, type ProductUserCapResponse as z };
@@ -0,0 +1,347 @@
1
+ type ProductUserStatus = "active" | "suspended";
2
+ /**
3
+ * App connection credit enforcement mode.
4
+ */
5
+ type CreditMode = "disabled" | "track_only" | "enforce_if_present" | "enforce";
6
+ type AppConnectionCreditMode = CreditMode;
7
+ /**
8
+ * Error parameters returned by the gateway when an enforced allowance is insufficient.
9
+ */
10
+ interface ProductUserAllowanceInsufficientParams {
11
+ cap_rule_id: string;
12
+ cap_period: "daily" | "weekly" | "monthly" | "lifetime" | string;
13
+ currency: string;
14
+ cap_amount: string;
15
+ settled_spend_this_period: string;
16
+ active_reservations_amount: string;
17
+ remaining_base_allowance: string;
18
+ promotional_credit_balance: string;
19
+ available_allowance: string;
20
+ estimated_request_cost: string;
21
+ shortfall: string;
22
+ [key: string]: unknown;
23
+ }
24
+ interface ProductUserCapResponse {
25
+ source: string;
26
+ cap_rule_id: string;
27
+ amount: string;
28
+ currency: string;
29
+ period: "daily" | "weekly" | "monthly" | "lifetime" | string;
30
+ spent_this_period: string;
31
+ reset_at: string | null;
32
+ status: string;
33
+ updated_at: string;
34
+ }
35
+ interface ProductUserUsageMetrics {
36
+ sell_cost: string;
37
+ /** Reference-priced usage consumed against caps and credits. */
38
+ virtual_spend?: string;
39
+ /** Upstream provider cost, when the caller may view it. */
40
+ provider_cost?: string;
41
+ /** Usage beyond available allowance in track-only or overrun cases. */
42
+ uncovered_virtual_spend?: string;
43
+ input_tokens: number;
44
+ output_tokens: number;
45
+ total_tokens: number;
46
+ request_count: number;
47
+ }
48
+ interface ProductUserUsageSummary {
49
+ this_month: ProductUserUsageMetrics;
50
+ total: ProductUserUsageMetrics;
51
+ }
52
+ interface ProductUserCreditSummaryResponse {
53
+ currency: string;
54
+ available_credits: string;
55
+ active_grant_count: number;
56
+ expiring_soon_amount: string;
57
+ spent_this_month: string;
58
+ spent_total: string;
59
+ last_grant_at?: string | null;
60
+ last_used_at?: string | null;
61
+ product_end_user_id?: string;
62
+ total_granted?: string;
63
+ total_remaining?: string;
64
+ active_grants_count?: number;
65
+ }
66
+ interface ProductUserResponse {
67
+ product_end_user_id: string;
68
+ org_id: string;
69
+ app_id: string;
70
+ external_user_id: string;
71
+ display_name: string | null;
72
+ email_hash: string | null;
73
+ status: ProductUserStatus;
74
+ metadata: Record<string, unknown> | null;
75
+ usage?: ProductUserUsageSummary | Record<string, unknown>;
76
+ cap?: ProductUserCapResponse | null;
77
+ credits?: ProductUserCreditSummaryResponse | null;
78
+ }
79
+ type ProductUser = ProductUserResponse;
80
+ interface UpsertProductUserResponse {
81
+ product_user: ProductUserResponse;
82
+ created: boolean;
83
+ }
84
+ interface ProductUserListResponse {
85
+ product_users: ProductUserResponse[];
86
+ }
87
+ interface UpsertProductUserParams {
88
+ orgId?: string;
89
+ appId?: string;
90
+ externalUserId: string;
91
+ displayName?: string | null;
92
+ email?: string | null;
93
+ metadata?: Record<string, unknown> | null;
94
+ }
95
+ interface GetProductUserByExternalIdParams {
96
+ appId: string;
97
+ externalUserId: string;
98
+ orgId?: string;
99
+ }
100
+ interface GetProductUserCreditSummaryByExternalIdParams {
101
+ appId: string;
102
+ externalUserId: string;
103
+ currency?: string;
104
+ orgId?: string;
105
+ }
106
+ type CreditGrantStatus = "active" | "exhausted" | "expired" | "revoked";
107
+ type CreditGrantSource = "admin_adjustment" | "service_key" | "purchase" | "promotion" | "monthly_allowance" | "support_credit" | "import" | (string & {});
108
+ interface ProductUserCreditGrantResponse {
109
+ credit_grant_id: string;
110
+ org_id: string;
111
+ app_id: string;
112
+ product_end_user_id: string;
113
+ amount: string;
114
+ remaining_amount: string;
115
+ currency: string;
116
+ source: string;
117
+ reason: string | null;
118
+ status: CreditGrantStatus;
119
+ expires_at: string | null;
120
+ metadata: Record<string, unknown> | null;
121
+ created_at: string;
122
+ updated_at: string;
123
+ }
124
+ type CreditGrant = ProductUserCreditGrantResponse;
125
+ interface GrantProductUserCreditsResponse {
126
+ product_user: ProductUserResponse;
127
+ credit_grant: ProductUserCreditGrantResponse;
128
+ credit_summary: ProductUserCreditSummaryResponse;
129
+ }
130
+ interface ProductUserCreditGrantListResponse {
131
+ credit_grants: ProductUserCreditGrantResponse[];
132
+ }
133
+ interface RevokeProductUserCreditGrantResponse {
134
+ credit_grant: ProductUserCreditGrantResponse;
135
+ credit_summary: ProductUserCreditSummaryResponse;
136
+ revoked: boolean;
137
+ }
138
+ interface GrantCreditParams {
139
+ orgId?: string;
140
+ appId?: string;
141
+ amount: string;
142
+ currency?: string;
143
+ reason?: string | null;
144
+ expiresAt?: string | null;
145
+ metadata?: Record<string, unknown> | null;
146
+ }
147
+ interface GrantCreditByExternalIdParams {
148
+ appId: string;
149
+ externalUserId: string;
150
+ amount: string;
151
+ displayName?: string | null;
152
+ email?: string | null;
153
+ currency?: string;
154
+ source?: CreditGrantSource;
155
+ reason?: string | null;
156
+ expiresAt?: string | null;
157
+ metadata?: Record<string, unknown> | null;
158
+ orgId?: string;
159
+ }
160
+ interface ListCreditGrantsParams {
161
+ appId?: string;
162
+ orgId?: string;
163
+ limit?: number;
164
+ offset?: number;
165
+ }
166
+ interface ListCreditGrantsByExternalIdParams {
167
+ appId: string;
168
+ externalUserId: string;
169
+ status?: CreditGrantStatus;
170
+ source?: CreditGrantSource;
171
+ limit?: number;
172
+ orgId?: string;
173
+ }
174
+ interface ProductUserListParams {
175
+ orgId?: string;
176
+ appId?: string;
177
+ limit?: number;
178
+ offset?: number;
179
+ }
180
+
181
+ /**
182
+ * Base class for all Zorveus SDK errors.
183
+ */
184
+ declare class ZorveusError extends Error {
185
+ readonly status?: number;
186
+ readonly code?: string;
187
+ readonly param?: string;
188
+ readonly type?: string;
189
+ readonly params?: Record<string, unknown>;
190
+ readonly headers?: Record<string, string>;
191
+ readonly rawBody?: unknown;
192
+ constructor(message: string, options?: {
193
+ status?: number;
194
+ code?: string;
195
+ param?: string;
196
+ type?: string;
197
+ params?: Record<string, unknown>;
198
+ headers?: Record<string, string>;
199
+ rawBody?: unknown;
200
+ cause?: unknown;
201
+ });
202
+ }
203
+ /**
204
+ * Thrown when an HTTP request fails before receiving a response (network drops, DNS failures, aborts/timeouts).
205
+ */
206
+ declare class APIConnectionError extends ZorveusError {
207
+ constructor(message?: string, options?: {
208
+ cause?: unknown;
209
+ });
210
+ }
211
+ /**
212
+ * Base class for all HTTP 4xx and 5xx responses from the Zorveus API.
213
+ */
214
+ declare class APIStatusError extends ZorveusError {
215
+ constructor(message: string, options: {
216
+ status: number;
217
+ code?: string;
218
+ param?: string;
219
+ type?: string;
220
+ params?: Record<string, unknown>;
221
+ headers?: Record<string, string>;
222
+ rawBody?: unknown;
223
+ });
224
+ }
225
+ /**
226
+ * HTTP 401: Invalid or expired API key, Service key, or OAuth access token.
227
+ */
228
+ declare class AuthenticationError extends APIStatusError {
229
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
230
+ status?: number;
231
+ });
232
+ }
233
+ /**
234
+ * HTTP 403: Forbidden access, insufficient scope, or model not permitted.
235
+ */
236
+ declare class PermissionDeniedError extends APIStatusError {
237
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
238
+ status?: number;
239
+ });
240
+ }
241
+ /**
242
+ * HTTP 404: Requested resource (app, user, credential, model) was not found.
243
+ */
244
+ declare class NotFoundError extends APIStatusError {
245
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
246
+ status?: number;
247
+ });
248
+ }
249
+ /**
250
+ * HTTP 422: Request schema validation failure.
251
+ */
252
+ declare class UnprocessableEntityError extends APIStatusError {
253
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
254
+ status?: number;
255
+ });
256
+ }
257
+ /**
258
+ * HTTP 429: Rate limit exceeded or quota exhausted.
259
+ */
260
+ declare class RateLimitError extends APIStatusError {
261
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
262
+ status?: number;
263
+ });
264
+ }
265
+ /**
266
+ * HTTP 500, 502, 503, 504: Zorveus internal server or upstream gateway error.
267
+ */
268
+ declare class InternalServerError extends APIStatusError {
269
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof APIStatusError>[1], "status"> & {
270
+ status?: number;
271
+ });
272
+ }
273
+ /**
274
+ * Base class for Zorveus financial and business constraint errors.
275
+ */
276
+ declare class ZorveusBusinessError extends APIStatusError {
277
+ constructor(message: string, options: {
278
+ status: number;
279
+ code?: string;
280
+ param?: string;
281
+ type?: string;
282
+ params?: Record<string, unknown>;
283
+ headers?: Record<string, string>;
284
+ rawBody?: unknown;
285
+ });
286
+ }
287
+ /**
288
+ * HTTP 402: Organization wallet balance is exhausted or insufficient for estimated charge/fee.
289
+ */
290
+ declare class InsufficientFundsError extends ZorveusBusinessError {
291
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
292
+ status?: number;
293
+ });
294
+ }
295
+ /**
296
+ * HTTP 403: Spending cap limit reached for inference key or member.
297
+ */
298
+ declare class CapExceededError extends ZorveusBusinessError {
299
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
300
+ status?: number;
301
+ });
302
+ }
303
+ /**
304
+ * HTTP 403: Enforced AI allowance exhausted for a product user on an inference key.
305
+ * Contains shortfall and breakdown between base cap and promotional credits.
306
+ */
307
+ declare class ProductUserAllowanceInsufficientError extends ZorveusBusinessError {
308
+ readonly params?: ProductUserAllowanceInsufficientParams;
309
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
310
+ status?: number;
311
+ params?: ProductUserAllowanceInsufficientParams;
312
+ });
313
+ }
314
+ /**
315
+ * HTTP 403: Product user credit grant has expired.
316
+ */
317
+ declare class CreditGrantExpiredError extends ZorveusBusinessError {
318
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
319
+ status?: number;
320
+ });
321
+ }
322
+ /**
323
+ * HTTP 403: Supplied inference key or connected app is invalid or revoked.
324
+ */
325
+ declare class AppConnectionNotFoundError extends ZorveusBusinessError {
326
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
327
+ status?: number;
328
+ });
329
+ }
330
+ /**
331
+ * HTTP 409: Idempotency key reused with mismatched request parameters.
332
+ */
333
+ declare class ReservationConflictError extends ZorveusBusinessError {
334
+ constructor(message?: string, options?: Omit<ConstructorParameters<typeof ZorveusBusinessError>[1], "status"> & {
335
+ status?: number;
336
+ });
337
+ }
338
+ /**
339
+ * Factory that parses HTTP status code and response payload into the most specific ZorveusError subclass.
340
+ */
341
+ declare function createAPIError(status: number, body: unknown, headers?: Record<string, string>): APIStatusError;
342
+ /**
343
+ * Parses errors thrown by OpenAI SDK or Vercel AI SDK into typed Zorveus errors.
344
+ */
345
+ declare function parseZorveusGatewayError(error: unknown): ZorveusError | unknown;
346
+
347
+ export { APIConnectionError as A, type ProductUserCreditGrantResponse as B, CapExceededError as C, type ProductUserStatus as D, type ProductUserUsageMetrics as E, type ProductUserUsageSummary as F, type GetProductUserByExternalIdParams as G, RateLimitError as H, InsufficientFundsError as I, ReservationConflictError as J, UnprocessableEntityError as K, type ListCreditGrantsParams as L, ZorveusError as M, NotFoundError as N, createAPIError as O, type ProductUserResponse as P, type RevokeProductUserCreditGrantResponse as R, type UpsertProductUserParams as U, ZorveusBusinessError as Z, type UpsertProductUserResponse as a, type GetProductUserCreditSummaryByExternalIdParams as b, type ProductUserCreditSummaryResponse as c, type ProductUserListParams as d, type ProductUserListResponse as e, type GrantCreditParams as f, type GrantProductUserCreditsResponse as g, type GrantCreditByExternalIdParams as h, type ProductUserCreditGrantListResponse as i, type ListCreditGrantsByExternalIdParams as j, APIStatusError as k, type AppConnectionCreditMode as l, AppConnectionNotFoundError as m, AuthenticationError as n, type CreditGrant as o, parseZorveusGatewayError as p, CreditGrantExpiredError as q, type CreditGrantSource as r, type CreditGrantStatus as s, type CreditMode as t, InternalServerError as u, PermissionDeniedError as v, type ProductUser as w, ProductUserAllowanceInsufficientError as x, type ProductUserAllowanceInsufficientParams as y, type ProductUserCapResponse as z };