@acarmisc/backstage-plugin-litellm-backend 0.1.16 → 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/dist/client.d.ts +69 -0
- package/dist/client.js +312 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +26 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.js +23 -0
- package/dist/provisioning.d.ts +87 -0
- package/dist/provisioning.js +339 -0
- package/dist/router.d.ts +12 -0
- package/dist/router.js +274 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.js +2 -0
- package/package.json +9 -9
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export interface UserInfo {
|
|
2
|
+
user_id: string;
|
|
3
|
+
user_email?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
teams?: string[];
|
|
6
|
+
models?: string[];
|
|
7
|
+
max_budget?: number;
|
|
8
|
+
spend?: number;
|
|
9
|
+
current_spend?: number;
|
|
10
|
+
soft_limit?: number;
|
|
11
|
+
hard_limit?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TeamMember {
|
|
14
|
+
user_id: string;
|
|
15
|
+
role: 'admin' | 'user';
|
|
16
|
+
}
|
|
17
|
+
export interface TeamInfo {
|
|
18
|
+
team_id: string;
|
|
19
|
+
team_alias?: string;
|
|
20
|
+
max_budget?: number;
|
|
21
|
+
spend: number;
|
|
22
|
+
members_with_roles?: TeamMember[];
|
|
23
|
+
models?: string[];
|
|
24
|
+
tpm_limit?: number;
|
|
25
|
+
rpm_limit?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface VirtualKey {
|
|
28
|
+
key: string;
|
|
29
|
+
token: string;
|
|
30
|
+
key_alias?: string;
|
|
31
|
+
created_at: string;
|
|
32
|
+
expires_at?: string;
|
|
33
|
+
spend: number;
|
|
34
|
+
max_budget?: number;
|
|
35
|
+
tpm_limit?: number;
|
|
36
|
+
rpm_limit?: number;
|
|
37
|
+
models?: string[];
|
|
38
|
+
user_id?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Shape of a single entry inside LiteLLM's `/user/info` `keys` array.
|
|
42
|
+
* Differs from VirtualKey: uses `expires` (not `expires_at`), exposes
|
|
43
|
+
* both a hashed `token` and a masked `key_name`, and fields are nullable
|
|
44
|
+
* rather than optional.
|
|
45
|
+
*/
|
|
46
|
+
export interface LiteLLMUserKey {
|
|
47
|
+
token: string;
|
|
48
|
+
key_name?: string;
|
|
49
|
+
key_alias?: string | null;
|
|
50
|
+
spend?: number;
|
|
51
|
+
expires?: string | null;
|
|
52
|
+
models?: string[];
|
|
53
|
+
tpm_limit?: number | null;
|
|
54
|
+
rpm_limit?: number | null;
|
|
55
|
+
max_budget?: number | null;
|
|
56
|
+
user_id?: string | null;
|
|
57
|
+
team_id?: string | null;
|
|
58
|
+
created_at: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ModelInfo {
|
|
61
|
+
model_name: string;
|
|
62
|
+
mode: string;
|
|
63
|
+
supports_function_calling?: boolean;
|
|
64
|
+
supports_vision?: boolean;
|
|
65
|
+
input_cost_per_token?: number;
|
|
66
|
+
output_cost_per_token?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface UsageModelBreakdown {
|
|
69
|
+
total_spend: number;
|
|
70
|
+
total_tokens: number;
|
|
71
|
+
prompt_tokens: number;
|
|
72
|
+
completion_tokens: number;
|
|
73
|
+
api_requests: number;
|
|
74
|
+
successful_requests: number;
|
|
75
|
+
failed_requests: number;
|
|
76
|
+
}
|
|
77
|
+
export interface UsageKeyBreakdown {
|
|
78
|
+
key_alias?: string;
|
|
79
|
+
team_id?: string | null;
|
|
80
|
+
models: string[];
|
|
81
|
+
total_spend: number;
|
|
82
|
+
total_tokens: number;
|
|
83
|
+
prompt_tokens: number;
|
|
84
|
+
completion_tokens: number;
|
|
85
|
+
api_requests: number;
|
|
86
|
+
successful_requests: number;
|
|
87
|
+
failed_requests: number;
|
|
88
|
+
}
|
|
89
|
+
export interface UsageDailyPoint {
|
|
90
|
+
date: string;
|
|
91
|
+
spend: number;
|
|
92
|
+
total_tokens: number;
|
|
93
|
+
prompt_tokens: number;
|
|
94
|
+
completion_tokens: number;
|
|
95
|
+
api_requests: number;
|
|
96
|
+
successful_requests: number;
|
|
97
|
+
failed_requests: number;
|
|
98
|
+
}
|
|
99
|
+
export interface UsageDailyModelPoint {
|
|
100
|
+
date: string;
|
|
101
|
+
model: string;
|
|
102
|
+
spend: number;
|
|
103
|
+
prompt_tokens: number;
|
|
104
|
+
completion_tokens: number;
|
|
105
|
+
total_tokens: number;
|
|
106
|
+
api_requests: number;
|
|
107
|
+
successful_requests: number;
|
|
108
|
+
failed_requests: number;
|
|
109
|
+
}
|
|
110
|
+
export interface UsageMetrics {
|
|
111
|
+
total_spend: number;
|
|
112
|
+
total_tokens: number;
|
|
113
|
+
prompt_tokens: number;
|
|
114
|
+
completion_tokens: number;
|
|
115
|
+
api_requests: number;
|
|
116
|
+
successful_requests: number;
|
|
117
|
+
failed_requests: number;
|
|
118
|
+
usage_by_model: Record<string, UsageModelBreakdown>;
|
|
119
|
+
usage_by_key: Record<string, UsageKeyBreakdown>;
|
|
120
|
+
daily_usage: UsageDailyPoint[];
|
|
121
|
+
daily_by_model: UsageDailyModelPoint[];
|
|
122
|
+
}
|
|
123
|
+
export interface GenerateKeyRequest {
|
|
124
|
+
alias?: string;
|
|
125
|
+
models?: string[];
|
|
126
|
+
duration?: string;
|
|
127
|
+
max_budget?: number;
|
|
128
|
+
tpm_limit?: number;
|
|
129
|
+
rpm_limit?: number;
|
|
130
|
+
user_id?: string;
|
|
131
|
+
team_id?: string;
|
|
132
|
+
key_type?: string;
|
|
133
|
+
metadata?: Record<string, string>;
|
|
134
|
+
}
|
|
135
|
+
export interface UpdateKeyRequest {
|
|
136
|
+
key: string;
|
|
137
|
+
key_alias?: string;
|
|
138
|
+
models?: string[];
|
|
139
|
+
max_budget?: number;
|
|
140
|
+
tpm_limit?: number;
|
|
141
|
+
rpm_limit?: number;
|
|
142
|
+
team_id?: string;
|
|
143
|
+
duration?: string;
|
|
144
|
+
}
|
|
145
|
+
export interface GenerateKeyResponse {
|
|
146
|
+
key: string;
|
|
147
|
+
key_alias?: string;
|
|
148
|
+
expires_at?: string;
|
|
149
|
+
max_budget?: number;
|
|
150
|
+
tpm_limit?: number;
|
|
151
|
+
rpm_limit?: number;
|
|
152
|
+
models?: string[];
|
|
153
|
+
}
|
|
154
|
+
export interface DeleteKeyRequest {
|
|
155
|
+
keys: string[];
|
|
156
|
+
}
|
|
157
|
+
export interface LiteLLMConfig {
|
|
158
|
+
baseUrl: string;
|
|
159
|
+
masterKey: string;
|
|
160
|
+
}
|
|
161
|
+
export interface ProvisioningDefaults {
|
|
162
|
+
maxBudget: number;
|
|
163
|
+
budgetDuration: string;
|
|
164
|
+
models: string[];
|
|
165
|
+
teams: string[];
|
|
166
|
+
tpmLimit?: number;
|
|
167
|
+
rpmLimit?: number;
|
|
168
|
+
/**
|
|
169
|
+
* LiteLLM user role applied on /user/new. Defaults to "internal_user"
|
|
170
|
+
* which grants self-service Create/Delete/View on the user's own keys.
|
|
171
|
+
* Valid values: proxy_admin, proxy_admin_viewer, internal_user,
|
|
172
|
+
* internal_user_viewer, team.
|
|
173
|
+
*/
|
|
174
|
+
userRole?: string;
|
|
175
|
+
metadata: Record<string, string>;
|
|
176
|
+
}
|
|
177
|
+
export interface RoleConfig {
|
|
178
|
+
group: string;
|
|
179
|
+
maxBudget?: number;
|
|
180
|
+
budgetDuration?: string;
|
|
181
|
+
models?: string[];
|
|
182
|
+
teams?: string[];
|
|
183
|
+
tpmLimit?: number;
|
|
184
|
+
rpmLimit?: number;
|
|
185
|
+
userRole?: string;
|
|
186
|
+
metadata?: Record<string, string>;
|
|
187
|
+
}
|
|
188
|
+
export interface CreateUserRequest {
|
|
189
|
+
user_id: string;
|
|
190
|
+
user_email?: string;
|
|
191
|
+
user_alias?: string;
|
|
192
|
+
user_role?: string;
|
|
193
|
+
max_budget?: number;
|
|
194
|
+
budget_duration?: string;
|
|
195
|
+
models?: string[];
|
|
196
|
+
teams?: string[];
|
|
197
|
+
tpm_limit?: number;
|
|
198
|
+
rpm_limit?: number;
|
|
199
|
+
metadata?: Record<string, string>;
|
|
200
|
+
auto_create_key?: boolean;
|
|
201
|
+
}
|
|
202
|
+
export interface CreateUserResponse {
|
|
203
|
+
user_id: string;
|
|
204
|
+
user_email?: string;
|
|
205
|
+
max_budget?: number;
|
|
206
|
+
models?: string[];
|
|
207
|
+
teams?: string[];
|
|
208
|
+
}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acarmisc/backstage-plugin-litellm-backend",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The Backstage backend plugin for LiteLLM governance",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin",
|
|
@@ -23,20 +23,20 @@
|
|
|
23
23
|
"config.d.ts"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "
|
|
27
|
-
"prepack": "
|
|
26
|
+
"build": "node build.js && tsc -p tsconfig.json",
|
|
27
|
+
"prepack": "npm run build",
|
|
28
28
|
"postpack": ""
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@backstage/backend-plugin-api": "^1.
|
|
32
|
-
"@backstage/catalog-client": "^1.
|
|
33
|
-
"@backstage/catalog-model": "^1.
|
|
34
|
-
"@backstage/config": "^1.
|
|
35
|
-
"@backstage/types": "^1.
|
|
31
|
+
"@backstage/backend-plugin-api": "^1.9.1",
|
|
32
|
+
"@backstage/catalog-client": "^1.9.0",
|
|
33
|
+
"@backstage/catalog-model": "^1.7.0",
|
|
34
|
+
"@backstage/config": "^1.3.0",
|
|
35
|
+
"@backstage/types": "^1.2.0",
|
|
36
36
|
"express": "^4.18.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@backstage/cli": "^0.
|
|
39
|
+
"@backstage/cli": "^0.36.2",
|
|
40
40
|
"@types/express": "^4.17.25",
|
|
41
41
|
"esbuild": "^0.28.0",
|
|
42
42
|
"typescript": "^5.9.3"
|