@lavapayments/nodejs 0.1.1 → 1.0.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/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @lavapayments/nodejs
13
13
  ### Initialize the client
14
14
 
15
15
  ```typescript
16
- import Lava from '@lavapayments/nodejs';
16
+ import { Lava } from '@lavapayments/nodejs';
17
17
 
18
18
  const lava = new Lava('your_secret_key', {
19
19
  apiVersion: '2025-03-10.v1',
package/dist/index.d.mts CHANGED
@@ -1,3 +1,89 @@
1
+ type ApiVersion = "2025-03-10.v1";
2
+ interface Config {
3
+ apiVersion: ApiVersion;
4
+ /**
5
+ * Base URL for the API.
6
+ * If not provided, it will be inferred from the secret key (production or sandbox).
7
+ */
8
+ baseUrl?: string;
9
+ }
10
+ type ForwardTokenOptions = {
11
+ connection_secret: string;
12
+ product_secret: string;
13
+ };
14
+ declare class Lava {
15
+ private readonly secretKey;
16
+ private readonly baseUrl;
17
+ private readonly apiVersion;
18
+ /**
19
+ * The checkout resource
20
+ */
21
+ readonly checkout: Resources.CheckoutResource;
22
+ /**
23
+ * The connections resource
24
+ */
25
+ readonly connections: Resources.ConnectionsResource;
26
+ /**
27
+ * The requests resource
28
+ */
29
+ readonly requests: Resources.RequestsResource;
30
+ /**
31
+ * The usage resource
32
+ */
33
+ readonly usage: Resources.UsageResource;
34
+ /**
35
+ * OpenAI base URL for convenience
36
+ */
37
+ readonly openaiUrl: string;
38
+ /**
39
+ * Anthropic base URL for convenience
40
+ */
41
+ readonly anthropicUrl: string;
42
+ /**
43
+ * Mistral base URL for convenience
44
+ */
45
+ readonly mistralUrl: string;
46
+ /**
47
+ * DeepSeek base URL for convenience
48
+ */
49
+ readonly deepseekUrl: string;
50
+ /**
51
+ * xAI base URL for convenience
52
+ */
53
+ readonly xaiUrl: string;
54
+ /**
55
+ * Google base URL for convenience
56
+ */
57
+ readonly googleUrl: string;
58
+ /**
59
+ * Google OpenAI-compatible base URL for convenience
60
+ */
61
+ readonly googleOpenaiCompatibleUrl: string;
62
+ /**
63
+ * Create a new Lava client
64
+ * @param secretKey Your Lava secret key
65
+ * @param config Configuration options
66
+ */
67
+ constructor(secretKey: string, config: Config);
68
+ /**
69
+ * Make a request to the Lava API
70
+ * @param method HTTP method
71
+ * @param path API path
72
+ * @param options Request options
73
+ * @returns Response data
74
+ */
75
+ request<T>(method: string, path: string, { data, query }?: {
76
+ data?: any;
77
+ query?: Record<string, string>;
78
+ }): Promise<T>;
79
+ /**
80
+ * Generate a token for the forward endpoint
81
+ * @param options Token options
82
+ * @returns Base64 encoded token
83
+ */
84
+ generateForwardToken(options: ForwardTokenOptions): string;
85
+ }
86
+
1
87
  type CheckoutMode = "onboarding" | "topup";
2
88
  interface CreateCheckoutSessionParams {
3
89
  checkout_mode: CheckoutMode;
@@ -26,6 +112,8 @@ interface Connection {
26
112
  connection_id: string;
27
113
  reference_id?: string;
28
114
  wallet: Wallet;
115
+ next_usage_reset: string;
116
+ previous_usage_reset: string;
29
117
  created_at: string;
30
118
  }
31
119
  interface ConnectionsListParams {
@@ -69,7 +157,7 @@ interface Request {
69
157
  product_id: string;
70
158
  model: string;
71
159
  endpoint: string;
72
- response_id: string;
160
+ response_id: string | null;
73
161
  model_usage: ModelUsage;
74
162
  fee: Fee;
75
163
  service_charge: ServiceCharge;
@@ -90,8 +178,10 @@ interface RequestsListResponse {
90
178
  }
91
179
  interface UsageData {
92
180
  date: string;
181
+ total_requests: number;
93
182
  total_usage_tokens: number;
94
183
  total_usage_cost: string;
184
+ total_fee_amount: string;
95
185
  total_service_charge_amount: string;
96
186
  total_request_cost: string;
97
187
  }
@@ -181,90 +271,4 @@ declare namespace Resources {
181
271
  export { };
182
272
  }
183
273
 
184
- type ApiVersion = "2025-03-10.v1";
185
- interface Config {
186
- apiVersion: ApiVersion;
187
- /**
188
- * Base URL for the API.
189
- * If not provided, it will be inferred from the secret key (production or sandbox).
190
- */
191
- baseUrl?: string;
192
- }
193
- type ForwardTokenOptions = {
194
- connection_secret: string;
195
- product_secret: string;
196
- };
197
- declare class Lava {
198
- private readonly secretKey;
199
- private readonly baseUrl;
200
- private readonly apiVersion;
201
- /**
202
- * The checkout resource
203
- */
204
- readonly checkout: Resources.CheckoutResource;
205
- /**
206
- * The connections resource
207
- */
208
- readonly connections: Resources.ConnectionsResource;
209
- /**
210
- * The requests resource
211
- */
212
- readonly requests: Resources.RequestsResource;
213
- /**
214
- * The usage resource
215
- */
216
- readonly usage: Resources.UsageResource;
217
- /**
218
- * OpenAI base URL for convenience
219
- */
220
- readonly openaiUrl: string;
221
- /**
222
- * Anthropic base URL for convenience
223
- */
224
- readonly anthropicUrl: string;
225
- /**
226
- * Mistral base URL for convenience
227
- */
228
- readonly mistralUrl: string;
229
- /**
230
- * DeepSeek base URL for convenience
231
- */
232
- readonly deepseekUrl: string;
233
- /**
234
- * xAI base URL for convenience
235
- */
236
- readonly xaiUrl: string;
237
- /**
238
- * Google base URL for convenience
239
- */
240
- readonly googleUrl: string;
241
- /**
242
- * Google OpenAI-compatible base URL for convenience
243
- */
244
- readonly googleOpenaiCompatibleUrl: string;
245
- /**
246
- * Create a new Lava client
247
- * @param secretKey Your Lava secret key
248
- * @param config Configuration options
249
- */
250
- constructor(secretKey: string, config: Config);
251
- /**
252
- * Make a request to the Lava API
253
- * @param method HTTP method
254
- * @param path API path
255
- * @param options Request options
256
- * @returns Response data
257
- */
258
- request<T>(method: string, path: string, { data, query }?: {
259
- data?: any;
260
- query?: Record<string, string>;
261
- }): Promise<T>;
262
- /**
263
- * Generate a token for the forward endpoint
264
- * @param options Token options
265
- * @returns Base64 encoded token
266
- */
267
- generateForwardToken(options: ForwardTokenOptions): string;
268
- }
269
-
270
- export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet, Lava as default };
274
+ export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, Lava, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,89 @@
1
+ type ApiVersion = "2025-03-10.v1";
2
+ interface Config {
3
+ apiVersion: ApiVersion;
4
+ /**
5
+ * Base URL for the API.
6
+ * If not provided, it will be inferred from the secret key (production or sandbox).
7
+ */
8
+ baseUrl?: string;
9
+ }
10
+ type ForwardTokenOptions = {
11
+ connection_secret: string;
12
+ product_secret: string;
13
+ };
14
+ declare class Lava {
15
+ private readonly secretKey;
16
+ private readonly baseUrl;
17
+ private readonly apiVersion;
18
+ /**
19
+ * The checkout resource
20
+ */
21
+ readonly checkout: Resources.CheckoutResource;
22
+ /**
23
+ * The connections resource
24
+ */
25
+ readonly connections: Resources.ConnectionsResource;
26
+ /**
27
+ * The requests resource
28
+ */
29
+ readonly requests: Resources.RequestsResource;
30
+ /**
31
+ * The usage resource
32
+ */
33
+ readonly usage: Resources.UsageResource;
34
+ /**
35
+ * OpenAI base URL for convenience
36
+ */
37
+ readonly openaiUrl: string;
38
+ /**
39
+ * Anthropic base URL for convenience
40
+ */
41
+ readonly anthropicUrl: string;
42
+ /**
43
+ * Mistral base URL for convenience
44
+ */
45
+ readonly mistralUrl: string;
46
+ /**
47
+ * DeepSeek base URL for convenience
48
+ */
49
+ readonly deepseekUrl: string;
50
+ /**
51
+ * xAI base URL for convenience
52
+ */
53
+ readonly xaiUrl: string;
54
+ /**
55
+ * Google base URL for convenience
56
+ */
57
+ readonly googleUrl: string;
58
+ /**
59
+ * Google OpenAI-compatible base URL for convenience
60
+ */
61
+ readonly googleOpenaiCompatibleUrl: string;
62
+ /**
63
+ * Create a new Lava client
64
+ * @param secretKey Your Lava secret key
65
+ * @param config Configuration options
66
+ */
67
+ constructor(secretKey: string, config: Config);
68
+ /**
69
+ * Make a request to the Lava API
70
+ * @param method HTTP method
71
+ * @param path API path
72
+ * @param options Request options
73
+ * @returns Response data
74
+ */
75
+ request<T>(method: string, path: string, { data, query }?: {
76
+ data?: any;
77
+ query?: Record<string, string>;
78
+ }): Promise<T>;
79
+ /**
80
+ * Generate a token for the forward endpoint
81
+ * @param options Token options
82
+ * @returns Base64 encoded token
83
+ */
84
+ generateForwardToken(options: ForwardTokenOptions): string;
85
+ }
86
+
1
87
  type CheckoutMode = "onboarding" | "topup";
2
88
  interface CreateCheckoutSessionParams {
3
89
  checkout_mode: CheckoutMode;
@@ -26,6 +112,8 @@ interface Connection {
26
112
  connection_id: string;
27
113
  reference_id?: string;
28
114
  wallet: Wallet;
115
+ next_usage_reset: string;
116
+ previous_usage_reset: string;
29
117
  created_at: string;
30
118
  }
31
119
  interface ConnectionsListParams {
@@ -69,7 +157,7 @@ interface Request {
69
157
  product_id: string;
70
158
  model: string;
71
159
  endpoint: string;
72
- response_id: string;
160
+ response_id: string | null;
73
161
  model_usage: ModelUsage;
74
162
  fee: Fee;
75
163
  service_charge: ServiceCharge;
@@ -90,8 +178,10 @@ interface RequestsListResponse {
90
178
  }
91
179
  interface UsageData {
92
180
  date: string;
181
+ total_requests: number;
93
182
  total_usage_tokens: number;
94
183
  total_usage_cost: string;
184
+ total_fee_amount: string;
95
185
  total_service_charge_amount: string;
96
186
  total_request_cost: string;
97
187
  }
@@ -181,90 +271,4 @@ declare namespace Resources {
181
271
  export { };
182
272
  }
183
273
 
184
- type ApiVersion = "2025-03-10.v1";
185
- interface Config {
186
- apiVersion: ApiVersion;
187
- /**
188
- * Base URL for the API.
189
- * If not provided, it will be inferred from the secret key (production or sandbox).
190
- */
191
- baseUrl?: string;
192
- }
193
- type ForwardTokenOptions = {
194
- connection_secret: string;
195
- product_secret: string;
196
- };
197
- declare class Lava {
198
- private readonly secretKey;
199
- private readonly baseUrl;
200
- private readonly apiVersion;
201
- /**
202
- * The checkout resource
203
- */
204
- readonly checkout: Resources.CheckoutResource;
205
- /**
206
- * The connections resource
207
- */
208
- readonly connections: Resources.ConnectionsResource;
209
- /**
210
- * The requests resource
211
- */
212
- readonly requests: Resources.RequestsResource;
213
- /**
214
- * The usage resource
215
- */
216
- readonly usage: Resources.UsageResource;
217
- /**
218
- * OpenAI base URL for convenience
219
- */
220
- readonly openaiUrl: string;
221
- /**
222
- * Anthropic base URL for convenience
223
- */
224
- readonly anthropicUrl: string;
225
- /**
226
- * Mistral base URL for convenience
227
- */
228
- readonly mistralUrl: string;
229
- /**
230
- * DeepSeek base URL for convenience
231
- */
232
- readonly deepseekUrl: string;
233
- /**
234
- * xAI base URL for convenience
235
- */
236
- readonly xaiUrl: string;
237
- /**
238
- * Google base URL for convenience
239
- */
240
- readonly googleUrl: string;
241
- /**
242
- * Google OpenAI-compatible base URL for convenience
243
- */
244
- readonly googleOpenaiCompatibleUrl: string;
245
- /**
246
- * Create a new Lava client
247
- * @param secretKey Your Lava secret key
248
- * @param config Configuration options
249
- */
250
- constructor(secretKey: string, config: Config);
251
- /**
252
- * Make a request to the Lava API
253
- * @param method HTTP method
254
- * @param path API path
255
- * @param options Request options
256
- * @returns Response data
257
- */
258
- request<T>(method: string, path: string, { data, query }?: {
259
- data?: any;
260
- query?: Record<string, string>;
261
- }): Promise<T>;
262
- /**
263
- * Generate a token for the forward endpoint
264
- * @param options Token options
265
- * @returns Base64 encoded token
266
- */
267
- generateForwardToken(options: ForwardTokenOptions): string;
268
- }
269
-
270
- export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet, Lava as default };
274
+ export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, Lava, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet };
package/dist/index.js CHANGED
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- Resources: () => Resources,
24
- default: () => Lava
23
+ Lava: () => Lava,
24
+ Resources: () => Resources
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
@@ -149,7 +149,7 @@ var Resources;
149
149
  Resources2.UsageResource = UsageResource;
150
150
  })(Resources || (Resources = {}));
151
151
 
152
- // src/index.ts
152
+ // src/client.ts
153
153
  var Lava = class {
154
154
  /**
155
155
  * Create a new Lava client
@@ -224,5 +224,6 @@ var Lava = class {
224
224
  };
225
225
  // Annotate the CommonJS export names for ESM import in node:
226
226
  0 && (module.exports = {
227
+ Lava,
227
228
  Resources
228
229
  });
package/dist/index.mjs CHANGED
@@ -122,7 +122,7 @@ var Resources;
122
122
  Resources2.UsageResource = UsageResource;
123
123
  })(Resources || (Resources = {}));
124
124
 
125
- // src/index.ts
125
+ // src/client.ts
126
126
  var Lava = class {
127
127
  /**
128
128
  * Create a new Lava client
@@ -196,6 +196,6 @@ var Lava = class {
196
196
  }
197
197
  };
198
198
  export {
199
- Resources,
200
- Lava as default
199
+ Lava,
200
+ Resources
201
201
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavapayments/nodejs",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "description": "Backend SDK for Lava Payments API - enabling usage-based billing for AI services",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",