@deeprelay/sdk 0.1.2 → 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.
Files changed (61) hide show
  1. package/.openapi-generator/FILES +0 -8
  2. package/README.md +3 -6
  3. package/dist/apis/BillingApi.d.ts +14 -0
  4. package/dist/apis/BillingApi.js +43 -0
  5. package/dist/apis/UsageApi.d.ts +14 -0
  6. package/dist/apis/UsageApi.js +18 -1
  7. package/dist/apis/index.d.ts +0 -1
  8. package/dist/apis/index.js +0 -1
  9. package/dist/esm/apis/BillingApi.d.ts +14 -0
  10. package/dist/esm/apis/BillingApi.js +43 -0
  11. package/dist/esm/apis/UsageApi.d.ts +14 -0
  12. package/dist/esm/apis/UsageApi.js +17 -0
  13. package/dist/esm/apis/index.d.ts +0 -1
  14. package/dist/esm/apis/index.js +0 -1
  15. package/dist/esm/models/UsageBucket.d.ts +38 -5
  16. package/dist/esm/models/UsageBucket.js +10 -0
  17. package/dist/esm/models/UsagePage.d.ts +1 -0
  18. package/dist/esm/models/index.d.ts +0 -3
  19. package/dist/esm/models/index.js +0 -3
  20. package/dist/esm/runtime.js +1 -1
  21. package/dist/models/UsageBucket.d.ts +38 -5
  22. package/dist/models/UsageBucket.js +10 -0
  23. package/dist/models/UsagePage.d.ts +1 -0
  24. package/dist/models/index.d.ts +0 -3
  25. package/dist/models/index.js +0 -3
  26. package/dist/runtime.js +1 -1
  27. package/docs/BillingApi.md +68 -0
  28. package/docs/UsageApi.md +17 -9
  29. package/docs/UsageBucket.md +11 -0
  30. package/package.json +1 -1
  31. package/src/apis/BillingApi.ts +46 -0
  32. package/src/apis/UsageApi.ts +22 -0
  33. package/src/apis/index.ts +0 -1
  34. package/src/models/UsageBucket.ts +48 -5
  35. package/src/models/UsagePage.ts +1 -0
  36. package/src/models/index.ts +0 -3
  37. package/src/runtime.ts +1 -1
  38. package/dist/apis/OperationsApi.d.ts +0 -33
  39. package/dist/apis/OperationsApi.js +0 -79
  40. package/dist/esm/apis/OperationsApi.d.ts +0 -33
  41. package/dist/esm/apis/OperationsApi.js +0 -75
  42. package/dist/esm/models/Operation.d.ts +0 -107
  43. package/dist/esm/models/Operation.js +0 -86
  44. package/dist/esm/models/OperationError.d.ts +0 -38
  45. package/dist/esm/models/OperationError.js +0 -43
  46. package/dist/esm/models/OperationResult.d.ts +0 -44
  47. package/dist/esm/models/OperationResult.js +0 -45
  48. package/dist/models/Operation.d.ts +0 -107
  49. package/dist/models/Operation.js +0 -94
  50. package/dist/models/OperationError.d.ts +0 -38
  51. package/dist/models/OperationError.js +0 -50
  52. package/dist/models/OperationResult.d.ts +0 -44
  53. package/dist/models/OperationResult.js +0 -52
  54. package/docs/Operation.md +0 -52
  55. package/docs/OperationError.md +0 -36
  56. package/docs/OperationResult.md +0 -39
  57. package/docs/OperationsApi.md +0 -80
  58. package/src/apis/OperationsApi.ts +0 -89
  59. package/src/models/Operation.ts +0 -179
  60. package/src/models/OperationError.ts +0 -73
  61. package/src/models/OperationResult.ts +0 -81
@@ -43,6 +43,11 @@ function UsageBucketFromJSONTyped(json, ignoreDiscriminator) {
43
43
  'gpuType': json['gpu_type'] == null ? undefined : json['gpu_type'],
44
44
  'gpuSeconds': json['gpu_seconds'],
45
45
  'costCents': json['cost_cents'],
46
+ 'modality': json['modality'] == null ? undefined : json['modality'],
47
+ 'model': json['model'] == null ? undefined : json['model'],
48
+ 'promptTokens': json['prompt_tokens'] == null ? undefined : json['prompt_tokens'],
49
+ 'completionTokens': json['completion_tokens'] == null ? undefined : json['completion_tokens'],
50
+ 'imageCount': json['image_count'] == null ? undefined : json['image_count'],
46
51
  };
