@deeprelay/sdk 0.2.0 → 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.
- package/README.md +2 -2
- package/dist/apis/UsageApi.d.ts +14 -0
- package/dist/apis/UsageApi.js +18 -1
- package/dist/esm/apis/UsageApi.d.ts +14 -0
- package/dist/esm/apis/UsageApi.js +17 -0
- package/dist/esm/models/UsageBucket.d.ts +38 -5
- package/dist/esm/models/UsageBucket.js +10 -0
- package/dist/esm/models/UsagePage.d.ts +1 -0
- package/dist/esm/runtime.js +1 -1
- package/dist/models/UsageBucket.d.ts +38 -5
- package/dist/models/UsageBucket.js +10 -0
- package/dist/models/UsagePage.d.ts +1 -0
- package/dist/runtime.js +1 -1
- package/docs/UsageApi.md +17 -9
- package/docs/UsageBucket.md +11 -0
- package/package.json +1 -1
- package/src/apis/UsageApi.ts +22 -0
- package/src/models/UsageBucket.ts +48 -5
- package/src/models/UsagePage.ts +1 -0
- package/src/runtime.ts +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @deeprelay/sdk@0.2.
|
|
1
|
+
# @deeprelay/sdk@0.2.1
|
|
2
2
|
|
|
3
3
|
A TypeScript SDK client for the api.deeprelay.ai API.
|
|
4
4
|
|
|
@@ -156,7 +156,7 @@ and is automatically generated by the
|
|
|
156
156
|
[OpenAPI Generator](https://openapi-generator.tech) project:
|
|
157
157
|
|
|
158
158
|
- API version: `1.0.0`
|
|
159
|
-
- Package version: `0.2.
|
|
159
|
+
- Package version: `0.2.1`
|
|
160
160
|
- Generator version: `7.24.0`
|
|
161
161
|
- Build package: `org.openapitools.codegen.languages.TypeScriptFetchClientCodegen`
|
|
162
162
|
|
package/dist/apis/UsageApi.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface ListUsageRequest {
|
|
|
18
18
|
end?: Date;
|
|
19
19
|
cursor?: string;
|
|
20
20
|
limit?: number;
|
|
21
|
+
modality?: ListUsageModalityEnum;
|
|
22
|
+
model?: string;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
*
|
|
@@ -28,10 +30,12 @@ export declare class UsageApi extends runtime.BaseAPI {
|
|
|
28
30
|
*/
|
|
29
31
|
listUsageRequestOpts(requestParameters: ListUsageRequest): Promise<runtime.RequestOpts>;
|
|
30
32
|
/**
|
|
33
|
+
* 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.
|
|
31
34
|
* Time-bucketed usage
|
|
32
35
|
*/
|
|
33
36
|
listUsageRaw(requestParameters: ListUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UsagePage>>;
|
|
34
37
|
/**
|
|
38
|
+
* 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.
|
|
35
39
|
* Time-bucketed usage
|
|
36
40
|
*/
|
|
37
41
|
listUsage(requestParameters?: ListUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UsagePage>;
|
|
@@ -54,3 +58,13 @@ export declare const ListUsageGroupByEnum: {
|
|
|
54
58
|
readonly GpuType: "gpu_type";
|
|
55
59
|
};
|
|
56
60
|
export type ListUsageGroupByEnum = typeof ListUsageGroupByEnum[keyof typeof ListUsageGroupByEnum];
|
|
61
|
+
/**
|
|
62
|
+
* @export
|
|
63
|
+
*/
|
|
64
|
+
export declare const ListUsageModalityEnum: {
|
|
65
|
+
readonly Chat: "chat";
|
|
66
|
+
readonly Image: "image";
|
|
67
|
+
readonly Video: "video";
|
|
68
|
+
readonly Embedding: "embedding";
|
|
69
|
+
};
|
|
70
|
+
export type ListUsageModalityEnum = typeof ListUsageModalityEnum[keyof typeof ListUsageModalityEnum];
|
package/dist/apis/UsageApi.js
CHANGED
|
@@ -22,7 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.ListUsageGroupByEnum = exports.ListUsageBucketEnum = exports.UsageApi = void 0;
|
|
25
|
+
exports.ListUsageModalityEnum = exports.ListUsageGroupByEnum = exports.ListUsageBucketEnum = exports.UsageApi = void 0;
|
|
26
26
|
const runtime = require("../runtime");
|
|
27
27
|
const UsagePage_1 = require("../models/UsagePage");
|
|
28
28
|
/**
|
|
@@ -53,6 +53,12 @@ class UsageApi extends runtime.BaseAPI {
|
|
|
53
53
|
if (requestParameters['limit'] != null) {
|
|
54
54
|
queryParameters['limit'] = requestParameters['limit'];
|
|
55
55
|
}
|
|
56
|
+
if (requestParameters['modality'] != null) {
|
|
57
|
+
queryParameters['modality'] = requestParameters['modality'];
|
|
58
|
+
}
|
|
59
|
+
if (requestParameters['model'] != null) {
|
|
60
|
+
queryParameters['model'] = requestParameters['model'];
|
|
61
|
+
}
|
|
56
62
|
const headerParameters = {};
|
|
57
63
|
if (this.configuration && this.configuration.accessToken) {
|
|
58
64
|
const token = this.configuration.accessToken;
|
|
@@ -71,6 +77,7 @@ class UsageApi extends runtime.BaseAPI {
|
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
80
|
+
* 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.
|
|
74
81
|
* Time-bucketed usage
|
|
75
82
|
*/
|
|
76
83
|
listUsageRaw(requestParameters, initOverrides) {
|
|
@@ -81,6 +88,7 @@ class UsageApi extends runtime.BaseAPI {
|
|
|
81
88
|
});
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
91
|
+
* 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.
|
|
84
92
|
* Time-bucketed usage
|
|
85
93
|
*/
|
|
86
94
|
listUsage() {
|
|
@@ -107,3 +115,12 @@ exports.ListUsageGroupByEnum = {
|
|
|
107
115
|
InstanceId: 'instance_id',
|
|
108
116
|
GpuType: 'gpu_type'
|
|
109
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* @export
|
|
120
|
+
*/
|
|
121
|
+
exports.ListUsageModalityEnum = {
|
|
122
|
+
Chat: 'chat',
|
|
123
|
+
Image: 'image',
|
|
124
|
+
Video: 'video',
|
|
125
|
+
Embedding: 'embedding'
|
|
126
|
+
};
|
|
@@ -18,6 +18,8 @@ export interface ListUsageRequest {
|
|
|
18
18
|
end?: Date;
|
|
19
19
|
cursor?: string;
|
|
20
20
|
limit?: number;
|
|
21
|
+
modality?: ListUsageModalityEnum;
|
|
22
|
+
model?: string;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
*
|
|
@@ -28,10 +30,12 @@ export declare class UsageApi extends runtime.BaseAPI {
|
|
|
28
30
|
*/
|
|
29
31
|
listUsageRequestOpts(requestParameters: ListUsageRequest): Promise<runtime.RequestOpts>;
|
|
30
32
|
/**
|
|
33
|
+
* 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.
|
|
31
34
|
* Time-bucketed usage
|
|
32
35
|
*/
|
|
33
36
|
listUsageRaw(requestParameters: ListUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UsagePage>>;
|
|
34
37
|
/**
|
|
38
|
+
* 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.
|
|
35
39
|
* Time-bucketed usage
|
|
36
40
|
*/
|
|
37
41
|
listUsage(requestParameters?: ListUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UsagePage>;
|
|
@@ -54,3 +58,13 @@ export declare const ListUsageGroupByEnum: {
|
|
|
54
58
|
readonly GpuType: "gpu_type";
|
|
55
59
|
};
|
|
56
60
|
export type ListUsageGroupByEnum = typeof ListUsageGroupByEnum[keyof typeof ListUsageGroupByEnum];
|
|
61
|
+
/**
|
|
62
|
+
* @export
|
|
63
|
+
*/
|
|
64
|
+
export declare const ListUsageModalityEnum: {
|
|
65
|
+
readonly Chat: "chat";
|
|
66
|
+
readonly Image: "image";
|
|
67
|
+
readonly Video: "video";
|
|
68
|
+
readonly Embedding: "embedding";
|
|
69
|
+
};
|
|
70
|
+
export type ListUsageModalityEnum = typeof ListUsageModalityEnum[keyof typeof ListUsageModalityEnum];
|
|
@@ -50,6 +50,12 @@ export class UsageApi extends runtime.BaseAPI {
|
|
|
50
50
|
if (requestParameters['limit'] != null) {
|
|
51
51
|
queryParameters['limit'] = requestParameters['limit'];
|
|
52
52
|
}
|
|
53
|
+
if (requestParameters['modality'] != null) {
|
|
54
|
+
queryParameters['modality'] = requestParameters['modality'];
|
|
55
|
+
}
|
|
56
|
+
if (requestParameters['model'] != null) {
|
|
57
|
+
queryParameters['model'] = requestParameters['model'];
|
|
58
|
+
}
|
|
53
59
|
const headerParameters = {};
|
|
54
60
|
if (this.configuration && this.configuration.accessToken) {
|
|
55
61
|
const token = this.configuration.accessToken;
|
|
@@ -68,6 +74,7 @@ export class UsageApi extends runtime.BaseAPI {
|
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
77
|
+
* 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.
|
|
71
78
|
* Time-bucketed usage
|
|
72
79
|
*/
|
|
73
80
|
listUsageRaw(requestParameters, initOverrides) {
|
|
@@ -78,6 +85,7 @@ export class UsageApi extends runtime.BaseAPI {
|
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
87
|
/**
|
|
88
|
+
* 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.
|
|
81
89
|
* Time-bucketed usage
|
|
82
90
|
*/
|
|
83
91
|
listUsage() {
|
|
@@ -103,3 +111,12 @@ export const ListUsageGroupByEnum = {
|
|
|
103
111
|
InstanceId: 'instance_id',
|
|
104
112
|
GpuType: 'gpu_type'
|
|
105
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* @export
|
|
116
|
+
*/
|
|
117
|
+
export const ListUsageModalityEnum = {
|
|
118
|
+
Chat: 'chat',
|
|
119
|
+
Image: 'image',
|
|
120
|
+
Video: 'video',
|
|
121
|
+
Embedding: 'embedding'
|
|
122
|
+
};
|
|
@@ -10,41 +10,74 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
+
* 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.
|
|
13
14
|
*
|
|
14
15
|
* @export
|
|
15
16
|
* @interface UsageBucket
|
|
16
17
|
*/
|
|
17
18
|
export interface UsageBucket {
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Start of the time bucket (truncated to `bucket`).
|
|
20
21
|
* @type {Date}
|
|
21
22
|
* @memberof UsageBucket
|
|
22
23
|
*/
|
|
23
24
|
bucketStart: Date;
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Instance-usage rows with `group_by=instance_id` only.
|
|
26
27
|
* @type {string}
|
|
27
28
|
* @memberof UsageBucket
|
|
28
29
|
*/
|
|
29
30
|
instanceId?: string;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Instance-usage rows with `group_by=gpu_type` only.
|
|
32
33
|
* @type {string}
|
|
33
34
|
* @memberof UsageBucket
|
|
34
35
|
*/
|
|
35
36
|
gpuType?: string;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* GPU instance seconds billed in the bucket. Always 0 on inference-usage rows.
|
|
38
39
|
* @type {number}
|
|
39
40
|
* @memberof UsageBucket
|
|
40
41
|
*/
|
|
41
42
|
gpuSeconds: number;
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
+
* Total cost of the row, in US cents.
|
|
44
45
|
* @type {number}
|
|
45
46
|
* @memberof UsageBucket
|
|
46
47
|
*/
|
|
47
48
|
costCents: number;
|
|
49
|
+
/**
|
|
50
|
+
* Inference-usage rows only: the modality of the calls in this row (chat, image, video or embedding).
|
|
51
|
+
*
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @memberof UsageBucket
|
|
54
|
+
*/
|
|
55
|
+
modality?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Inference-usage rows only: the model `id` the calls in this row were made against.
|
|
58
|
+
*
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @memberof UsageBucket
|
|
61
|
+
*/
|
|
62
|
+
model?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Inference-usage rows only. Sum of input tokens; 0 for modalities not billed per token.
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @memberof UsageBucket
|
|
67
|
+
*/
|
|
68
|
+
promptTokens?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Inference-usage rows only. Sum of output tokens; 0 for modalities not billed per token.
|
|
71
|
+
* @type {number}
|
|
72
|
+
* @memberof UsageBucket
|
|
73
|
+
*/
|
|
74
|
+
completionTokens?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Inference-usage rows only. Sum of generated images; 0 for non-image modalities.
|
|
77
|
+
* @type {number}
|
|
78
|
+
* @memberof UsageBucket
|
|
79
|
+
*/
|
|
80
|
+
imageCount?: number;
|
|
48
81
|
}
|
|
49
82
|
/**
|
|
50
83
|
* Check if a given object implements the UsageBucket interface.
|
|
@@ -36,6 +36,11 @@ export function UsageBucketFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
36
36
|
'gpuType': json['gpu_type'] == null ? undefined : json['gpu_type'],
|
|
37
37
|
'gpuSeconds': json['gpu_seconds'],
|
|
38
38
|
'costCents': json['cost_cents'],
|
|
39
|
+
'modality': json['modality'] == null ? undefined : json['modality'],
|
|
40
|
+
'model': json['model'] == null ? undefined : json['model'],
|
|
41
|
+
'promptTokens': json['prompt_tokens'] == null ? undefined : json['prompt_tokens'],
|
|
42
|
+
'completionTokens': json['completion_tokens'] == null ? undefined : json['completion_tokens'],
|
|
43
|
+
'imageCount': json['image_count'] == null ? undefined : json['image_count'],
|
|
39
44
|
};
|
|
40
45
|
}
|
|
41
46
|
export function UsageBucketToJSON(json) {
|
|
@@ -51,5 +56,10 @@ export function UsageBucketToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
51
56
|
'gpu_type': value['gpuType'],
|
|
52
57
|
'gpu_seconds': value['gpuSeconds'],
|
|
53
58
|
'cost_cents': value['costCents'],
|
|
59
|
+
'modality': value['modality'],
|
|
60
|
+
'model': value['model'],
|
|
61
|
+
'prompt_tokens': value['promptTokens'],
|
|
62
|
+
'completion_tokens': value['completionTokens'],
|
|
63
|
+
'image_count': value['imageCount'],
|
|
54
64
|
};
|
|
55
65
|
}
|
|
@@ -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
|
package/dist/esm/runtime.js
CHANGED
|
@@ -61,7 +61,7 @@ export class Configuration {
|
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
63
|
get headers() {
|
|
64
|
-
return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.2.
|
|
64
|
+
return Object.assign({ 'User-Agent': 'deeprelay-sdk-ts/0.2.1' }, this.configuration.headers);
|
|
65
65
|
}
|
|
66
66
|
get credentials() {
|
|
67
67
|
return this.configuration.credentials;
|
|
@@ -10,41 +10,74 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
+
* 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.
|
|
13
14
|
*
|
|
14
15
|
* @export
|
|
15
16
|
* @interface UsageBucket
|
|
16
17
|
*/
|
|
17
18
|
export interface UsageBucket {
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Start of the time bucket (truncated to `bucket`).
|
|
20
21
|
* @type {Date}
|
|
21
22
|
* @memberof UsageBucket
|
|
22
23
|
*/
|
|
23
24
|
bucketStart: Date;
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Instance-usage rows with `group_by=instance_id` only.
|
|
26
27
|
* @type {string}
|
|
27
28
|
* @memberof UsageBucket
|
|
28
29
|
*/
|
|
29
30
|
instanceId?: string;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Instance-usage rows with `group_by=gpu_type` only.
|
|
32
33
|
* @type {string}
|
|
33
34
|
* @memberof UsageBucket
|
|
34
35
|
*/
|
|
35
36
|
gpuType?: string;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* GPU instance seconds billed in the bucket. Always 0 on inference-usage rows.
|
|
38
39
|
* @type {number}
|
|
39
40
|
* @memberof UsageBucket
|
|
40
41
|
*/
|
|
41
42
|
gpuSeconds: number;
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
+
* Total cost of the row, in US cents.
|
|
44
45
|
* @type {number}
|
|
45
46
|
* @memberof UsageBucket
|
|
46
47
|
*/
|
|
47
48
|
costCents: number;
|
|
49
|
+
/**
|
|
50
|
+
* Inference-usage rows only: the modality of the calls in this row (chat, image, video or embedding).
|
|
51
|
+
*
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @memberof UsageBucket
|
|
54
|
+
*/
|
|
55
|
+
modality?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Inference-usage rows only: the model `id` the calls in this row were made against.
|
|
58
|
+
*
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @memberof UsageBucket
|
|
61
|
+
*/
|
|
62
|
+
model?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Inference-usage rows only. Sum of input tokens; 0 for modalities not billed per token.
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @memberof UsageBucket
|
|
67
|
+
*/
|
|
68
|
+
promptTokens?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Inference-usage rows only. Sum of output tokens; 0 for modalities not billed per token.
|
|
71
|
+
* @type {number}
|
|
72
|
+
* @memberof UsageBucket
|
|
73
|
+
*/
|
|
74
|
+
completionTokens?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Inference-usage rows only. Sum of generated images; 0 for non-image modalities.
|
|
77
|
+
* @type {number}
|
|
78
|
+
* @memberof UsageBucket
|
|
79
|
+
*/
|
|
80
|
+
imageCount?: number;
|
|
48
81
|
}
|
|
49
82
|
/**
|
|
50
83
|
* Check if a given object implements the UsageBucket interface.
|
|
@@ -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
|
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.2.
|
|
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;
|
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 `[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.
|
|
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` |
|
|
67
|
-
| **groupBy** | `instance_id`, `gpu_type` | | [Optional] [Defaults to `undefined`] [Enum: instance_id, gpu_type] |
|
|
68
|
-
| **start** | `Date` |
|
|
69
|
-
| **end** | `Date` |
|
|
72
|
+
| **bucket** | `hour`, `day`, `week`, `month` | Bucket width. Defaults to `day`. | [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 `modality` nor `model` 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 `start`. | [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 `modality` or `model` 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 `id` as listed by `GET /models`. May be combined with `modality`. Setting `modality` or `model` selects the inference-usage shape. | [Optional] [Defaults to `undefined`] |
|
|
72
80
|
|
|
73
81
|
### Return type
|
|
74
82
|
|
package/docs/UsageBucket.md
CHANGED
|
@@ -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
package/src/apis/UsageApi.ts
CHANGED
|
@@ -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];
|
|
@@ -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
|
|
package/src/models/UsagePage.ts
CHANGED
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.2.
|
|
78
|
+
return { 'User-Agent': 'deeprelay-sdk-ts/0.2.1', ...this.configuration.headers };
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
get credentials(): RequestCredentials | undefined {
|