@acarmisc/backstage-plugin-litellm-backend 0.6.2 → 0.8.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 +21 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.js +31 -4
- package/dist/index.cjs.js +42 -8
- package/dist/index.cjs.js.map +3 -3
- package/dist/openapi.js +6 -2
- package/dist/router.js +16 -1
- package/package.json +1 -1
package/dist/openapi.js
CHANGED
|
@@ -56,12 +56,16 @@ exports.openApiSpec = {
|
|
|
56
56
|
'/config': {
|
|
57
57
|
get: {
|
|
58
58
|
tags: ['System'],
|
|
59
|
-
summary: 'Public LiteLLM proxy base URL
|
|
59
|
+
summary: 'Public LiteLLM proxy base URL and key-generation form settings',
|
|
60
60
|
responses: {
|
|
61
61
|
'200': {
|
|
62
|
-
description: '
|
|
62
|
+
description: 'Frontend config',
|
|
63
63
|
content: { 'application/json': { schema: { type: 'object', properties: {
|
|
64
64
|
baseUrl: { type: 'string' },
|
|
65
|
+
keyGeneration: { type: 'object', properties: {
|
|
66
|
+
allowUnlimitedBudget: { type: 'boolean' },
|
|
67
|
+
teamRequired: { type: 'boolean' },
|
|
68
|
+
} },
|
|
65
69
|
} } } },
|
|
66
70
|
},
|
|
67
71
|
},
|
package/dist/router.js
CHANGED
|
@@ -55,6 +55,8 @@ async function createRouter(options) {
|
|
|
55
55
|
const { enabled: provisioningEnabled, defaults: provisioningDefaults } = (0, provisioning_1.readProvisioningDefaults)(config);
|
|
56
56
|
const roleConfigs = (0, provisioning_1.readRoleConfigs)(config);
|
|
57
57
|
const auditGroup = config.getOptionalString('litellm.audit.group');
|
|
58
|
+
const allowUnlimitedBudget = config.getOptionalBoolean('litellm.keyGeneration.allowUnlimitedBudget') ?? false;
|
|
59
|
+
const teamRequired = config.getOptionalBoolean('litellm.keyGeneration.teamRequired') ?? true;
|
|
58
60
|
const catalogClient = new catalog_client_1.CatalogClient({ discoveryApi: discovery });
|
|
59
61
|
if (provisioningEnabled) {
|
|
60
62
|
logger.info(`LiteLLM auto-provisioning enabled — defaults: budget=$${provisioningDefaults.maxBudget}/${provisioningDefaults.budgetDuration}, models=${provisioningDefaults.models.length
|
|
@@ -72,7 +74,10 @@ async function createRouter(options) {
|
|
|
72
74
|
// Exposes the public LiteLLM proxy URL so the frontend can build
|
|
73
75
|
// ready-to-paste curl / OpenAI-SDK snippets for freshly generated keys.
|
|
74
76
|
router.get('/config', (_req, res) => {
|
|
75
|
-
res.json({
|
|
77
|
+
res.json({
|
|
78
|
+
baseUrl: publicBaseUrl,
|
|
79
|
+
keyGeneration: { allowUnlimitedBudget, teamRequired },
|
|
80
|
+
});
|
|
76
81
|
});
|
|
77
82
|
// Self-hosted OpenAPI 3.1 contract — lets integrators read a spec instead
|
|
78
83
|
// of router.ts. No swagger-ui dependency; serve the JSON and point external
|
|
@@ -282,6 +287,16 @@ async function createRouter(options) {
|
|
|
282
287
|
});
|
|
283
288
|
return;
|
|
284
289
|
}
|
|
290
|
+
// Preserve upstream LiteLLM status + structured error (e.g. a 400 with
|
|
291
|
+
// param "key_alias" for a duplicate alias) so the frontend can
|
|
292
|
+
// distinguish "alias taken" from a genuine server error.
|
|
293
|
+
if (error instanceof client_1.LiteLLMUpstreamError) {
|
|
294
|
+
res.status(error.status).json({
|
|
295
|
+
error: error.message,
|
|
296
|
+
...(error.param ? { param: error.param } : {}),
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
285
300
|
logger.error('Failed to generate key', error);
|
|
286
301
|
res.status(500).json({ error: error.message });
|
|
287
302
|
}
|