47
52
  }
48
53
  function UsageBucketToJSON(json) {
@@ -58,5 +63,10 @@ function UsageBucketToJSONTyped(value, ignoreDiscriminator = false) {
58
63
  'gpu_type': value['gpuType'],
59
64
  'gpu_seconds': value['gpuSeconds'],
60
65
  'cost_cents': value['costCents'],
66
+ 'modality': value['modality'],
67
+ 'model': value['model'],
68
+ 'prompt_tokens': value['promptTokens'],
69
+ 'completion_tokens': value['completionTokens'],
70
+ 'image_count': value['imageCount'],
61
71
  };
62
72
  }
@@ -17,6 +17,7 @@ import type { UsageBucket } from './UsageBucket';
17
17
  */
18
18
  export interface UsagePage {
19
19
  /**
20
+ * Inference-usage rows when the request set `modality` or `model`; instance-usage rows otherwise. One page never mixes the two.
20
21
  *
21
22
  * @type {Array<UsageBucket>}
22
23
  * @memberof UsagePage
@@ -25,9 +25,6 @@ export * from './ModelPricing';
25
25
  export * from './ModelRate';
26
26
  export * from './OpenAIErrorEnvelope';
27
27
  export * from './OpenAIErrorEnvelopeError';
28
- export * from './Operation';
29
- export * from './OperationError';
30
- export * from './OperationResult';
31
28
  export * from './PeakWindow';
32
29
  export * from './Problem';
33
30
  export * from './RefereeStatus';
@@ -43,9 +43,6 @@ __exportStar(require("./ModelPricing"), exports);
43
43
  __exportStar(require("./ModelRate"), exports);
44
44
  __exportStar(require("./OpenAIErrorEnvelope"), exports);
45
45
  __exportStar(require("./OpenAIErrorEnvelopeError"), exports);
46
- __exportStar(require("./Operation"), exports);
47
- __exportStar(require("./OperationError"), exports);
48
- __exportStar(require("./OperationResult"), exports);
49
46
  __exportStar(require("./PeakWindow"), exports);
50
47
  __exportStar(require("./Problem"), exports);
51
48
  __exportStar(require("./RefereeStatus"), exports);
package/dist/runtime.js CHANGED
@@ -69,7 +69,7 @@ class Configuration {
69
69
  return undefined;
70
70
  }
71
71
  get headers() {
72
- return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.1.2' }, this.configuration.headers);
72
+ return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.2.1' }, this.configuration.headers);
73
73
  }
74
74
  get credentials() {
75
75
  return this.configuration.credentials;
@@ -7,6 +7,7 @@ All URIs are relative to *https://api.deeprelay.ai/v1*
7
7
  | [**createCryptoDeposit**](BillingApi.md#createcryptodepositoperation) | **POST** /billing/deposits/crypto | Create a stablecoin deposit |
8
8
  | [**createSubscriptionCheckout**](BillingApi.md#createsubscriptioncheckout) | **POST** /billing/subscription/checkout | Start a subscription checkout session |
9
9
  | [**createSubscriptionPortal**](BillingApi.md#createsubscriptionportal) | **POST** /billing/subscription/portal | Open the billing portal to cancel or manage the subscription |
10
+ | [**deleteSpendingLimit**](BillingApi.md#deletespendinglimit) | **DELETE** /billing/spending-limit | Clear the org spending limit |
10
11
  | [**getBalance**](BillingApi.md#getbalance) | **GET** /billing/balance | Get the org credit balance |
11
12
  | [**getDeposit**](BillingApi.md#getdeposit) | **GET** /billing/deposits/{id} | Get one stablecoin deposit |
12
13
  | [**getReferral**](BillingApi.md#getreferral) | **GET** /referrals | Get the org referral code, invite link, terms and stats |
@@ -246,6 +247,73 @@ example().catch(console.error);
246
247
  [[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
247
248
 
248
249
 
250
+ ## deleteSpendingLimit
251
+
252
+ > deleteSpendingLimit()
253
+
254
+ Clear the org spending limit
255
+
256
+ Removes the organization\&#39;s monthly spending limit and daily spend cap entirely. Requires the &#x60;billing:write&#x60; scope AND org-admin privileges (a non-admin member gets 403). Returns 404 when no limit is configured. This is the only way to remove a limit through the API, because &#x60;PUT&#x60; floors &#x60;monthly_limit_dollars&#x60; at 1.00 and so cannot express \&quot;no limit\&quot;.
257
+
258
+ ### Example
259
+
260
+ ```ts
261
+ import {
262
+ Configuration,
263
+ BillingApi,
264
+ } from '@deeprelay/sdk';
265
+ import type { DeleteSpendingLimitRequest } from '@deeprelay/sdk';
266
+
267
+ async function example() {
268
+ console.log("🚀 Testing @deeprelay/sdk SDK...");
269
+ const config = new Configuration({
270
+ // Configure HTTP bearer authorization: bearerAuth
271
+ accessToken: "YOUR BEARER TOKEN",
272
+ });
273
+ const api = new BillingApi(config);
274
+
275
+ try {
276
+ const data = await api.deleteSpendingLimit();
277
+ console.log(data);
278
+ } catch (error) {
279
+ console.error(error);
280
+ }
281
+ }
282
+
283
+ // Run the test
284
+ example().catch(console.error);
285
+ ```
286
+
287
+ ### Parameters
288
+
289
+ This endpoint does not need any parameter.
290
+
291
+ ### Return type
292
+
293
+ `void` (Empty response body)
294
+
295
+ ### Authorization
296
+
297
+ [bearerAuth](../README.md#bearerAuth)
298
+
299
+ ### HTTP request headers
300
+
301
+ - **Content-Type**: Not defined
302
+ - **Accept**: `application/problem+json`
303
+
304
+
305
+ ### HTTP response details
306
+ | Status code | Description | Response headers |
307
+ |-------------|-------------|------------------|
308
+ | **204** | No Content | - |
309
+ | **403** | Error response (RFC 7807) | - |
310
+ | **404** | Error response (RFC 7807) | - |
311
+ | **429** | Rate limit exceeded (RFC 7807). Retry-After header indicates seconds to wait. | * Retry-After - Seconds the client should wait before retrying. <br> |
312
+ | **0** | Error response (RFC 7807) | - |
313
+
314
+ [[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
315
+
316
+
249
317
  ## getBalance
250
318
 
251
319
  > Balance getBalance()
package/docs/UsageApi.md CHANGED
@@ -10,10 +10,12 @@ All URIs are relative to *https://api.deeprelay.ai/v1*
10
10
 
11
11
  ## listUsage
12
12
 
13
- > UsagePage listUsage(bucket, groupBy, start, end, cursor, limit)
13
+ > UsagePage listUsage(bucket, groupBy, start, end, cursor, limit, modality, model)
14
14
 
15
15
  Time-bucketed usage
16
16
 
17
+ Returns spend aggregated into time buckets over &#x60;[start, end)&#x60; (default: the last 30 days, &#x60;bucket&#x3D;day&#x60;), newest bucket first. The response has one of two row shapes, selected by the query: - **Inference usage** — set &#x60;modality&#x60; and/or &#x60;model&#x60;. Rows aggregate serverless inference calls, one row per (bucket, modality, model), and carry &#x60;modality&#x60;, &#x60;model&#x60;, &#x60;prompt_tokens&#x60;, &#x60;completion_tokens&#x60; and &#x60;image_count&#x60;. This is the usage a serverless-inference customer is billed for. - **Instance usage** — neither &#x60;modality&#x60; nor &#x60;model&#x60; set. Rows aggregate GPU instance billing sessions, optionally split by &#x60;group_by&#x60;. With no instance usage this returns an empty &#x60;data&#x60; array, so to read inference spend always pass &#x60;modality&#x60; or &#x60;model&#x60;. Requires the &#x60;billing:read&#x60; scope.
18
+
17
19
  ### Example
18
20
 
19
21
  ```ts
@@ -32,18 +34,22 @@ async function example() {
32
34
  const api = new UsageApi(config);
33
35
 
34
36
  const body = {
35
- // 'hour' | 'day' | 'week' | 'month' (optional)
37
+ // 'hour' | 'day' | 'week' | 'month' | Bucket width. Defaults to `day`. (optional)
36
38
  bucket: bucket_example,
37
- // 'instance_id' | 'gpu_type' (optional)
39
+ // 'instance_id' | 'gpu_type' | Split instance-usage rows by instance or GPU type. Applies only to the instance-usage shape (neither `modality` nor `model` set); ignored when either is set, since inference rows are always split by modality and model. (optional)
38
40
  groupBy: groupBy_example,
39
- // Date (optional)
41
+ // Date | Inclusive RFC 3339 range start. Defaults to 30 days ago. (optional)
40
42
  start: 2013-10-20T19:20:30+01:00,
41
- // Date (optional)
43
+ // Date | Exclusive RFC 3339 range end. Defaults to now; must be after `start`. (optional)
42
44
  end: 2013-10-20T19:20:30+01:00,
43
45
  // string (optional)
44
46
  cursor: cursor_example,
45
47
  // number (optional)
46
48
  limit: 56,
49
+ // 'chat' | 'image' | 'video' | 'embedding' | Return inference-usage rows for this modality only. Setting `modality` or `model` selects the inference-usage shape; omit both for the instance-usage shape. (optional)
50
+ modality: modality_example,
51
+ // string | Return inference-usage rows for this model only: an exact match on the model `id` as listed by `GET /models`. May be combined with `modality`. Setting `modality` or `model` selects the inference-usage shape. (optional)
52
+ model: model_example,
47
53
  } satisfies ListUsageRequest;
48
54
 
49
55
  try {
@@ -63,12 +69,14 @@ example().catch(console.error);
63
69
 
64
70
  | Name | Type | Description | Notes |
65
71
  |------------- | ------------- | ------------- | -------------|
66
- | **bucket** | `hour`, `day`, `week`, `month` | | [Optional] [Defaults to `undefined`] [Enum: hour, day, week, month] |
67
- | **groupBy** | `instance_id`, `gpu_type` | | [Optional] [Defaults to `undefined`] [Enum: instance_id, gpu_type] |
68
- | **start** | `Date` | | [Optional] [Defaults to `undefined`] |
69
- | **end** | `Date` | | [Optional] [Defaults to `undefined`] |
72
+ | **bucket** | `hour`, `day`, `week`, `month` | Bucket width. Defaults to &#x60;day&#x60;. | [Optional] [Defaults to `undefined`] [Enum: hour, day, week, month] |
73
+ | **groupBy** | `instance_id`, `gpu_type` | Split instance-usage rows by instance or GPU type. Applies only to the instance-usage shape (neither &#x60;modality&#x60; nor &#x60;model&#x60; set); ignored when either is set, since inference rows are always split by modality and model. | [Optional] [Defaults to `undefined`] [Enum: instance_id, gpu_type] |
74
+ | **start** | `Date` | Inclusive RFC 3339 range start. Defaults to 30 days ago. | [Optional] [Defaults to `undefined`] |
75
+ | **end** | `Date` | Exclusive RFC 3339 range end. Defaults to now; must be after &#x60;start&#x60;. | [Optional] [Defaults to `undefined`] |
70
76
  | **cursor** | `string` | | [Optional] [Defaults to `undefined`] |
71
77
  | **limit** | `number` | | [Optional] [Defaults to `50`] |
78
+ | **modality** | `chat`, `image`, `video`, `embedding` | Return inference-usage rows for this modality only. Setting &#x60;modality&#x60; or &#x60;model&#x60; selects the inference-usage shape; omit both for the instance-usage shape. | [Optional] [Defaults to `undefined`] [Enum: chat, image, video, embedding] |
79
+ | **model** | `string` | Return inference-usage rows for this model only: an exact match on the model &#x60;id&#x60; as listed by &#x60;GET /models&#x60;. May be combined with &#x60;modality&#x60;. Setting &#x60;modality&#x60; or &#x60;model&#x60; selects the inference-usage shape. | [Optional] [Defaults to `undefined`] |
72
80
 
73
81
  ### Return type
74
82
 
@@ -1,6 +1,7 @@
1
1
 
2
2
  # UsageBucket
3
3
 
4
+ One `/usage` row. Every row carries `bucket_start`, `gpu_seconds` and `cost_cents`. When the request set `modality` or `model` the row is an inference-usage row: it also carries `modality`, `model`, `prompt_tokens`, `completion_tokens` and `image_count` (aggregating every serverless inference call in the bucket for that modality and model), and `gpu_seconds` is always 0. Otherwise it is an instance-usage row, carrying `instance_id` / `gpu_type` when `group_by` asked for them.
4
5
 
5
6
  ## Properties
6
7
 
@@ -11,6 +12,11 @@ Name | Type
11
12
  `gpuType` | string
12
13
  `gpuSeconds` | number
13
14
  `costCents` | number
15
+ `modality` | string
16
+ `model` | string
17
+ `promptTokens` | number
18
+ `completionTokens` | number
19
+ `imageCount` | number
14
20
 
15
21
  ## Example
16
22
 
@@ -24,6 +30,11 @@ const example = {
24
30
  "gpuType": null,
25
31
  "gpuSeconds": null,
26
32
  "costCents": null,
33
+ "modality": null,
34
+ "model": null,
35
+ "promptTokens": null,
36
+ "completionTokens": null,
37
+ "imageCount": null,
27
38
  } satisfies UsageBucket
28
39
 
29
40
  console.log(example)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeprelay/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "TypeScript SDK for the deeprelay Public Developer API",
5
5
  "author": "deeprelay Support <support@deeprelay.ai>",
6
6
  "repository": {
@@ -261,6 +261,52 @@ export class BillingApi extends runtime.BaseAPI {
261
261
  return await response.value();
262
262
  }
263
263
 
264
+ /**
265
+ * Creates request options for deleteSpendingLimit without sending the request
266
+ */
267
+ async deleteSpendingLimitRequestOpts(): Promise<runtime.RequestOpts> {
268
+ const queryParameters: any = {};
269
+
270
+ const headerParameters: runtime.HTTPHeaders = {};
271
+
272
+ if (this.configuration && this.configuration.accessToken) {
273
+ const token = this.configuration.accessToken;
274
+ const tokenString = await token("bearerAuth", []);
275
+
276
+ if (tokenString) {
277
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
278
+ }
279
+ }
280
+
281
+ let urlPath = `/billing/spending-limit`;
282
+
283
+ return {
284
+ path: urlPath,
285
+ method: 'DELETE',
286
+ headers: headerParameters,
287
+ query: queryParameters,
288
+ };
289
+ }
290
+
291
+ /**
292
+ * Removes the organization\'s monthly spending limit and daily spend cap entirely. Requires the `billing:write` scope AND org-admin privileges (a non-admin member gets 403). Returns 404 when no limit is configured. This is the only way to remove a limit through the API, because `PUT` floors `monthly_limit_dollars` at 1.00 and so cannot express \"no limit\".
293
+ * Clear the org spending limit
294
+ */
295
+ async deleteSpendingLimitRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
296
+ const requestOptions = await this.deleteSpendingLimitRequestOpts();
297
+ const response = await this.request(requestOptions, initOverrides);
298
+
299
+ return new runtime.VoidApiResponse(response);
300
+ }
301
+
302
+ /**
303
+ * Removes the organization\'s monthly spending limit and daily spend cap entirely. Requires the `billing:write` scope AND org-admin privileges (a non-admin member gets 403). Returns 404 when no limit is configured. This is the only way to remove a limit through the API, because `PUT` floors `monthly_limit_dollars` at 1.00 and so cannot express \"no limit\".
304
+ * Clear the org spending limit
305
+ */
306
+ async deleteSpendingLimit(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
307
+ await this.deleteSpendingLimitRaw(initOverrides);
308
+ }
309
+
264
310
  /**
265
311
  * Creates request options for getBalance without sending the request
266
312
  */
