@acarmisc/backstage-plugin-litellm-backend 0.19.0 → 0.21.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/config.d.ts CHANGED
@@ -171,6 +171,16 @@ export interface Config {
171
171
  */
172
172
  allowedDurations?: string[];
173
173
 
174
+ /**
175
+ * Allowed `budget_duration` values for new keys (how often a key's
176
+ * spend resets, e.g. "30d" or "1mo"). Requests with a value not in this
177
+ * list are rejected with a 400 error. An empty array allows any value
178
+ * matching /^\d+(s|m|h|d|mo)$/. Omitting the field keeps today's
179
+ * behaviour: the key's budget never resets.
180
+ * @default ["1d", "7d", "30d", "1mo"]
181
+ */
182
+ allowedBudgetDurations?: string[];
183
+
174
184
  /**
175
185
  * When true, key owners can reset their key's spend counter via the
176
186
  * "Reset Spend" button in the frontend, subject to the
@@ -206,6 +216,12 @@ export interface Config {
206
216
  */
207
217
  maxBudget?: number;
208
218
 
219
+ /**
220
+ * Reset period of maxBudget in LiteLLM format (e.g. "30d"). Unset, maxBudget
221
+ * covers the whole life of the key.
222
+ */
223
+ budgetDuration?: string;
224
+
209
225
  /**
210
226
  * When true a team must be supplied and the user must belong to it.
211
227
  * @default false
@@ -397,6 +413,37 @@ export interface Config {
397
413
  hideTeamBudgetForManagers?: boolean;
398
414
  };
399
415
 
416
+ /**
417
+ * Team usage views beyond the team totals shown to every member.
418
+ */
419
+ teamUsage?: {
420
+ /**
421
+ * Per-member usage breakdown (GET /teams/:teamId/usage/members and the
422
+ * "Usage by member" table on the Teams tab). Per-person spend is
423
+ * sensitive, so the breakdown is off by default and, when on, only
424
+ * reaches:
425
+ * - managers of the team (members of its metadata.owning_group, with
426
+ * team management enabled);
427
+ * - members of the team holding one of `viewerRoles` in it;
428
+ * - members of the team granted `litellm.team.usage.read` (only
429
+ * consulted when permission.enabled is true).
430
+ */
431
+ memberBreakdown?: {
432
+ /**
433
+ * When false, the route returns 404 and the UI hides the table.
434
+ * @default false
435
+ */
436
+ enabled?: boolean;
437
+
438
+ /**
439
+ * LiteLLM team roles (e.g. ["admin"]) whose holders may view their
440
+ * own team's breakdown.
441
+ * @default []
442
+ */
443
+ viewerRoles?: string[];
444
+ };
445
+ };
446
+
400
447
  bridge?: {
401
448
  /**
402
449
  * When true, mount the /bridge/keys, /bridge/keys (POST), /bridge/models
package/dist/client.d.ts CHANGED
@@ -60,6 +60,11 @@ export declare class LiteLLMClient {
60
60
  * `expires` instead of `expires_at`).
61
61
  */
62
62
  listKeys(userId?: string): Promise<VirtualKey[]>;
63
+ /**
64
+ * Lists every key bound to a team (any owner), following `/key/list`
65
+ * pagination. Stops after 50 pages of 100 keys.
66
+ */
67
+ listTeamKeys(teamId: string): Promise<VirtualKey[]>;
63
68
  private toVirtualKey;
64
69
  /**
65
70
  * Creates a new virtual key on the LiteLLM proxy.
package/dist/client.js CHANGED
@@ -198,6 +198,27 @@ class LiteLLMClient {
198
198
  throw err;
199
199
  }
200
200
  }
201
+ /**
202
+ * Lists every key bound to a team (any owner), following `/key/list`
203
+ * pagination. Stops after 50 pages of 100 keys.
204
+ */
205
+ async listTeamKeys(teamId) {
206
+ const keys = [];
207
+ for (let page = 1; page <= 50; page++) {
208
+ const params = new URLSearchParams({
209
+ team_id: teamId,
210
+ return_full_object: 'true',
211
+ page: String(page),
212
+ size: '100',
213
+ });
214
+ const response = await this.request(`/key/list?${params.toString()}`);
215
+ const rawKeys = (response.keys ?? []).filter((k) => typeof k === 'object' && k !== null);
216
+ keys.push(...rawKeys.map(this.toVirtualKey));
217
+ if (rawKeys.length === 0 || page >= (response.total_pages ?? 1))
218
+ break;
219
+ }
220
+ return keys;
221
+ }
201
222
  toVirtualKey(k) {
202
223
  return {
203
224
  key: k.key_name ?? k.token,