Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: add secret sync implementation

adilson9b97b415e422
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts
index 8ac3c19cfd..1e4b714dd7 100644
--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts
@@ -9,6 +9,7 @@ import { registerDatadogApplicationKeySecretRotationRouter } from "./datadog-app
import { registerDbtServiceTokenRotationRouter } from "./dbt-service-token-rotation-router";
import { registerHpIloRotationRouter } from "./hp-ilo-rotation-router";
import { registerLdapPasswordRotationRouter } from "./ldap-password-rotation-router";
+import { registerLiteLLMApiKeyRotationRouter } from "./litellm-api-key-rotation-router";
import { registerMongoDBCredentialsRotationRouter } from "./mongodb-credentials-rotation-router";
import { registerMsSqlCredentialsRotationRouter } from "./mssql-credentials-rotation-router";
import { registerMySqlCredentialsRotationRouter } from "./mysql-credentials-rotation-router";
@@ -44,6 +45,7 @@ export const SECRET_ROTATION_REGISTER_ROUTER_MAP: Record<
[SecretRotation.DbtServiceToken]: registerDbtServiceTokenRotationRouter,
[SecretRotation.WindowsLocalAccount]: registerWindowsLocalAccountRotationRouter,
[SecretRotation.OpenRouterApiKey]: registerOpenRouterApiKeyRotationRouter,
+ [SecretRotation.LiteLLMApiKey]: registerLiteLLMApiKeyRotationRouter,
[SecretRotation.HpIloLocalAccount]: registerHpIloRotationRouter,
[SecretRotation.SupabaseApiKey]: registerSupabaseApiKeyRotationRouter,
[SecretRotation.SalesforceOauthCredentials]: registerSalesforceOauthCredentialsRotationRouter,
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/litellm-api-key-rotation-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/litellm-api-key-rotation-router.ts
new file mode 100644
index 0000000000..6244cddaab
--- /dev/null
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/litellm-api-key-rotation-router.ts
@@ -0,0 +1,19 @@
+import {
+ CreateLiteLLMApiKeyRotationSchema,
+ LiteLLMApiKeyRotationGeneratedCredentialsSchema,
+ LiteLLMApiKeyRotationSchema,
+ UpdateLiteLLMApiKeyRotationSchema
+} from "@app/ee/services/secret-rotation-v2/litellm-api-key";
+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+
+import { registerSecretRotationEndpoints } from "./secret-rotation-v2-endpoints";
+
+export const registerLiteLLMApiKeyRotationRouter = async (server: FastifyZodProvider) =>
+ registerSecretRotationEndpoints({
+ type: SecretRotation.LiteLLMApiKey,
+ server,
+ responseSchema: LiteLLMApiKeyRotationSchema,
+ createSchema: CreateLiteLLMApiKeyRotationSchema,
+ updateSchema: UpdateLiteLLMApiKeyRotationSchema,
+ generatedCredentialsSchema: LiteLLMApiKeyRotationGeneratedCredentialsSchema
+ });
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts
index 17a41bafe5..641478d4ea 100644
--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts
@@ -10,6 +10,7 @@ import { DatadogApplicationKeySecretRotationListItemSchema } from "@app/ee/servi
import { DbtServiceTokenRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/dbt-service-token";
import { HpIloRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/hp-ilo-rotation";
import { LdapPasswordRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/ldap-password";
+import { LiteLLMApiKeyRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/litellm-api-key";
import { MongoDBCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mongodb-credentials";
import { MsSqlCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mssql-credentials";
import { MySqlCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mysql-credentials";
@@ -45,6 +46,7 @@ const SecretRotationV2OptionsSchema = z.discriminatedUnion("type", [
DbtServiceTokenRotationListItemSchema,
WindowsLocalAccountRotationListItemSchema,
OpenRouterApiKeyRotationListItemSchema,
+ LiteLLMApiKeyRotationListItemSchema,
HpIloRotationListItemSchema,
SupabaseApiKeyRotationListItemSchema,
SalesforceOauthCredentialsRotationListItemSchema,
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/index.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/index.ts
new file mode 100644
index 0000000000..e82c873b5a
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/index.ts
@@ -0,0 +1,3 @@
+export * from "./litellm-api-key-rotation-constants";
+export * from "./litellm-api-key-rotation-schemas";
+export * from "./litellm-api-key-rotation-types";
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts
new file mode 100644
index 0000000000..5df0eb728e
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts
@@ -0,0 +1,36 @@
+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+import { TSecretRotationV2ListItem } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+/**
+ * Key-generation options that cannot be set via the additional options JSON, either because
+ * Infisical owns them for the rotation lifecycle or because they have dedicated form fields:
+ * - key_alias is generated per key (embeds creation time + guarantees uniqueness)
+ * - auto_rotate / rotation_interval would conflict with Infisical's create/delete rotation
+ * - duration would expire the key out from under Infisical
+ * - send_invite_email is irrelevant for machine-managed keys
+ * - key_type is intentionally left to the LiteLLM instance default
+ * - user_id / team_id / models have dedicated parameter fields
+ */
+export const LITELLM_RESERVED_KEY_OPTIONS = [
+ "key_alias",
+ "auto_rotate",
+ "rotation_interval",
+ "duration",
+ "send_invite_email",
+ "key_type",
+ "user_id",
+ "team_id",
+ "models"
+];
+
+export const LITELLM_API_KEY_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {
+ name: "LiteLLM API Key",
+ type: SecretRotation.LiteLLMApiKey,
+ connection: AppConnection.LiteLLM,
+ template: {
+ secretsMapping: {
+ apiKey: "LITELLM_API_KEY"
+ }
+ }
+};
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts
new file mode 100644
index 0000000000..dcd795fedf
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts
@@ -0,0 +1,206 @@
+import { AxiosError } from "axios";
+
+import {
+ TRotationFactory,
+ TRotationFactoryCheckActiveCredentials,
+ TRotationFactoryGetSecretsPayload,
+ TRotationFactoryIssueCredentials,
+ TRotationFactoryRevokeCredentials,
+ TRotationFactoryRotateCredentials
+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
+import { request } from "@app/lib/config/request";
+import { BadRequestError } from "@app/lib/errors";
+import { removeTrailingSlash } from "@app/lib/fn/string";
+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
+
+import {
+ TLiteLLMApiKeyGenerateResponse,
+ TLiteLLMApiKeyRotationGeneratedCredentials,
+ TLiteLLMApiKeyRotationWithConnection
+} from "./litellm-api-key-rotation-types";
+
+type LiteLLMErrorResponse = { error?: { message?: string }; detail?: unknown };
+
+const isLiteLLMErrorResponse = (data: unknown): data is LiteLLMErrorResponse => {
+ return typeof data === "object" && data !== null && ("error" in data || "detail" in data);
+};
+
+const createErrorMessage = (error: unknown) => {
+ if (error instanceof AxiosError) {
+ if (error.response?.data && isLiteLLMErrorResponse(error.response.data)) {
+ const litellmError = error.response.data;
+ if (litellmError.error?.message) {
+ return litellmError.error.message;
+ }
+ if (litellmError.detail) {
+ return typeof litellmError.detail === "string" ? litellmError.detail : JSON.stringify(litellmError.detail);
+ }
+ }
+ if (error.message) {
+ return error.message;
+ }
+ }
+ return "Unknown error";
+};
+
+export const litellmApiKeyRotationFactory: TRotationFactory<
+ TLiteLLMApiKeyRotationWithConnection,
+ TLiteLLMApiKeyRotationGeneratedCredentials
+> = (secretRotation) => {
+ const {
+ connection,
+ parameters: { name, userId, teamId, models, additionalOptions },
+ secretsMapping
+ } = secretRotation;
+
+ const provisioningApiKey = connection.credentials.apiKey;
+ const baseUrl = removeTrailingSlash(connection.credentials.instanceUrl);
+
+ /**
+ * Creates a new virtual key via the LiteLLM key-management API.
+ */
+ const $createApiKey = async () => {
+ // Guard the user-supplied instance host against SSRF, matching the connection validator.
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ try {
+ const userOptions: Record<string, unknown> = additionalOptions
+ ? (JSON.parse(additionalOptions) as Record<string, unknown>)
+ : {};
+
+ // Infisical-owned fields always win over user-supplied options. The timestamp suffix embeds the
+ // creation time and guarantees uniqueness across rotations (create-before-revoke).
+ const requestBody: Record<string, unknown> = {
+ ...userOptions,
+ ...(userId ? { user_id: userId } : {}),
+ ...(teamId ? { team_id: teamId } : {}),
+ ...(models?.length ? { models } : {}),
+ key_alias: `${name}-${Date.now()}`,
+ auto_rotate: false,
+ send_invite_email: false
+ };
+
+ const { data } = await request.post<TLiteLLMApiKeyGenerateResponse>(`${baseUrl}/key/generate`, requestBody, {
+ headers: {
+ Authorization: `Bearer ${provisioningApiKey}`,
+ "Content-Type": "application/json"
+ }
+ });
+
+ return {
+ apiKey: data.key
+ };
+ } catch (error: unknown) {
+ throw new BadRequestError({
+ message: `Failed to create LiteLLM API key: ${createErrorMessage(error)}`
+ });
+ }
+ };
+
+ /**
+ * Deletes a virtual key via the LiteLLM key-management API. LiteLLM deletes by the key value.
+ */
+ const $deleteApiKey = async (apiKey: string) => {
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ try {
+ await request.post(
+ `${baseUrl}/key/delete`,
+ { keys: [apiKey] },
+ {
+ headers: {
+ Authorization: `Bearer ${provisioningApiKey}`,
+ "Content-Type": "application/json"
+ }
+ }
+ );
+ } catch (error: unknown) {
+ // If the key no longer exists, consider it already deleted
+ if (error instanceof AxiosError && (error.response?.status === 404 || error.response?.status === 400)) {
+ return;
+ }
+
+ throw new BadRequestError({
+ message: `Failed to delete LiteLLM API key: ${createErrorMessage(error)}`
+ });
+ }
+ };
+
+ /**
+ * Issues a new set of credentials.
+ */
+ const issueCredentials: TRotationFactoryIssueCredentials<TLiteLLMApiKeyRotationGeneratedCredentials> = async (
+ callback
+ ) => {
+ const credentials = await $createApiKey();
+ return callback(credentials);
+ };
+
+ /**
+ * Revokes a list of credentials.
+ */
+ const revokeCredentials: TRotationFactoryRevokeCredentials<TLiteLLMApiKeyRotationGeneratedCredentials> = async (
+ credentials,
+ callback
+ ) => {
+ if (!credentials?.length) return callback();
+
+ await Promise.all(credentials.map(({ apiKey }) => $deleteApiKey(apiKey)));
+
+ return callback();
+ };
+
+ /**
+ * Rotates credentials by issuing new ones and revoking the old.
+ */
+ const rotateCredentials: TRotationFactoryRotateCredentials<TLiteLLMApiKeyRotationGeneratedCredentials> = async (
+ oldCredentials,
+ callback
+ ) => {
+ // First create the new credentials
+ const newCredentials = await $createApiKey();
+
+ // Store the new credentials via callback
+ const result = await callback(newCredentials);
+
+ // Then delete the old key if it exists
+ if (oldCredentials?.apiKey) {
+ await $deleteApiKey(oldCredentials.apiKey);
+ }
+
+ return result;
+ };
+
+ /**
+ * Maps the generated credentials into the secret payload format.
+ */
+ const getSecretsPayload: TRotationFactoryGetSecretsPayload<TLiteLLMApiKeyRotationGeneratedCredentials> = ({
+ apiKey
+ }) => [{ key: secretsMapping.apiKey, value: apiKey }];
+
+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<
+ TLiteLLMApiKeyRotationGeneratedCredentials
+ > = async ({ apiKey }) => {
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ try {
+ // Verify the rotated key exists using the management key.
+ await request.get(`${baseUrl}/key/info`, {
+ params: { key: apiKey },
+ headers: { Authorization: `Bearer ${provisioningApiKey}` }
+ });
+ } catch (error: unknown) {
+ throw new BadRequestError({
+ message: `LiteLLM API key verification failed: ${createErrorMessage(error)}`
+ });
+ }
+ };
+
+ return {
+ issueCredentials,
+ revokeCredentials,
+ rotateCredentials,
+ getSecretsPayload,
+ checkActiveCredentials
+ };
+};
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts
new file mode 100644
index 0000000000..55c8d04443
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts
@@ -0,0 +1,98 @@
+import { z } from "zod";
+
+import { LITELLM_RESERVED_KEY_OPTIONS } from "@app/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants";
+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+import {
+ BaseCreateSecretRotationSchema,
+ BaseSecretRotationSchema,
+ BaseUpdateSecretRotationSchema
+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-schemas";
+import { SecretRotations } from "@app/lib/api-docs";
+import { SecretNameSchema } from "@app/server/lib/schemas";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+export const LiteLLMApiKeyRotationGeneratedCredentialsSchema = z
+ .object({
+ apiKey: z.string()
+ })
+ .array()
+ .min(1)
+ .max(2);
+
+/** Max length for the user-provided key name. Infisical appends a timestamp, so this is a sanity cap. */
+export const LITELLM_API_KEY_NAME_MAX_LENGTH = 100;
+
+const AdditionalOptionsSchema = z
+ .string()
+ .trim()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+
+ let parsed: unknown;
+ try {
+ parsed = JSON.parse(val);
+ } catch {
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Additional options must be valid JSON." });
+ return;
+ }
+
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Additional options must be a JSON object." });
+ return;
+ }
+
+ const reservedKeys = Object.keys(parsed).filter((key) => LITELLM_RESERVED_KEY_OPTIONS.includes(key));
+ if (reservedKeys.length) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `The following options are managed by Infisical and cannot be set: ${reservedKeys.join(", ")}.`
+ });
+ }
+ });
+
+const LiteLLMApiKeyRotationParametersSchema = z.object({
+ name: z
+ .string()
+ .trim()
+ .min(1, "Key name required")
+ .max(LITELLM_API_KEY_NAME_MAX_LENGTH, `Key name must be ${LITELLM_API_KEY_NAME_MAX_LENGTH} characters or fewer`)
+ .describe(SecretRotations.PARAMETERS.LITELLM_API_KEY.name),
+ additionalOptions: AdditionalOptionsSchema.describe(SecretRotations.PARAMETERS.LITELLM_API_KEY.additionalOptions),
+ userId: z.string().trim().optional().describe(SecretRotations.PARAMETERS.LITELLM_API_KEY.userId),
+ teamId: z.string().trim().optional().describe(SecretRotations.PARAMETERS.LITELLM_API_KEY.teamId),
+ models: z.string().trim().array().optional().describe(SecretRotations.PARAMETERS.LITELLM_API_KEY.models)
+});
+
+const LiteLLMApiKeyRotationSecretsMappingSchema = z.object({
+ apiKey: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.LITELLM_API_KEY.apiKey)
+});
+
+export const LiteLLMApiKeyRotationTemplateSchema = z.object({
+ secretsMapping: z.object({
+ apiKey: z.string()
+ })
+});
+
+export const LiteLLMApiKeyRotationSchema = BaseSecretRotationSchema(SecretRotation.LiteLLMApiKey).extend({
+ type: z.literal(SecretRotation.LiteLLMApiKey),
+ parameters: LiteLLMApiKeyRotationParametersSchema,
+ secretsMapping: LiteLLMApiKeyRotationSecretsMappingSchema
+});
+
+export const CreateLiteLLMApiKeyRotationSchema = BaseCreateSecretRotationSchema(SecretRotation.LiteLLMApiKey).extend({
+ parameters: LiteLLMApiKeyRotationParametersSchema,
+ secretsMapping: LiteLLMApiKeyRotationSecretsMappingSchema
+});
+
+export const UpdateLiteLLMApiKeyRotationSchema = BaseUpdateSecretRotationSchema(SecretRotation.LiteLLMApiKey).extend({
+ parameters: LiteLLMApiKeyRotationParametersSchema.optional(),
+ secretsMapping: LiteLLMApiKeyRotationSecretsMappingSchema.optional()
+});
+
+export const LiteLLMApiKeyRotationListItemSchema = z.object({
+ name: z.literal("LiteLLM API Key"),
+ connection: z.literal(AppConnection.LiteLLM),
+ type: z.literal(SecretRotation.LiteLLMApiKey),
+ template: LiteLLMApiKeyRotationTemplateSchema
+});
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-types.ts
new file mode 100644
index 0000000000..0af61ddc8d
--- /dev/null
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-types.ts
@@ -0,0 +1,28 @@
+import { z } from "zod";
+
+import { TLiteLLMConnection } from "@app/services/app-connection/litellm";
+
+import {
+ CreateLiteLLMApiKeyRotationSchema,
+ LiteLLMApiKeyRotationGeneratedCredentialsSchema,
+ LiteLLMApiKeyRotationListItemSchema,
+ LiteLLMApiKeyRotationSchema
+} from "./litellm-api-key-rotation-schemas";
+
+export type TLiteLLMApiKeyRotation = z.infer<typeof LiteLLMApiKeyRotationSchema>;
+
+export type TLiteLLMApiKeyRotationInput = z.infer<typeof CreateLiteLLMApiKeyRotationSchema>;
+
+export type TLiteLLMApiKeyRotationListItem = z.infer<typeof LiteLLMApiKeyRotationListItemSchema>;
+
+export type TLiteLLMApiKeyRotationWithConnection = TLiteLLMApiKeyRotation & {
+ connection: TLiteLLMConnection;
+};
+
+export type TLiteLLMApiKeyRotationGeneratedCredentials = z.infer<
+ typeof LiteLLMApiKeyRotationGeneratedCredentialsSchema
+>;
+
+export interface TLiteLLMApiKeyGenerateResponse {
+ key: string;
+}
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts
index cc89c95193..fcd98d2bd9 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts
@@ -15,6 +15,7 @@ export enum SecretRotation {
DbtServiceToken = "dbt-service-token",
WindowsLocalAccount = "windows-local-account",
OpenRouterApiKey = "open-router-api-key",
+ LiteLLMApiKey = "litellm-api-key",
HpIloLocalAccount = "hp-ilo-local-account",
SupabaseApiKey = "supabase-api-key",
SalesforceOauthCredentials = "salesforce-oauth-credentials",
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
index 6f8345ff81..bc935e723b 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
@@ -18,6 +18,7 @@ import {
import { DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION } from "./dbt-service-token";
import { HP_ILO_ROTATION_LIST_OPTION, THpIloRotation } from "./hp-ilo-rotation";
import { LDAP_PASSWORD_ROTATION_LIST_OPTION, TLdapPasswordRotation } from "./ldap-password";
+import { LITELLM_API_KEY_ROTATION_LIST_OPTION } from "./litellm-api-key";
import { MONGODB_CREDENTIALS_ROTATION_LIST_OPTION } from "./mongodb-credentials";
import { MSSQL_CREDENTIALS_ROTATION_LIST_OPTION } from "./mssql-credentials";
import { MYSQL_CREDENTIALS_ROTATION_LIST_OPTION } from "./mysql-credentials";
@@ -65,6 +66,7 @@ const SECRET_ROTATION_LIST_OPTIONS: Record<SecretRotation, TSecretRotationV2List
[SecretRotation.DbtServiceToken]: DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION,
[SecretRotation.WindowsLocalAccount]: WINDOWS_LOCAL_ACCOUNT_ROTATION_LIST_OPTION,
[SecretRotation.OpenRouterApiKey]: OPEN_ROUTER_API_KEY_ROTATION_LIST_OPTION,
+ [SecretRotation.LiteLLMApiKey]: LITELLM_API_KEY_ROTATION_LIST_OPTION,
[SecretRotation.HpIloLocalAccount]: HP_ILO_ROTATION_LIST_OPTION,
[SecretRotation.SupabaseApiKey]: SUPABASE_API_KEY_ROTATION_LIST_OPTION,
[SecretRotation.SalesforceOauthCredentials]: SALESFORCE_OAUTH_CREDENTIALS_ROTATION_LIST_OPTION,
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts
index ccc913fc69..c6692af19c 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts
@@ -18,6 +18,7 @@ export const SECRET_ROTATION_NAME_MAP: Record<SecretRotation, string> = {
[SecretRotation.DbtServiceToken]: "DBT Service Token",
[SecretRotation.WindowsLocalAccount]: "Windows Local Account",
[SecretRotation.OpenRouterApiKey]: "OpenRouter API Key",
+ [SecretRotation.LiteLLMApiKey]: "LiteLLM API Key",
[SecretRotation.HpIloLocalAccount]: "HP iLO Local Account",
[SecretRotation.SupabaseApiKey]: "Supabase API Key",
[SecretRotation.SalesforceOauthCredentials]: "Salesforce OAuth Credentials",
@@ -42,6 +43,7 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
[SecretRotation.DbtServiceToken]: AppConnection.Dbt,
[SecretRotation.WindowsLocalAccount]: AppConnection.SMB,
[SecretRotation.OpenRouterApiKey]: AppConnection.OpenRouter,
+ [SecretRotation.LiteLLMApiKey]: AppConnection.LiteLLM,
[SecretRotation.HpIloLocalAccount]: AppConnection.SSH,
[SecretRotation.SupabaseApiKey]: AppConnection.Supabase,
[SecretRotation.SalesforceOauthCredentials]: AppConnection.Salesforce,
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
index 2f900d8cb0..ed7c55f58d 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
@@ -104,6 +104,7 @@ import { dbtServiceTokenRotationFactory } from "./dbt-service-token/dbt-service-
import { hpIloRotationFactory } from "./hp-ilo-rotation/hp-ilo-rotation-fns";
import { HpIloRotationMethod } from "./hp-ilo-rotation/hp-ilo-rotation-schemas";
import { THpIloRotation, THpIloRotationGeneratedCredentials } from "./hp-ilo-rotation/hp-ilo-rotation-types";
+import { litellmApiKeyRotationFactory } from "./litellm-api-key/litellm-api-key-rotation-fns";
import { mongodbCredentialsRotationFactory } from "./mongodb-credentials/mongodb-credentials-rotation-fns";
import { oktaClientSecretRotationFactory } from "./okta-client-secret/okta-client-secret-rotation-fns";
import { openRouterApiKeyRotationFactory } from "./open-router-api-key/open-router-api-key-rotation-fns";
@@ -198,6 +199,7 @@ const SECRET_ROTATION_FACTORY_MAP: Record<SecretRotation, TRotationFactoryImplem
[SecretRotation.DbtServiceToken]: dbtServiceTokenRotationFactory as TRotationFactoryImplementation,
[SecretRotation.WindowsLocalAccount]: windowsLocalAccountRotationFactory as TRotationFactoryImplementation,
[SecretRotation.OpenRouterApiKey]: openRouterApiKeyRotationFactory as TRotationFactoryImplementation,
+ [SecretRotation.LiteLLMApiKey]: litellmApiKeyRotationFactory as TRotationFactoryImplementation,
[SecretRotation.HpIloLocalAccount]: hpIloRotationFactory as TRotationFactoryImplementation,
[SecretRotation.SupabaseApiKey]: supabaseApiKeyRotationFactory as TRotationFactoryImplementation,
[SecretRotation.SalesforceOauthCredentials]:
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
index 2b7da37159..0d8fd5789a 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
@@ -72,6 +72,13 @@ import {
TLdapPasswordRotationListItem,
TLdapPasswordRotationWithConnection
} from "./ldap-password";
+import {
+ TLiteLLMApiKeyRotation,
+ TLiteLLMApiKeyRotationGeneratedCredentials,
+ TLiteLLMApiKeyRotationInput,
+ TLiteLLMApiKeyRotationListItem,
+ TLiteLLMApiKeyRotationWithConnection
+} from "./litellm-api-key";
import {
TMongoDBCredentialsRotation,
TMongoDBCredentialsRotationInput,
@@ -171,6 +178,7 @@ export type TSecretRotationV2 =
| TDbtServiceTokenRotation
| TWindowsLocalAccountRotation
| TOpenRouterApiKeyRotation
+ | TLiteLLMApiKeyRotation
| THpIloRotation
| TSupabaseApiKeyRotation
| TSalesforceOauthCredentialsRotation
@@ -194,6 +202,7 @@ export type TSecretRotationV2WithConnection =
| TDbtServiceTokenRotationWithConnection
| TWindowsLocalAccountRotationWithConnection
| TOpenRouterApiKeyRotationWithConnection
+ | TLiteLLMApiKeyRotationWithConnection
| THpIloRotationWithConnection
| TSupabaseApiKeyRotationWithConnection
| TSalesforceOauthCredentialsRotationWithConnection
@@ -213,6 +222,7 @@ export type TSecretRotationV2GeneratedCredentials =
| TDbtServiceTokenRotationGeneratedCredentials
| TWindowsLocalAccountRotationGeneratedCredentials
| TOpenRouterApiKeyRotationGeneratedCredentials
+ | TLiteLLMApiKeyRotationGeneratedCredentials
| THpIloRotationGeneratedCredentials
| TSupabaseApiKeyRotationGeneratedCredentials
| TSalesforceOauthCredentialsRotationGeneratedCredentials
@@ -236,6 +246,7 @@ export type TSecretRotationV2Input =
| TDbtServiceTokenRotationInput
| TWindowsLocalAccountRotationInput
| TOpenRouterApiKeyRotationInput
+ | TLiteLLMApiKeyRotationInput
| THpIloRotationInput
| TSupabaseApiKeyRotationInput
| TSalesforceOauthCredentialsRotationInput
@@ -259,6 +270,7 @@ export type TSecretRotationV2ListItem =
| TDbtServiceTokenRotationListItem
| TWindowsLocalAccountRotationListItem
| TOpenRouterApiKeyRotationListItem
+ | TLiteLLMApiKeyRotationListItem
| THpIloRotationListItem
| TSupabaseApiKeyRotationListItem
| TSalesforceOauthCredentialsRotationListItem
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts
index d1cfa6cfc2..56f955cb9a 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts
@@ -6,6 +6,7 @@ import { AzureClientSecretRotationSchema } from "@app/ee/services/secret-rotatio
import { DatabricksServicePrincipalSecretRotationSchema } from "@app/ee/services/secret-rotation-v2/databricks-service-principal-secret";
import { DatadogApplicationKeySecretRotationSchema } from "@app/ee/services/secret-rotation-v2/datadog-application-key-secret";
import { LdapPasswordRotationSchema } from "@app/ee/services/secret-rotation-v2/ldap-password";
+import { LiteLLMApiKeyRotationSchema } from "@app/ee/services/secret-rotation-v2/litellm-api-key";
import { MongoDBCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/mongodb-credentials";
import { MsSqlCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/mssql-credentials";
import { MySqlCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/mysql-credentials";
@@ -40,6 +41,7 @@ export const SecretRotationV2Schema = z.discriminatedUnion("type", [
DbtServiceTokenRotationSchema,
WindowsLocalAccountRotationSchema,
OpenRouterApiKeyRotationSchema,
+ LiteLLMApiKeyRotationSchema,
HpIloRotationSchema,
SupabaseApiKeyRotationSchema,
SalesforceOauthCredentialsRotationSchema,
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index bf32a2de3f..e1a29b61ab 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -3471,6 +3471,14 @@ export const SecretRotations = {
includeByokInLimit:
"Whether to include BYOK (Bring Your Own Key) usage in the spending limit. When enabled, usage from your own provider keys counts toward this key's limit. See OpenRouter BYOK docs for details."
},
+ LITELLM_API_KEY: {
+ name: "The name for the generated LiteLLM API key. Infisical appends a timestamp to keep each rotated key unique and record its creation time.",
+ userId: "The ID of the LiteLLM user to associate the generated key with.",
+ teamId: "The ID of the LiteLLM team to associate the generated key with.",
+ models: "The list of model names the generated key is allowed to access. An empty list allows all models.",
+ additionalOptions:
+ "A JSON object of additional LiteLLM /key/generate options (e.g. max_budget, tpm_limit, metadata). Reserved fields (key_alias, auto_rotate, rotation_interval, duration, send_invite_email, key_type, user_id, team_id, models) are managed by Infisical or set via dedicated fields and cannot be set here."
+ },
SUPABASE_API_KEY: {
projectRef: "The reference ID of the Supabase project to rotate the API key for.",
keyType: "The type of the API key to rotate (e.g. publishable, secret)."
@@ -3545,6 +3553,9 @@ export const SecretRotations = {
OPEN_ROUTER_API_KEY: {
apiKey: "The name of the secret that the rotated OpenRouter API key will be mapped to."
},
+ LITELLM_API_KEY: {
+ apiKey: "The name of the secret that the rotated LiteLLM API key will be mapped to."
+ },
SUPABASE_API_KEY: {
apiKey: "The name of the secret that the rotated Supabase API key will be mapped to."
},
diff --git a/backend/src/server/routes/v1/app-connection-routers/litellm-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/litellm-connection-router.ts
index 27eecfdba5..26e086ddad 100644
--- a/backend/src/server/routes/v1/app-connection-routers/litellm-connection-router.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/litellm-connection-router.ts
@@ -1,12 +1,19 @@
+import { z } from "zod";
+
+import { readLimit } from "@app/server/config/rateLimiter";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import {
CreateLiteLLMConnectionSchema,
SanitizedLiteLLMConnectionSchema,
UpdateLiteLLMConnectionSchema
} from "@app/services/app-connection/litellm";
+import { AuthMode } from "@app/services/auth/auth-type";
import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
+const LiteLLMListItemSchema = z.object({ id: z.string(), name: z.string() });
+
export const registerLiteLLMConnectionRouter = async (server: FastifyZodProvider) => {
registerAppConnectionEndpoints({
app: AppConnection.LiteLLM,
@@ -15,4 +22,94 @@ export const registerLiteLLMConnectionRouter = async (server: FastifyZodProvider
createSchema: CreateLiteLLMConnectionSchema,
updateSchema: UpdateLiteLLMConnectionSchema
});
+
+ // The below endpoints are not exposed and for Infisical App use
+
+ server.route({
+ method: "GET",
+ url: "/:connectionId/users",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ operationId: "listLiteLLMUsers",
+ params: z.object({
+ connectionId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ users: LiteLLMListItemSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const {
+ params: { connectionId }
+ } = req;
+
+ const users = await server.services.appConnection.litellm.listUsers(connectionId, req.permission);
+ return { users };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:connectionId/teams",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ operationId: "listLiteLLMTeams",
+ params: z.object({
+ connectionId: z.string().uuid()
+ }),
+ querystring: z.object({
+ userId: z.string().trim().optional()
+ }),
+ response: {
+ 200: z.object({
+ teams: LiteLLMListItemSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const {
+ params: { connectionId },
+ query: { userId }
+ } = req;
+
+ const teams = await server.services.appConnection.litellm.listTeams(connectionId, req.permission, userId);
+ return { teams };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:connectionId/models",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ operationId: "listLiteLLMModels",
+ params: z.object({
+ connectionId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ models: LiteLLMListItemSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const {
+ params: { connectionId }
+ } = req;
+
+ const models = await server.services.appConnection.litellm.listModels(connectionId, req.permission);
+ return { models };
+ }
+ });
};
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 1c8ec52dc1..d452a29610 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -133,6 +133,7 @@ import { ValidateLaravelForgeConnectionCredentialsSchema } from "./laravel-forge
import { laravelForgeConnectionService } from "./laravel-forge/laravel-forge-connection-service";
import { ValidateLdapConnectionCredentialsSchema } from "./ldap";
import { ValidateLiteLLMConnectionCredentialsSchema } from "./litellm";
+import { liteLLMConnectionService } from "./litellm/litellm-connection-service";
import { ValidateMongoDBConnectionCredentialsSchema } from "./mongodb";
import { ValidateMsSqlConnectionCredentialsSchema } from "./mssql";
import { ValidateMySqlConnectionCredentialsSchema } from "./mysql";
@@ -1382,6 +1383,7 @@ export const appConnectionServiceFactory = ({
doppler: dopplerConnectionService(connectAppConnectionById),
digicert: digicertConnectionService(connectAppConnectionById),
travisCI: travisCIConnectionService(connectAppConnectionById),
- snowflake: snowflakeConnectionService(connectAppConnectionById)
+ snowflake: snowflakeConnectionService(connectAppConnectionById),
+ litellm: liteLLMConnectionService(connectAppConnectionById)
};
};
diff --git a/backend/src/services/app-connection/litellm/litellm-connection-fns.ts b/backend/src/services/app-connection/litellm/litellm-connection-fns.ts
index 7ec807f8f9..64a6d9d618 100644
--- a/backend/src/services/app-connection/litellm/litellm-connection-fns.ts
+++ b/backend/src/services/app-connection/litellm/litellm-connection-fns.ts
@@ -6,7 +6,7 @@ import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { LiteLLMConnectionMethod } from "./litellm-connection-enums";
-import { TLiteLLMConnectionConfig } from "./litellm-connection-types";
+import { TLiteLLMConnection, TLiteLLMConnectionConfig } from "./litellm-connection-types";
export const getLiteLLMConnectionListItem = () => {
return {
@@ -43,3 +43,69 @@ export const validateLiteLLMConnectionCredentials = async (config: TLiteLLMConne
return config.credentials;
};
+
+type TLiteLLMListItem = { id: string; name: string };
+
+const getLiteLLMBaseUrl = (connection: TLiteLLMConnection) => removeTrailingSlash(connection.credentials.instanceUrl);
+
+const getLiteLLMErrorMessage = (error: unknown) => (error instanceof Error ? error.message : "Unknown error");
+
+export const listLiteLLMUsers = async (connection: TLiteLLMConnection): Promise<TLiteLLMListItem[]> => {
+ const baseUrl = getLiteLLMBaseUrl(connection);
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ try {
+ const { data } = await request.get<{
+ users?: { user_id: string; user_email?: string | null; user_alias?: string | null }[];
+ }>(`${baseUrl}/user/list`, {
+ params: { page_size: 100 },
+ headers: { Authorization: `Bearer ${connection.credentials.apiKey}` }
+ });
+
+ return (data.users ?? []).map((user) => ({
+ id: user.user_id,
+ name: user.user_email || user.user_alias || user.user_id
+ }));
+ } catch (error: unknown) {
+ throw new BadRequestError({ message: `Failed to list LiteLLM users: ${getLiteLLMErrorMessage(error)}` });
+ }
+};
+
+export const listLiteLLMTeams = async (
+ connection: TLiteLLMConnection,
+ userId?: string
+): Promise<TLiteLLMListItem[]> => {
+ const baseUrl = getLiteLLMBaseUrl(connection);
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ try {
+ const { data } = await request.get<{
+ teams?: { team_id: string; team_alias?: string | null }[];
+ }>(`${baseUrl}/v2/team/list`, {
+ params: { user_id: userId, page_size: 100 },
+ headers: { Authorization: `Bearer ${connection.credentials.apiKey}` }
+ });
+
+ return (data.teams ?? []).map((team) => ({
+ id: team.team_id,
+ name: team.team_alias || team.team_id
+ }));
+ } catch (error: unknown) {
+ throw new BadRequestError({ message: `Failed to list LiteLLM teams: ${getLiteLLMErrorMessage(error)}` });
+ }
+};
+
+export const listLiteLLMModels = async (connection: TLiteLLMConnection): Promise<TLiteLLMListItem[]> => {
+ const baseUrl = getLiteLLMBaseUrl(connection);
+ await blockLocalAndPrivateIpAddresses(baseUrl);
+
+ try {
+ const { data } = await request.get<{ data?: { id: string }[] }>(`${baseUrl}/models`, {
+ headers: { Authorization: `Bearer ${connection.credentials.apiKey}` }
+ });
+
+ return (data.data ?? []).map((model) => ({ id: model.id, name: model.id }));
+ } catch (error: unknown) {
+ throw new BadRequestError({ message: `Failed to list LiteLLM models: ${getLiteLLMErrorMessage(error)}` });
+ }
+};
diff --git a/backend/src/services/app-connection/litellm/litellm-connection-service.ts b/backend/src/services/app-connection/litellm/litellm-connection-service.ts
new file mode 100644
index 0000000000..03c59b009e
--- /dev/null
+++ b/backend/src/services/app-connection/litellm/litellm-connection-service.ts
@@ -0,0 +1,34 @@
+import { OrgServiceActor } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+import { listLiteLLMModels, listLiteLLMTeams, listLiteLLMUsers } from "./litellm-connection-fns";
+import { TLiteLLMConnection } from "./litellm-connection-types";
+
+type TGetAppConnectionFunc = (
+ app: AppConnection,
+ connectionId: string,
+ actor: OrgServiceActor
+) => Promise<TLiteLLMConnection>;
+
+export const liteLLMConnectionService = (getAppConnection: TGetAppConnectionFunc) => {
+ const listUsers = async (connectionId: string, actor: OrgServiceActor) => {
+ const appConnection = await getAppConnection(AppConnection.LiteLLM, connectionId, actor);
+ return listLiteLLMUsers(appConnection);
+ };
+
+ const listTeams = async (connectionId: string, actor: OrgServiceActor, userId?: string) => {
+ const appConnection = await getAppConnection(AppConnection.LiteLLM, connectionId, actor);
+ return listLiteLLMTeams(appConnection, userId);
+ };
+
+ const listModels = async (connectionId: string, actor: OrgServiceActor) => {
+ const appConnection = await getAppConnection(AppConnection.LiteLLM, connectionId, actor);
+ return listLiteLLMModels(appConnection);
+ };
+
+ return {
+ listUsers,
+ listTeams,
+ listModels
+ };
+};
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewLiteLLMApiKeyRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewLiteLLMApiKeyRotationGeneratedCredentials.tsx
new file mode 100644
index 0000000000..2ce8fc2078
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewLiteLLMApiKeyRotationGeneratedCredentials.tsx
@@ -0,0 +1,32 @@
+import { CredentialDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/CredentialDisplay";
+import { TLiteLLMApiKeyRotationGeneratedCredentialsResponse } from "@app/hooks/api/secretRotationsV2/types/litellm-api-key-rotation";
+
+import { ViewRotationGeneratedCredentialsDisplay } from "./shared";
+
+type Props = {
+ generatedCredentialsResponse: TLiteLLMApiKeyRotationGeneratedCredentialsResponse;
+};
+
+export const ViewLiteLLMApiKeyRotationGeneratedCredentials = ({
+ generatedCredentialsResponse: { generatedCredentials, activeIndex }
+}: Props) => {
+ const inactiveIndex = activeIndex === 0 ? 1 : 0;
+
+ const activeCredentials = generatedCredentials[activeIndex];
+ const inactiveCredentials = generatedCredentials[inactiveIndex];
+
+ return (
+ <ViewRotationGeneratedCredentialsDisplay
+ activeCredentials={
+ <CredentialDisplay isSensitive label="API Key">
+ {activeCredentials?.apiKey}
+ </CredentialDisplay>
+ }
+ inactiveCredentials={
+ <CredentialDisplay isSensitive label="API Key">
+ {inactiveCredentials?.apiKey}
+ </CredentialDisplay>
+ }
+ />
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
index 0ecd35e9fe..6c63d653dd 100644
--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
@@ -27,6 +27,7 @@ import { ViewAwsIamUserSecretRotationGeneratedCredentials } from "./ViewAwsIamUs
import { ViewDatadogApplicationKeySecretRotationGeneratedCredentials } from "./ViewDatadogApplicationKeySecretRotationGeneratedCredentials";
import { ViewDbtServiceTokenRotationGeneratedCredentials } from "./ViewDbtSeviceTokenRotationGeneratedCredentials";
import { ViewHpIloRotationGeneratedCredentials } from "./ViewHpIloRotationGeneratedCredentials";
+import { ViewLiteLLMApiKeyRotationGeneratedCredentials } from "./ViewLiteLLMApiKeyRotationGeneratedCredentials";
import { ViewOktaClientSecretRotationGeneratedCredentials } from "./ViewOktaClientSecretRotationGeneratedCredentials";
import { ViewOpenRouterApiKeyRotationGeneratedCredentials } from "./ViewOpenRouterApiKeyRotationGeneratedCredentials";
import { ViewRedisCredentialsRotationGeneratedCredentials } from "./ViewRedisCredentialsRotationGeneratedCredentials";
@@ -161,6 +162,13 @@ const Content = ({ secretRotation }: ContentProps) => {
/>
);
break;
+ case SecretRotation.LiteLLMApiKey:
+ Component = (
+ <ViewLiteLLMApiKeyRotationGeneratedCredentials
+ generatedCredentialsResponse={generatedCredentialsResponse}
+ />
+ );
+ break;
case SecretRotation.HpIloLocalAccount:
Component = (
<ViewHpIloRotationGeneratedCredentials
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LiteLLMApiKeyRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LiteLLMApiKeyRotationParametersFields.tsx
new file mode 100644
index 0000000000..58e7dbc7c3
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LiteLLMApiKeyRotationParametersFields.tsx
@@ -0,0 +1,206 @@
+import { Controller, useFormContext } from "react-hook-form";
+import { MultiValue, SingleValue } from "react-select";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import {
+ FilterableSelect,
+ FormControl,
+ Input,
+ Tab,
+ TabList,
+ TabPanel,
+ Tabs,
+ TextArea
+} from "@app/components/v2";
+import {
+ useListLiteLLMConnectionModels,
+ useListLiteLLMConnectionTeams,
+ useListLiteLLMConnectionUsers
+} from "@app/hooks/api/appConnections/litellm";
+import {
+ TLiteLLMModel,
+ TLiteLLMTeam,
+ TLiteLLMUser
+} from "@app/hooks/api/appConnections/litellm/types";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+/** Max length for the key name (matches backend schema). */
+const LITELLM_API_KEY_NAME_MAX_LENGTH = 100;
+
+/** Starter set of common LiteLLM key options; users can edit or clear these. Must be valid JSON. */
+const DEFAULT_LITELLM_OPTIONS = `{
+ "max_budget": null,
+ "tpm_limit": null,
+ "rpm_limit": null,
+ "metadata": {}
+}`;
+
+enum ParameterTab {
+ General = "general",
+ Advanced = "advanced"
+}
+
+export const LiteLLMApiKeyRotationParametersFields = () => {
+ const { control, watch, setValue } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.LiteLLMApiKey;
+ }
+ >();
+
+ const connectionId = watch("connection.id");
+ const userId = watch("parameters.userId");
+
+ const { data: users, isPending: isUsersPending } = useListLiteLLMConnectionUsers(connectionId, {
+ enabled: Boolean(connectionId)
+ });
+
+ const { data: teams, isPending: isTeamsPending } = useListLiteLLMConnectionTeams(
+ connectionId,
+ userId,
+ {
+ enabled: Boolean(connectionId && userId)
+ }
+ );
+
+ const { data: models, isPending: isModelsPending } = useListLiteLLMConnectionModels(
+ connectionId,
+ {
+ enabled: Boolean(connectionId)
+ }
+ );
+
+ return (
+ <Tabs defaultValue={ParameterTab.General}>
+ <TabList className="border-b border-mineshaft-500">
+ <Tab value={ParameterTab.General}>General</Tab>
+ <Tab value={ParameterTab.Advanced}>Advanced</Tab>
+ </TabList>
+ <TabPanel value={ParameterTab.General}>
+ <Controller
+ name="parameters.name"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Key Name"
+ tooltipText="A descriptive name for the generated key. Infisical appends a timestamp so each rotated key stays unique and records its creation time."
+ >
+ <Input
+ value={value}
+ onChange={onChange}
+ placeholder="my-rotated-key"
+ maxLength={LITELLM_API_KEY_NAME_MAX_LENGTH}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="parameters.userId"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isOptional
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="User"
+ tooltipText="Associate the generated key with a LiteLLM user."
+ >
+ <FilterableSelect
+ isClearable
+ isLoading={isUsersPending && Boolean(connectionId)}
+ isDisabled={!connectionId}
+ value={users?.find((user) => user.id === value) ?? null}
+ onChange={(option) => {
+ onChange((option as SingleValue<TLiteLLMUser>)?.id);
+ // Teams are scoped to the selected user, so reset the team when the user changes.
+ setValue("parameters.teamId", undefined);
+ }}
+ options={users}
+ placeholder="Select a user..."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.id}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="parameters.teamId"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isOptional
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Team"
+ tooltipText="Associate the generated key with a team the selected user belongs to. Select a user first."
+ >
+ <FilterableSelect
+ isClearable
+ isLoading={isTeamsPending && Boolean(connectionId && userId)}
+ isDisabled={!connectionId || !userId}
+ value={teams?.find((team) => team.id === value) ?? null}
+ onChange={(option) => onChange((option as SingleValue<TLiteLLMTeam>)?.id)}
+ options={teams}
+ placeholder={userId ? "Select a team..." : "Select a user first"}
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.id}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="parameters.models"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isOptional
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Models"
+ tooltipText="Restrict the generated key to specific models. Leave empty to allow all models."
+ >
+ <FilterableSelect
+ isMulti
+ isLoading={isModelsPending && Boolean(connectionId)}
+ isDisabled={!connectionId}
+ value={models?.filter((model) => (value ?? []).includes(model.id)) ?? []}
+ onChange={(option) => {
+ onChange((option as MultiValue<TLiteLLMModel>).map((model) => model.id));
+ }}
+ options={models}
+ placeholder="Select models..."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.id}
+ />
+ </FormControl>
+ )}
+ />
+ </TabPanel>
+ <TabPanel value={ParameterTab.Advanced}>
+ <Controller
+ name="parameters.additionalOptions"
+ control={control}
+ defaultValue={DEFAULT_LITELLM_OPTIONS}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isOptional
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Additional Key Options (JSON)"
+ tooltipText="Common fields: max_budget (number), tpm_limit / rpm_limit (numbers), metadata (object). user_id, team_id and models are set via the fields above; key_alias, auto_rotate, rotation_interval, duration, send_invite_email and key_type are managed by Infisical and cannot be set here."
+ >
+ <TextArea
+ {...field}
+ reSize="none"
+ rows={10}
+ placeholder={DEFAULT_LITELLM_OPTIONS}
+ className="border-mineshaft-600 bg-mineshaft-900 font-mono text-sm"
+ />
+ </FormControl>
+ )}
+ />
+ </TabPanel>
+ </Tabs>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
index 7711fb3019..b98212c9a7 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
@@ -12,6 +12,7 @@ import { DatadogApplicationKeySecretRotationParametersFields } from "./DatadogAp
import { DbtServiceTokenRotationParametersFields } from "./DbtServiceTokenRotationParametersFields";
import { HpIloRotationParametersFields } from "./HpIloRotationParametersFields";
import { LdapPasswordRotationParametersFields } from "./LdapPasswordRotationParametersFields";
+import { LiteLLMApiKeyRotationParametersFields } from "./LiteLLMApiKeyRotationParametersFields";
import { MongoRotationParametersFields } from "./MongoRotationParametersFields";
import { OktaClientSecretRotationParametersFields } from "./OktaClientSecretRotationParametersFields";
import { OpenRouterApiKeyRotationParametersFields } from "./OpenRouterApiKeyRotationParametersFields";
@@ -40,6 +41,7 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.DbtServiceToken]: DbtServiceTokenRotationParametersFields,
[SecretRotation.WindowsLocalAccount]: WindowsLocalAccountRotationParametersFields,
[SecretRotation.OpenRouterApiKey]: OpenRouterApiKeyRotationParametersFields,
+ [SecretRotation.LiteLLMApiKey]: LiteLLMApiKeyRotationParametersFields,
[SecretRotation.HpIloLocalAccount]: HpIloRotationParametersFields,
[SecretRotation.SupabaseApiKey]: SupabaseApiKeyRotationParametersFields,
[SecretRotation.SalesforceOauthCredentials]: SalesforceOauthCredentialsRotationParametersFields,
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/LiteLLMApiKeyRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/LiteLLMApiKeyRotationReviewFields.tsx
new file mode 100644
index 0000000000..17ca18fb5b
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/LiteLLMApiKeyRotationReviewFields.tsx
@@ -0,0 +1,43 @@
+import { useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { GenericFieldLabel } from "@app/components/v2";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+import { SecretRotationReviewSection } from "./shared";
+
+export const LiteLLMApiKeyRotationReviewFields = () => {
+ const { watch } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.LiteLLMApiKey;
+ }
+ >();
+
+ const [{ name, userId, teamId, models, additionalOptions }, { apiKey }] = watch([
+ "parameters",
+ "secretsMapping"
+ ]);
+
+ return (
+ <>
+ <SecretRotationReviewSection label="Parameters">
+ <GenericFieldLabel label="Key Name">{name}</GenericFieldLabel>
+ {userId && <GenericFieldLabel label="User">{userId}</GenericFieldLabel>}
+ {teamId && <GenericFieldLabel label="Team">{teamId}</GenericFieldLabel>}
+ {models && models.length > 0 && (
+ <GenericFieldLabel label="Models">{models.join(", ")}</GenericFieldLabel>
+ )}
+ <GenericFieldLabel label="Additional Options" className="w-full">
+ {additionalOptions ? (
+ <span className="mt-1 block max-h-40 overflow-auto rounded-sm border border-mineshaft-600 bg-mineshaft-900 p-2 font-mono text-xs break-words whitespace-pre-wrap text-mineshaft-200">
+ {additionalOptions}
+ </span>
+ ) : undefined}
+ </GenericFieldLabel>
+ </SecretRotationReviewSection>
+ <SecretRotationReviewSection label="Secrets Mapping">
+ <GenericFieldLabel label="API Key">{apiKey}</GenericFieldLabel>
+ </SecretRotationReviewSection>
+ </>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
index 90b38931de..7445e5f17c 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
@@ -15,6 +15,7 @@ import { DatadogApplicationKeySecretRotationReviewFields } from "./DatadogApplic
import { DbtServiceTokenRotationReviewFields } from "./DbtServiceTokenRotationReviewFields";
import { HpIloRotationReviewFields } from "./HpIloRotationReviewFields";
import { LdapPasswordRotationReviewFields } from "./LdapPasswordRotationReviewFields";
+import { LiteLLMApiKeyRotationReviewFields } from "./LiteLLMApiKeyRotationReviewFields";
import { OktaClientSecretRotationReviewFields } from "./OktaClientSecretRotationReviewFields";
import { OpenRouterApiKeyRotationReviewFields } from "./OpenRouterApiKeyRotationReviewFields";
import { RedisCredentialsRotationReviewFields } from "./RedisCredentialsRotationReviewFields";
@@ -42,6 +43,7 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.DbtServiceToken]: DbtServiceTokenRotationReviewFields,
[SecretRotation.WindowsLocalAccount]: WindowsLocalAccountRotationReviewFields,
[SecretRotation.OpenRouterApiKey]: OpenRouterApiKeyRotationReviewFields,
+ [SecretRotation.LiteLLMApiKey]: LiteLLMApiKeyRotationReviewFields,
[SecretRotation.HpIloLocalAccount]: HpIloRotationReviewFields,
[SecretRotation.SupabaseApiKey]: SupabaseApiKeyRotationReviewFields,
[SecretRotation.SalesforceOauthCredentials]: SalesforceOauthCredentialsRotationReviewFields,
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/LiteLLMApiKeyRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/LiteLLMApiKeyRotationSecretsMappingFields.tsx
new file mode 100644
index 0000000000..fcacb73d66
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/LiteLLMApiKeyRotationSecretsMappingFields.tsx
@@ -0,0 +1,40 @@
+import { Controller, useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { FormControl, Input } from "@app/components/v2";
+import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";
+
+import { SecretsMappingTable } from "./shared";
+
+export const LiteLLMApiKeyRotationSecretsMappingFields = () => {
+ const { control } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.LiteLLMApiKey;
+ }
+ >();
+
+ const { rotationOption } = useSecretRotationV2Option(SecretRotation.LiteLLMApiKey);
+
+ const items = [
+ {
+ name: "API Key",
+ input: (
+ <Controller
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input
+ value={value}
+ onChange={onChange}
+ placeholder={rotationOption?.template.secretsMapping.apiKey}
+ />
+ </FormControl>
+ )}
+ control={control}
+ name="secretsMapping.apiKey"
+ />
+ )
+ }
+ ];
+
+ return <SecretsMappingTable items={items} />;
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
index 3dc2f925e1..3a0ec726ec 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
@@ -12,6 +12,7 @@ import { DatadogApplicationKeySecretRotationSecretsMappingFields } from "./Datad
import { DbtServiceTokenRotationSecretsMappingFields } from "./DbtServiceTokenRotationSecretsMappingFields";
import { HpIloRotationSecretsMappingFields } from "./HpIloRotationSecretsMappingFields";
import { LdapPasswordRotationSecretsMappingFields } from "./LdapPasswordRotationSecretsMappingFields";
+import { LiteLLMApiKeyRotationSecretsMappingFields } from "./LiteLLMApiKeyRotationSecretsMappingFields";
import { OktaClientSecretRotationSecretsMappingFields } from "./OktaClientSecretRotationSecretsMappingFields";
import { OpenRouterApiKeyRotationSecretsMappingFields } from "./OpenRouterApiKeyRotationSecretsMappingFields";
import { RedisCredentialsRotationSecretsMappingFields } from "./RedisCredentialsRotationSecretsMappingFields";
@@ -39,6 +40,7 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.DbtServiceToken]: DbtServiceTokenRotationSecretsMappingFields,
[SecretRotation.WindowsLocalAccount]: WindowsLocalAccountRotationSecretsMappingFields,
[SecretRotation.OpenRouterApiKey]: OpenRouterApiKeyRotationSecretsMappingFields,
+ [SecretRotation.LiteLLMApiKey]: LiteLLMApiKeyRotationSecretsMappingFields,
[SecretRotation.HpIloLocalAccount]: HpIloRotationSecretsMappingFields,
[SecretRotation.SupabaseApiKey]: SupabaseApiKeyRotationSecretsMappingFields,
[SecretRotation.SalesforceOauthCredentials]:
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
index 499d876872..5eb8d13e34 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
@@ -19,6 +19,7 @@ import { ConvexAccessKeyRotationSchema } from "./convex-access-key-rotation-sche
import { DatadogApplicationKeySecretRotationSchema } from "./datadog-application-key-secret-rotation-schema";
import { DbtServiceTokenRotationSchema } from "./dbt-service-token-rotation-schema";
import { HpIloRotationSchema } from "./hp-ilo-rotation-schema";
+import { LiteLLMApiKeyRotationSchema } from "./litellm-api-key-rotation-schema";
import { OktaClientSecretRotationSchema } from "./okta-client-secret-rotation-schema";
import { OpenRouterApiKeyRotationSchema } from "./open-router-api-key-rotation-schema";
import { OracleDBCredentialsRotationSchema } from "./oracledb-credentials-rotation-schema";
@@ -48,6 +49,7 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>
DbtServiceTokenRotationSchema,
WindowsLocalAccountRotationSchema,
OpenRouterApiKeyRotationSchema,
+ LiteLLMApiKeyRotationSchema,
HpIloRotationSchema,
SupabaseApiKeyRotationSchema,
SalesforceOauthCredentialsRotationSchema,
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts
new file mode 100644
index 0000000000..7cdba04a1c
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts
@@ -0,0 +1,78 @@
+import { z } from "zod";
+
+import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+
+/** Max length for the key name (matches backend schema). */
+const LITELLM_API_KEY_NAME_MAX_LENGTH = 100;
+
+/** Options owned by Infisical or set via dedicated fields; users cannot set these via the additional options JSON. */
+const LITELLM_RESERVED_KEY_OPTIONS = [
+ "key_alias",
+ "auto_rotate",
+ "rotation_interval",
+ "duration",
+ "send_invite_email",
+ "key_type",
+ "user_id",
+ "team_id",
+ "models"
+];
+
+export const LiteLLMApiKeyRotationSchema = z
+ .object({
+ type: z.literal(SecretRotation.LiteLLMApiKey),
+ parameters: z.object({
+ name: z
+ .string()
+ .trim()
+ .min(1, "Key name required")
+ .max(
+ LITELLM_API_KEY_NAME_MAX_LENGTH,
+ `Key name must be ${LITELLM_API_KEY_NAME_MAX_LENGTH} characters or fewer`
+ ),
+ additionalOptions: z
+ .string()
+ .trim()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+
+ let parsed: unknown;
+ try {
+ parsed = JSON.parse(val);
+ } catch {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "Additional options must be valid JSON."
+ });
+ return;
+ }
+
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "Additional options must be a JSON object."
+ });
+ return;
+ }
+
+ const reservedKeys = Object.keys(parsed).filter((key) =>
+ LITELLM_RESERVED_KEY_OPTIONS.includes(key)
+ );
+ if (reservedKeys.length) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `The following options are managed by Infisical and cannot be set: ${reservedKeys.join(", ")}.`
+ });
+ }
+ }),
+ userId: z.string().trim().optional(),
+ teamId: z.string().trim().optional(),
+ models: z.array(z.string().trim()).optional()
+ }),
+ secretsMapping: z.object({
+ apiKey: z.string().trim().min(1, "API Key secret name required")
+ })
+ })
+ .merge(BaseSecretRotationSchema);
diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.ts
index f768f4dc25..1e14ee8cf4 100644
--- a/frontend/src/helpers/secretRotationsV2.ts
+++ b/frontend/src/helpers/secretRotationsV2.ts
@@ -85,6 +85,11 @@ export const SECRET_ROTATION_MAP: Record<
image: "OpenRouter.png",
size: 50
},
+ [SecretRotation.LiteLLMApiKey]: {
+ name: "LiteLLM API Key",
+ image: "LiteLLM.png",
+ size: 50
+ },
[SecretRotation.HpIloLocalAccount]: {
name: "HP iLO Local Account",
image: "SSH.png",
@@ -129,6 +134,7 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
[SecretRotation.DbtServiceToken]: AppConnection.Dbt,
[SecretRotation.WindowsLocalAccount]: AppConnection.SMB,
[SecretRotation.OpenRouterApiKey]: AppConnection.OpenRouter,
+ [SecretRotation.LiteLLMApiKey]: AppConnection.LiteLLM,
[SecretRotation.HpIloLocalAccount]: AppConnection.SSH,
[SecretRotation.SupabaseApiKey]: AppConnection.Supabase,
[SecretRotation.SalesforceOauthCredentials]: AppConnection.Salesforce,
@@ -154,6 +160,7 @@ export const IS_ROTATION_DUAL_CREDENTIALS: Record<SecretRotation, boolean> = {
[SecretRotation.DbtServiceToken]: true,
[SecretRotation.WindowsLocalAccount]: false,
[SecretRotation.OpenRouterApiKey]: true,
+ [SecretRotation.LiteLLMApiKey]: true,
[SecretRotation.HpIloLocalAccount]: false,
[SecretRotation.SupabaseApiKey]: true,
[SecretRotation.SalesforceOauthCredentials]: true,
diff --git a/frontend/src/hooks/api/appConnections/litellm/index.ts b/frontend/src/hooks/api/appConnections/litellm/index.ts
new file mode 100644
index 0000000000..2c1906d369
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/litellm/index.ts
@@ -0,0 +1,2 @@
+export * from "./queries";
+export * from "./types";
diff --git a/frontend/src/hooks/api/appConnections/litellm/queries.tsx b/frontend/src/hooks/api/appConnections/litellm/queries.tsx
new file mode 100644
index 0000000000..c3ac73b7ad
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/litellm/queries.tsx
@@ -0,0 +1,93 @@
+import { useQuery, UseQueryOptions } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+import { appConnectionKeys } from "../queries";
+import { TLiteLLMModel, TLiteLLMTeam, TLiteLLMUser } from "./types";
+
+const litellmConnectionKeys = {
+ all: [...appConnectionKeys.all, "litellm"] as const,
+ listUsers: (connectionId: string) =>
+ [...litellmConnectionKeys.all, "users", connectionId] as const,
+ listTeams: (connectionId: string, userId?: string) =>
+ [...litellmConnectionKeys.all, "teams", connectionId, { userId }] as const,
+ listModels: (connectionId: string) =>
+ [...litellmConnectionKeys.all, "models", connectionId] as const
+};
+
+export const useListLiteLLMConnectionUsers = (
+ connectionId: string,
+ options?: Omit<
+ UseQueryOptions<
+ TLiteLLMUser[],
+ unknown,
+ TLiteLLMUser[],
+ ReturnType<typeof litellmConnectionKeys.listUsers>
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: litellmConnectionKeys.listUsers(connectionId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ users: TLiteLLMUser[] }>(
+ `/api/v1/app-connections/litellm/${connectionId}/users`
+ );
+
+ return data.users;
+ },
+ ...options
+ });
+};
+
+export const useListLiteLLMConnectionTeams = (
+ connectionId: string,
+ userId?: string,
+ options?: Omit<
+ UseQueryOptions<
+ TLiteLLMTeam[],
+ unknown,
+ TLiteLLMTeam[],
+ ReturnType<typeof litellmConnectionKeys.listTeams>
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: litellmConnectionKeys.listTeams(connectionId, userId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ teams: TLiteLLMTeam[] }>(
+ `/api/v1/app-connections/litellm/${connectionId}/teams`,
+ { params: { userId } }
+ );
+
+ return data.teams;
+ },
+ ...options
+ });
+};
+
+export const useListLiteLLMConnectionModels = (
+ connectionId: string,
+ options?: Omit<
+ UseQueryOptions<
+ TLiteLLMModel[],
+ unknown,
+ TLiteLLMModel[],
+ ReturnType<typeof litellmConnectionKeys.listModels>
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: litellmConnectionKeys.listModels(connectionId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ models: TLiteLLMModel[] }>(
+ `/api/v1/app-connections/litellm/${connectionId}/models`
+ );
+
+ return data.models;
+ },
+ ...options
+ });
+};
diff --git a/frontend/src/hooks/api/appConnections/litellm/types.ts b/frontend/src/hooks/api/appConnections/litellm/types.ts
new file mode 100644
index 0000000000..7495bea1d2
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/litellm/types.ts
@@ -0,0 +1,14 @@
+export type TLiteLLMUser = {
+ id: string;
+ name: string;
+};
+
+export type TLiteLLMTeam = {
+ id: string;
+ name: string;
+};
+
+export type TLiteLLMModel = {
+ id: string;
+ name: string;
+};
diff --git a/frontend/src/hooks/api/secretRotationsV2/enums.ts b/frontend/src/hooks/api/secretRotationsV2/enums.ts
index ce3c11c8e5..625e4a552d 100644
--- a/frontend/src/hooks/api/secretRotationsV2/enums.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/enums.ts
@@ -15,6 +15,7 @@ export enum SecretRotation {
DbtServiceToken = "dbt-service-token",
WindowsLocalAccount = "windows-local-account",
OpenRouterApiKey = "open-router-api-key",
+ LiteLLMApiKey = "litellm-api-key",
HpIloLocalAccount = "hp-ilo-local-account",
SupabaseApiKey = "supabase-api-key",
SalesforceOauthCredentials = "salesforce-oauth-credentials",
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
index 3f0370531f..9d83362f16 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
@@ -56,6 +56,11 @@ import {
THpIloRotationGeneratedCredentialsResponse,
THpIloRotationOption
} from "./hp-ilo-rotation";
+import {
+ TLiteLLMApiKeyRotation,
+ TLiteLLMApiKeyRotationGeneratedCredentialsResponse,
+ TLiteLLMApiKeyRotationOption
+} from "./litellm-api-key-rotation";
import {
TMongoDBCredentialsRotation,
TMongoDBCredentialsRotationGeneratedCredentialsResponse,
@@ -122,6 +127,7 @@ export type TSecretRotationV2 = (
| TDbtServiceTokenRotation
| TWindowsLocalAccountRotation
| TOpenRouterApiKeyRotation
+ | TLiteLLMApiKeyRotation
| THpIloRotation
| TSupabaseApiKeyRotation
| TSalesforceOauthCredentialsRotation
@@ -145,6 +151,7 @@ export type TSecretRotationV2Option =
| TDbtServiceTokenRotationOption
| TWindowsLocalAccountRotationOption
| TOpenRouterApiKeyRotationOption
+ | TLiteLLMApiKeyRotationOption
| THpIloRotationOption
| TSupabaseApiKeyRotationOption
| TSalesforceOauthCredentialsRotationOption
@@ -172,6 +179,7 @@ export type TViewSecretRotationGeneratedCredentialsResponse =
| TDbtServiceTokenRotationGeneratedCredentialsResponse
| TWindowsLocalAccountRotationGeneratedCredentialsResponse
| TOpenRouterApiKeyRotationGeneratedCredentialsResponse
+ | TLiteLLMApiKeyRotationGeneratedCredentialsResponse
| THpIloRotationGeneratedCredentialsResponse
| TSupabaseApiKeyRotationGeneratedCredentialsResponse
| TSalesforceOauthCredentialsRotationGeneratedCredentialsResponse
@@ -247,6 +255,7 @@ export type TSecretRotationOptionMap = {
[SecretRotation.DbtServiceToken]: TDbtServiceTokenRotationOption;
[SecretRotation.WindowsLocalAccount]: TWindowsLocalAccountRotationOption;
[SecretRotation.OpenRouterApiKey]: TOpenRouterApiKeyRotationOption;
+ [SecretRotation.LiteLLMApiKey]: TLiteLLMApiKeyRotationOption;
[SecretRotation.HpIloLocalAccount]: THpIloRotationOption;
[SecretRotation.SupabaseApiKey]: TSupabaseApiKeyRotationOption;
[SecretRotation.SalesforceOauthCredentials]: TSalesforceOauthCredentialsRotationOption;
@@ -271,6 +280,7 @@ export type TSecretRotationGeneratedCredentialsResponseMap = {
[SecretRotation.DbtServiceToken]: TDbtServiceTokenRotationGeneratedCredentialsResponse;
[SecretRotation.WindowsLocalAccount]: TWindowsLocalAccountRotationGeneratedCredentialsResponse;
[SecretRotation.OpenRouterApiKey]: TOpenRouterApiKeyRotationGeneratedCredentialsResponse;
+ [SecretRotation.LiteLLMApiKey]: TLiteLLMApiKeyRotationGeneratedCredentialsResponse;
[SecretRotation.HpIloLocalAccount]: THpIloRotationGeneratedCredentialsResponse;
[SecretRotation.SupabaseApiKey]: TSupabaseApiKeyRotationGeneratedCredentialsResponse;
[SecretRotation.SalesforceOauthCredentials]: TSalesforceOauthCredentialsRotationGeneratedCredentialsResponse;
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/litellm-api-key-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/litellm-api-key-rotation.ts
new file mode 100644
index 0000000000..a034f5b4a1
--- /dev/null
+++ b/frontend/src/hooks/api/secretRotationsV2/types/litellm-api-key-rotation.ts
@@ -0,0 +1,39 @@
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+import {
+ TSecretRotationV2Base,
+ TSecretRotationV2GeneratedCredentialsResponseBase
+} from "@app/hooks/api/secretRotationsV2/types/shared";
+
+export type TLiteLLMApiKeyRotation = TSecretRotationV2Base & {
+ type: SecretRotation.LiteLLMApiKey;
+ parameters: {
+ name: string;
+ additionalOptions?: string;
+ userId?: string;
+ teamId?: string;
+ models?: string[];
+ };
+ secretsMapping: {
+ apiKey: string;
+ };
+};
+
+export type TLiteLLMApiKeyRotationGeneratedCredentials = {
+ apiKey: string;
+};
+
+export type TLiteLLMApiKeyRotationGeneratedCredentialsResponse =
+ TSecretRotationV2GeneratedCredentialsResponseBase<
+ SecretRotation.LiteLLMApiKey,
+ TLiteLLMApiKeyRotationGeneratedCredentials
+ >;
+
+export type TLiteLLMApiKeyRotationOption = {
+ name: string;
+ type: SecretRotation.LiteLLMApiKey;
+ connection: AppConnection.LiteLLM;
+ template: {
+ secretsMapping: TLiteLLMApiKeyRotation["secretsMapping"];
+ };
+};