@@ -31,6 +31,8 @@ export interface ListUsageRequest {
31
31
  end?: Date;
32
32
  cursor?: string;
33
33
  limit?: number;
34
+ modality?: ListUsageModalityEnum;
35
+ model?: string;
34
36
  }
35
37
 
36
38
  /**
@@ -68,6 +70,14 @@ export class UsageApi extends runtime.BaseAPI {
68
70
  queryParameters['limit'] = requestParameters['limit'];
69
71
  }
70
72
 
73
+ if (requestParameters['modality'] != null) {
74
+ queryParameters['modality'] = requestParameters['modality'];
75
+ }
76
+
77
+ if (requestParameters['model'] != null) {
78
+ queryParameters['model'] = requestParameters['model'];
79
+ }
80
+
71
81
  const headerParameters: runtime.HTTPHeaders = {};
72
82
 
73
83
  if (this.configuration && this.configuration.accessToken) {
@@ -90,6 +100,7 @@ export class UsageApi extends runtime.BaseAPI {
90
100
  }
91
101
 
92
102
  /**
103
+ * Returns spend aggregated into time buckets over `[start, end)` (default: the last 30 days, `bucket=day`), newest bucket first. The response has one of two row shapes, selected by the query: - **Inference usage** — set `modality` and/or `model`. Rows aggregate serverless inference calls, one row per (bucket, modality, model), and carry `modality`, `model`, `prompt_tokens`, `completion_tokens` and `image_count`. This is the usage a serverless-inference customer is billed for. - **Instance usage** — neither `modality` nor `model` set. Rows aggregate GPU instance billing sessions, optionally split by `group_by`. With no instance usage this returns an empty `data` array, so to read inference spend always pass `modality` or `model`. Requires the `billing:read` scope.
93
104
  * Time-bucketed usage
94
105
  */
95
106
  async listUsageRaw(requestParameters: ListUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UsagePage>> {
@@ -100,6 +111,7 @@ export class UsageApi extends runtime.BaseAPI {
100
111
  }
101
112
 
102
113
  /**
114
+ * Returns spend aggregated into time buckets over `[start, end)` (default: the last 30 days, `bucket=day`), newest bucket first. The response has one of two row shapes, selected by the query: - **Inference usage** — set `modality` and/or `model`. Rows aggregate serverless inference calls, one row per (bucket, modality, model), and carry `modality`, `model`, `prompt_tokens`, `completion_tokens` and `image_count`. This is the usage a serverless-inference customer is billed for. - **Instance usage** — neither `modality` nor `model` set. Rows aggregate GPU instance billing sessions, optionally split by `group_by`. With no instance usage this returns an empty `data` array, so to read inference spend always pass `modality` or `model`. Requires the `billing:read` scope.
103
115
  * Time-bucketed usage
104
116
  */
105
117
  async listUsage(requestParameters: ListUsageRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UsagePage> {
@@ -127,3 +139,13 @@ export const ListUsageGroupByEnum = {
127
139
  GpuType: 'gpu_type'
128
140
  } as const;
129
141
  export type ListUsageGroupByEnum = typeof ListUsageGroupByEnum[keyof typeof ListUsageGroupByEnum];
142
+ /**
143
+ * @export
144
+ */
145
+ export const ListUsageModalityEnum = {
146
+ Chat: 'chat',
147
+ Image: 'image',
148
+ Video: 'video',
149
+ Embedding: 'embedding'
150
+ } as const;
151
+ export type ListUsageModalityEnum = typeof ListUsageModalityEnum[keyof typeof ListUsageModalityEnum];
package/src/apis/index.ts CHANGED
@@ -3,6 +3,5 @@
3
3
  export * from './BillingApi';
4
4
  export * from './InferenceApi';
5
5
  export * from './MetaApi';
6
- export * from './OperationsApi';
7
6
  export * from './UsageApi';
8
7
  export * from './WebhooksApi';
@@ -14,41 +14,74 @@
14
14
 
15
15
  import { mapValues } from '../runtime';
16
16
  /**
17
+ * One `/usage` row. Every row carries `bucket_start`, `gpu_seconds` and `cost_cents`. When the request set `modality` or `model` the row is an inference-usage row: it also carries `modality`, `model`, `prompt_tokens`, `completion_tokens` and `image_count` (aggregating every serverless inference call in the bucket for that modality and model), and `gpu_seconds` is always 0. Otherwise it is an instance-usage row, carrying `instance_id` / `gpu_type` when `group_by` asked for them.
17
18
  *
18
19
  * @export
19
20
  * @interface UsageBucket
20
21
  */
21
22
  export interface UsageBucket {
22
23
  /**
23
- *
24
+ * Start of the time bucket (truncated to `bucket`).
24
25
  * @type {Date}
25
26
  * @memberof UsageBucket
26
27
  */
27
28
  bucketStart: Date;
28
29
  /**
29
- *
30
+ * Instance-usage rows with `group_by=instance_id` only.
30
31
  * @type {string}
31
32
  * @memberof UsageBucket
32
33
  */
33
34
  instanceId?: string;
34
35
  /**
35
- *
36
+ * Instance-usage rows with `group_by=gpu_type` only.
36
37
  * @type {string}
37
38
  * @memberof UsageBucket
38
39
  */
39
40
  gpuType?: string;
40
41
  /**
41
- *
42
+ * GPU instance seconds billed in the bucket. Always 0 on inference-usage rows.
42
43
  * @type {number}
43
44
  * @memberof UsageBucket
44
45
  */
45
46
  gpuSeconds: number;
46
47
  /**
47
- *
48
+ * Total cost of the row, in US cents.
48
49
  * @type {number}
49
50
  * @memberof UsageBucket
50
51
  */
51
52
  costCents: number;
53
+ /**
54
+ * Inference-usage rows only: the modality of the calls in this row (chat, image, video or embedding).
55
+ *
56
+ * @type {string}
57
+ * @memberof UsageBucket
58
+ */
59
+ modality?: string;
60
+ /**
61
+ * Inference-usage rows only: the model `id` the calls in this row were made against.
62
+ *
63
+ * @type {string}
64
+ * @memberof UsageBucket
65
+ */
66
+ model?: string;
67
+ /**
68
+ * Inference-usage rows only. Sum of input tokens; 0 for modalities not billed per token.
69
+ * @type {number}
70
+ * @memberof UsageBucket
71
+ */
72
+ promptTokens?: number;
73
+ /**
74
+ * Inference-usage rows only. Sum of output tokens; 0 for modalities not billed per token.
75
+ * @type {number}
76
+ * @memberof UsageBucket
77
+ */
78
+ completionTokens?: number;
79
+ /**
80
+ * Inference-usage rows only. Sum of generated images; 0 for non-image modalities.
81
+ * @type {number}
82
+ * @memberof UsageBucket
83
+ */
84
+ imageCount?: number;
52
85
  }
53
86
 
54
87
  /**
@@ -76,6 +109,11 @@ export function UsageBucketFromJSONTyped(json: any, ignoreDiscriminator: boolean
76
109
  'gpuType': json['gpu_type'] == null ? undefined : json['gpu_type'],
77
110
  'gpuSeconds': json['gpu_seconds'],
78
111
  'costCents': json['cost_cents'],
112
+ 'modality': json['modality'] == null ? undefined : json['modality'],
113
+ 'model': json['model'] == null ? undefined : json['model'],
114
+ 'promptTokens': json['prompt_tokens'] == null ? undefined : json['prompt_tokens'],
115
+ 'completionTokens': json['completion_tokens'] == null ? undefined : json['completion_tokens'],
116
+ 'imageCount': json['image_count'] == null ? undefined : json['image_count'],
79
117
  };
80
118
  }
81
119
 
@@ -95,6 +133,11 @@ export function UsageBucketToJSONTyped(value?: UsageBucket | null, ignoreDiscrim
95
133
  'gpu_type': value['gpuType'],
96
134
  'gpu_seconds': value['gpuSeconds'],
97
135
  'cost_cents': value['costCents'],
136
+ 'modality': value['modality'],
137
+ 'model': value['model'],
138
+ 'prompt_tokens': value['promptTokens'],
139
+ 'completion_tokens': value['completionTokens'],
140
+ 'image_count': value['imageCount'],
98
141
  };
99
142
  }
100
143
 
@@ -28,6 +28,7 @@ import {
28
28
  */
29
29
  export interface UsagePage {
30
30
  /**
31
+ * Inference-usage rows when the request set `modality` or `model`; instance-usage rows otherwise. One page never mixes the two.
31
32
  *
32
33
  * @type {Array<UsageBucket>}
33
34
  * @memberof UsagePage
@@ -27,9 +27,6 @@ export * from './ModelPricing';
27
27
  export * from './ModelRate';
28
28
  export * from './OpenAIErrorEnvelope';
29
29
  export * from './OpenAIErrorEnvelopeError';
30
- export * from './Operation';
31
- export * from './OperationError';
32
- export * from './OperationResult';
33
30
  export * from './PeakWindow';
34
31
  export * from './Problem';
35
32
  export * from './RefereeStatus';
package/src/runtime.ts CHANGED
@@ -75,7 +75,7 @@ export class Configuration {
75
75
  }
76
76
 
77
77
  get headers(): HTTPHeaders | undefined {
78
- return { 'User-Agent': 'deeprelay-sdk-ts/0.1.2', ...this.configuration.headers };
78
+ return { 'User-Agent': 'deeprelay-sdk-ts/0.2.1', ...this.configuration.headers };
79
79
  }
80
80
 
81
81
  get credentials(): RequestCredentials | undefined {
@@ -1,33 +0,0 @@
1
- /**
2
- * deeprelay Public Developer API
3
- * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
4
- *
5
- * The version of the OpenAPI document: 1.0.0
6
- * Contact: support@deeprelay.ai
7
- *
8
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
- * https://openapi-generator.tech
10
- * Do not edit the class manually.
11
- */
12
- import * as runtime from '../runtime';
13
- import { type Operation } from '../models/Operation';
14
- export interface GetOperationRequest {
15
- id: string;
16
- }
17
- /**
18
- *
19
- */
20
- export declare class OperationsApi extends runtime.BaseAPI {
21
- /**
22
- * Creates request options for getOperation without sending the request
23
- */
24
- getOperationRequestOpts(requestParameters: GetOperationRequest): Promise<runtime.RequestOpts>;
25
- /**
26
- * Get an async operation status
27
- */
28
- getOperationRaw(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Operation>>;
29
- /**
30
- * Get an async operation status
31
- */
32
- getOperation(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Operation>;
33
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
- /* tslint:disable */
3
- /* eslint-disable */
4
- /**
5
- * deeprelay Public Developer API
6
- * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
7
- *
8
- * The version of the OpenAPI document: 1.0.0
9
- * Contact: support@deeprelay.ai
10
- *
11
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
- * https://openapi-generator.tech
13
- * Do not edit the class manually.
14
- */
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.OperationsApi = void 0;
26
- const runtime = require("../runtime");
27
- const Operation_1 = require("../models/Operation");
28
- /**
29
- *
30
- */
31
- class OperationsApi extends runtime.BaseAPI {
32
- /**
33
- * Creates request options for getOperation without sending the request
34
- */
35
- getOperationRequestOpts(requestParameters) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- if (requestParameters['id'] == null) {
38
- throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling getOperation().');
39
- }
40
- const queryParameters = {};
41
- const headerParameters = {};
42
- if (this.configuration && this.configuration.accessToken) {
43
- const token = this.configuration.accessToken;
44
- const tokenString = yield token("bearerAuth", []);
45
- if (tokenString) {
46
- headerParameters["Authorization"] = `Bearer ${tokenString}`;
47
- }
48
- }
49
- let urlPath = `/operations/{id}`;
50
- urlPath = urlPath.replace('{id}', encodeURIComponent(String(requestParameters['id'])));
51
- return {
52
- path: urlPath,
53
- method: 'GET',
54
- headers: headerParameters,
55
- query: queryParameters,
56
- };
57
- });
58
- }
59
- /**
60
- * Get an async operation status
61
- */
62
- getOperationRaw(requestParameters, initOverrides) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const requestOptions = yield this.getOperationRequestOpts(requestParameters);
65
- const response = yield this.request(requestOptions, initOverrides);
66
- return new runtime.JSONApiResponse(response, (jsonValue) => (0, Operation_1.OperationFromJSON)(jsonValue));
67
- });
68
- }
69
- /**
70
- * Get an async operation status
71
- */
72
- getOperation(requestParameters, initOverrides) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- const response = yield this.getOperationRaw(requestParameters, initOverrides);
75
- return yield response.value();
76
- });
77
- }
78
- }
79
- exports.OperationsApi = OperationsApi;
@@ -1,33 +0,0 @@
1
- /**
2
- * deeprelay Public Developer API
3
- * Programmatic API for deeprelay. Authenticate with API keys minted from the dashboard. See https://deeprelay.ai/docs for details.
4
- *
5
- * The version of the OpenAPI document: 1.0.0
6
- * Contact: support@deeprelay.ai
7
- *
8
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
- * https://openapi-generator.tech
10
- * Do not edit the class manually.
11
- */
12
- import * as runtime from '../runtime';
13
- import { type Operation } from '../models/Operation';
14
- export interface GetOperationRequest {
15
- id: string;
16
- }
17
- /**
18
- *
19
- */
20
- export declare class OperationsApi extends runtime.BaseAPI {
21
- /**
22
- * Creates request options for getOperation without sending the request
23
- */
24
- getOperationRequestOpts(requestParameters: GetOperationRequest): Promise<runtime.RequestOpts>;
25
- /**
26
- * Get an async operation status
27
- */
28
- getOperationRaw(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Operation>>;
29
- /**
30
- * Get an async operation status
31
- */
32
- getOperation(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Operation>;
33
- }