Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: adding secret rotation support for open router
IgorHorta9e8e1561ebae
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.tsindex f32a3d4b4c..0bed511bc3 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 { registerMongoDBCredentialsRotationRouter } from "./mongodb-credentials-import { registerMsSqlCredentialsRotationRouter } from "./mssql-credentials-rotation-router";import { registerMySqlCredentialsRotationRouter } from "./mysql-credentials-rotation-router";import { registerOktaClientSecretRotationRouter } from "./okta-client-secret-rotation-router";+import { registerOpenRouterApiKeyRotationRouter } from "./open-router-api-key-rotation-router";import { registerOracleDBCredentialsRotationRouter } from "./oracledb-credentials-rotation-router";import { registerPostgresCredentialsRotationRouter } from "./postgres-credentials-rotation-router";import { registerRedisCredentialsRotationRouter } from "./redis-credentials-rotation-router";@@ -32,5 +33,6 @@ export const SECRET_ROTATION_REGISTER_ROUTER_MAP: Record<[SecretRotation.RedisCredentials]: registerRedisCredentialsRotationRouter,[SecretRotation.MongoDBCredentials]: registerMongoDBCredentialsRotationRouter,[SecretRotation.DatabricksServicePrincipalSecret]: registerDatabricksServicePrincipalSecretRotationRouter,- [SecretRotation.UnixLinuxLocalAccount]: registerUnixLinuxLocalAccountRotationRouter+ [SecretRotation.UnixLinuxLocalAccount]: registerUnixLinuxLocalAccountRotationRouter,+ [SecretRotation.OpenRouterApiKey]: registerOpenRouterApiKeyRotationRouter};diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/open-router-api-key-rotation-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/open-router-api-key-rotation-router.tsnew file mode 100644index 0000000000..387e008f0e--- /dev/null+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/open-router-api-key-rotation-router.ts@@ -0,0 +1,19 @@+import {+ CreateOpenRouterApiKeyRotationSchema,+ OpenRouterApiKeyRotationGeneratedCredentialsSchema,+ OpenRouterApiKeyRotationSchema,+ UpdateOpenRouterApiKeyRotationSchema+} from "@app/ee/services/secret-rotation-v2/open-router-api-key";+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";++import { registerSecretRotationEndpoints } from "./secret-rotation-v2-endpoints";++export const registerOpenRouterApiKeyRotationRouter = async (server: FastifyZodProvider) =>+ registerSecretRotationEndpoints({+ type: SecretRotation.OpenRouterApiKey,+ server,+ responseSchema: OpenRouterApiKeyRotationSchema,+ createSchema: CreateOpenRouterApiKeyRotationSchema,+ updateSchema: UpdateOpenRouterApiKeyRotationSchema,+ generatedCredentialsSchema: OpenRouterApiKeyRotationGeneratedCredentialsSchema+ });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.tsindex 526e8c1451..97dd228ffc 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 { MongoDBCredentialsRotationListItemSchema } from "@app/ee/services/secreimport { MsSqlCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mssql-credentials";import { MySqlCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/mysql-credentials";import { OktaClientSecretRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/okta-client-secret";+import { OpenRouterApiKeyRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/open-router-api-key";import { OracleDBCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/oracledb-credentials";import { PostgresCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/postgres-credentials";import { RedisCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/redis-credentials";@@ -33,7 +34,8 @@ const SecretRotationV2OptionsSchema = z.discriminatedUnion("type", [RedisCredentialsRotationListItemSchema,MongoDBCredentialsRotationListItemSchema,DatabricksServicePrincipalSecretRotationListItemSchema,- UnixLinuxLocalAccountRotationListItemSchema+ UnixLinuxLocalAccountRotationListItemSchema,+ OpenRouterApiKeyRotationListItemSchema]);export const registerSecretRotationV2Router = async (server: FastifyZodProvider) => {diff --git a/backend/src/ee/services/secret-rotation-v2/open-router-api-key/index.ts b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/index.tsnew file mode 100644index 0000000000..e4afb37049--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/index.ts@@ -0,0 +1,3 @@+export * from "./open-router-api-key-rotation-constants";+export * from "./open-router-api-key-rotation-schemas";+export * from "./open-router-api-key-rotation-types";diff --git a/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-constants.tsnew file mode 100644index 0000000000..a3ee190066--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-constants.ts@@ -0,0 +1,14 @@+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";++export const OPEN_ROUTER_API_KEY_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {+ name: "OpenRouter API Key",+ type: SecretRotation.OpenRouterApiKey,+ connection: AppConnection.OpenRouter,+ template: {+ secretsMapping: {+ apiKey: "OPEN_ROUTER_API_KEY"+ }+ }+};diff --git a/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-fns.tsnew file mode 100644index 0000000000..c817ca9941--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-fns.ts@@ -0,0 +1,178 @@+import { AxiosError } from "axios";++import {+ TRotationFactory,+ 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 { OPEN_ROUTER_API_BASE_URL } from "@app/services/app-connection/open-router";++import {+ TOpenRouterApiKeyCreateResponse,+ TOpenRouterApiKeyRotationGeneratedCredentials,+ TOpenRouterApiKeyRotationWithConnection+} from "./open-router-api-key-rotation-types";++type OpenRouterErrorResponse = { error?: { message: string; code?: string } };++const isOpenRouterErrorResponse = (data: unknown): data is OpenRouterErrorResponse => {+ return typeof data === "object" && data !== null && "error" in data;+};++const createErrorMessage = (error: unknown) => {+ if (error instanceof AxiosError) {+ if (error.response?.data && isOpenRouterErrorResponse(error.response.data)) {+ const openRouterError = error.response.data;+ if (openRouterError.error?.message) {+ return openRouterError.error.message;+ }+ }+ if (error.message) {+ return error.message;+ }+ }+ return "Unknown error";+};++export const openRouterApiKeyRotationFactory: TRotationFactory<+ TOpenRouterApiKeyRotationWithConnection,+ TOpenRouterApiKeyRotationGeneratedCredentials+> = (secretRotation) => {+ const {+ connection,+ parameters: { name, limit, limitReset },+ secretsMapping+ } = secretRotation;++ const provisioningApiKey = connection.credentials.apiKey;++ /**+ * Creates a new API key via OpenRouter Provisioning API.+ */+ const $createApiKey = async () => {+ try {+ const requestBody: {+ name: string;+ limit?: number | null;+ limit_reset?: string | null;+ } = { name };++ if (limit !== undefined && limit !== null) {+ requestBody.limit = limit;+ }+ if (limitReset !== undefined && limitReset !== null) {+ requestBody.limit_reset = limitReset;+ }++ const { data } = await request.post<TOpenRouterApiKeyCreateResponse>(+ `${OPEN_ROUTER_API_BASE_URL}/keys`,+ requestBody,+ {+ headers: {+ Authorization: `Bearer ${provisioningApiKey}`,+ "Content-Type": "application/json"+ }+ }+ );++ if (!data.key || !data.data?.hash) {+ throw new Error("Invalid response from OpenRouter: missing 'key' or 'hash'.");+ }++ return {+ apiKey: data.key,+ keyHash: data.data.hash+ };+ } catch (error: unknown) {+ throw new BadRequestError({+ message: `Failed to create OpenRouter API key: ${createErrorMessage(error)}`+ });+ }+ };++ /**+ * Deletes an API key via OpenRouter Provisioning API.+ */+ const $deleteApiKey = async (keyHash: string) => {+ try {+ await request.delete(`${OPEN_ROUTER_API_BASE_URL}/keys/${keyHash}`, {+ headers: {+ Authorization: `Bearer ${provisioningApiKey}`,+ "Content-Type": "application/json"+ }+ });+ } catch (error: unknown) {+ // If key doesn't exist (404), consider it already deleted+ if (error instanceof AxiosError && error.response?.status === 404) {+ return;+ }++ throw new BadRequestError({+ message: `Failed to delete OpenRouter API key: ${createErrorMessage(error)}`+ });+ }+ };++ /**+ * Issues a new set of credentials.+ */+ const issueCredentials: TRotationFactoryIssueCredentials<TOpenRouterApiKeyRotationGeneratedCredentials> = async (+ callback+ ) => {+ const credentials = await $createApiKey();+ return callback(credentials);+ };++ /**+ * Revokes a list of credentials.+ */+ const revokeCredentials: TRotationFactoryRevokeCredentials<TOpenRouterApiKeyRotationGeneratedCredentials> = async (+ credentials,+ callback+ ) => {+ if (!credentials?.length) return callback();++ await Promise.all(credentials.map(({ keyHash }) => $deleteApiKey(keyHash)));++ return callback();+ };++ /**+ * Rotates credentials by issuing new ones and revoking the old.+ */+ const rotateCredentials: TRotationFactoryRotateCredentials<TOpenRouterApiKeyRotationGeneratedCredentials> = 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?.keyHash) {+ await $deleteApiKey(oldCredentials.keyHash);+ }++ return result;+ };++ /**+ * Maps the generated credentials into the secret payload format.+ */+ const getSecretsPayload: TRotationFactoryGetSecretsPayload<TOpenRouterApiKeyRotationGeneratedCredentials> = ({+ apiKey+ }) => [{ key: secretsMapping.apiKey, value: apiKey }];++ return {+ issueCredentials,+ revokeCredentials,+ rotateCredentials,+ getSecretsPayload+ };+};diff --git a/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-schemas.tsnew file mode 100644index 0000000000..cf779a4d1d--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-schemas.ts@@ -0,0 +1,73 @@+import { z } from "zod";++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 OpenRouterApiKeyRotationGeneratedCredentialsSchema = z+ .object({+ apiKey: z.string(),+ keyHash: z.string()+ })+ .array()+ .min(1)+ .max(2);++export enum OpenRouterLimitReset {+ Daily = "daily",+ Weekly = "weekly",+ Monthly = "monthly"+}++const OpenRouterApiKeyRotationParametersSchema = z.object({+ name: z.string().trim().min(1, "Key name required").describe(SecretRotations.PARAMETERS.OPEN_ROUTER_API_KEY.name),+ limit: z.number().positive().optional().nullable().describe(SecretRotations.PARAMETERS.OPEN_ROUTER_API_KEY.limit),+ limitReset: z+ .nativeEnum(OpenRouterLimitReset)+ .optional()+ .nullable()+ .describe(SecretRotations.PARAMETERS.OPEN_ROUTER_API_KEY.limitReset)+});++const OpenRouterApiKeyRotationSecretsMappingSchema = z.object({+ apiKey: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.OPEN_ROUTER_API_KEY.apiKey)+});++export const OpenRouterApiKeyRotationTemplateSchema = z.object({+ secretsMapping: z.object({+ apiKey: z.string()+ })+});++export const OpenRouterApiKeyRotationSchema = BaseSecretRotationSchema(SecretRotation.OpenRouterApiKey).extend({+ type: z.literal(SecretRotation.OpenRouterApiKey),+ parameters: OpenRouterApiKeyRotationParametersSchema,+ secretsMapping: OpenRouterApiKeyRotationSecretsMappingSchema+});++export const CreateOpenRouterApiKeyRotationSchema = BaseCreateSecretRotationSchema(+ SecretRotation.OpenRouterApiKey+).extend({+ parameters: OpenRouterApiKeyRotationParametersSchema,+ secretsMapping: OpenRouterApiKeyRotationSecretsMappingSchema+});++export const UpdateOpenRouterApiKeyRotationSchema = BaseUpdateSecretRotationSchema(+ SecretRotation.OpenRouterApiKey+).extend({+ parameters: OpenRouterApiKeyRotationParametersSchema.optional(),+ secretsMapping: OpenRouterApiKeyRotationSecretsMappingSchema.optional()+});++export const OpenRouterApiKeyRotationListItemSchema = z.object({+ name: z.literal("OpenRouter API Key"),+ connection: z.literal(AppConnection.OpenRouter),+ type: z.literal(SecretRotation.OpenRouterApiKey),+ template: OpenRouterApiKeyRotationTemplateSchema+});diff --git a/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-types.tsnew file mode 100644index 0000000000..bdf70c1226--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/open-router-api-key/open-router-api-key-rotation-types.ts@@ -0,0 +1,46 @@+import { z } from "zod";++import { TOpenRouterConnection } from "@app/services/app-connection/open-router";++import {+ CreateOpenRouterApiKeyRotationSchema,+ OpenRouterApiKeyRotationGeneratedCredentialsSchema,+ OpenRouterApiKeyRotationListItemSchema,+ OpenRouterApiKeyRotationSchema+} from "./open-router-api-key-rotation-schemas";++export type TOpenRouterApiKeyRotation = z.infer<typeof OpenRouterApiKeyRotationSchema>;++export type TOpenRouterApiKeyRotationInput = z.infer<typeof CreateOpenRouterApiKeyRotationSchema>;++export type TOpenRouterApiKeyRotationListItem = z.infer<typeof OpenRouterApiKeyRotationListItemSchema>;++export type TOpenRouterApiKeyRotationWithConnection = TOpenRouterApiKeyRotation & {+ connection: TOpenRouterConnection;+};++export type TOpenRouterApiKeyRotationGeneratedCredentials = z.infer<+ typeof OpenRouterApiKeyRotationGeneratedCredentialsSchema+>;++export interface TOpenRouterApiKeyRotationParameters {+ name: string;+ limit?: number | null;+ limitReset?: "daily" | "weekly" | "monthly" | null;+}++export interface TOpenRouterApiKeyRotationSecretsMapping {+ apiKey: string;+}++export interface TOpenRouterApiKeyCreateResponse {+ data: {+ hash: string;+ name: string;+ label: string;+ disabled: boolean;+ limit: number | null;+ created_at: string;+ };+ 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.tsindex f848876cf1..143882cfb3 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@@ -11,7 +11,8 @@ export enum SecretRotation {RedisCredentials = "redis-credentials",MongoDBCredentials = "mongodb-credentials",DatabricksServicePrincipalSecret = "databricks-service-principal-secret",- UnixLinuxLocalAccount = "unix-linux-local-account"+ UnixLinuxLocalAccount = "unix-linux-local-account",+ OpenRouterApiKey = "open-router-api-key"}export enum SecretRotationStatus {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.tsindex 4de49f6afe..1e82dea27e 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@@ -14,6 +14,7 @@ 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";import { OKTA_CLIENT_SECRET_ROTATION_LIST_OPTION } from "./okta-client-secret";+import { OPEN_ROUTER_API_KEY_ROTATION_LIST_OPTION } from "./open-router-api-key";import { ORACLEDB_CREDENTIALS_ROTATION_LIST_OPTION } from "./oracledb-credentials";import { POSTGRES_CREDENTIALS_ROTATION_LIST_OPTION } from "./postgres-credentials";import { REDIS_CREDENTIALS_ROTATION_LIST_OPTION } from "./redis-credentials";@@ -46,7 +47,8 @@ const SECRET_ROTATION_LIST_OPTIONS: Record<SecretRotation, TSecretRotationV2List[SecretRotation.RedisCredentials]: REDIS_CREDENTIALS_ROTATION_LIST_OPTION,[SecretRotation.MongoDBCredentials]: MONGODB_CREDENTIALS_ROTATION_LIST_OPTION,[SecretRotation.DatabricksServicePrincipalSecret]: DATABRICKS_SERVICE_PRINCIPAL_SECRET_ROTATION_LIST_OPTION,- [SecretRotation.UnixLinuxLocalAccount]: UNIX_LINUX_LOCAL_ACCOUNT_ROTATION_LIST_OPTION+ [SecretRotation.UnixLinuxLocalAccount]: UNIX_LINUX_LOCAL_ACCOUNT_ROTATION_LIST_OPTION,+ [SecretRotation.OpenRouterApiKey]: OPEN_ROUTER_API_KEY_ROTATION_LIST_OPTION};export const listSecretRotationOptions = () => {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.tsindex bfc39f39ec..f9140ba670 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@@ -14,7 +14,8 @@ export const SECRET_ROTATION_NAME_MAP: Record<SecretRotation, string> = {[SecretRotation.RedisCredentials]: "Redis Credentials",[SecretRotation.MongoDBCredentials]: "MongoDB Credentials",[SecretRotation.DatabricksServicePrincipalSecret]: "Databricks Service Principal Secret",- [SecretRotation.UnixLinuxLocalAccount]: "Unix/Linux Local Account"+ [SecretRotation.UnixLinuxLocalAccount]: "Unix/Linux Local Account",+ [SecretRotation.OpenRouterApiKey]: "OpenRouter API Key"};export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnection> = {@@ -30,5 +31,6 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.RedisCredentials]: AppConnection.Redis,[SecretRotation.MongoDBCredentials]: AppConnection.MongoDB,[SecretRotation.DatabricksServicePrincipalSecret]: AppConnection.Databricks,- [SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH+ [SecretRotation.UnixLinuxLocalAccount]: AppConnection.SSH,+ [SecretRotation.OpenRouterApiKey]: AppConnection.OpenRouter};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.tsindex e99baaf8f6..3be8ec2cde 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@@ -87,6 +87,7 @@ import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";import { awsIamUserSecretRotationFactory } from "./aws-iam-user-secret/aws-iam-user-secret-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";import { redisCredentialsRotationFactory } from "./redis-credentials/redis-credentials-rotation-fns";import { TSecretRotationV2DALFactory } from "./secret-rotation-v2-dal";import { unixLinuxLocalAccountRotationFactory } from "./unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns";@@ -146,7 +147,8 @@ const SECRET_ROTATION_FACTORY_MAP: Record<SecretRotation, TRotationFactoryImplem[SecretRotation.MongoDBCredentials]: mongodbCredentialsRotationFactory as TRotationFactoryImplementation,[SecretRotation.DatabricksServicePrincipalSecret]:databricksServicePrincipalSecretRotationFactory as TRotationFactoryImplementation,- [SecretRotation.UnixLinuxLocalAccount]: unixLinuxLocalAccountRotationFactory as TRotationFactoryImplementation+ [SecretRotation.UnixLinuxLocalAccount]: unixLinuxLocalAccountRotationFactory as TRotationFactoryImplementation,+ [SecretRotation.OpenRouterApiKey]: openRouterApiKeyRotationFactory as TRotationFactoryImplementation};export const secretRotationV2ServiceFactory = ({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.tsindex 9b6c89ad10..c32bd7a62c 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@@ -67,6 +67,13 @@ import {TOktaClientSecretRotationListItem,TOktaClientSecretRotationWithConnection} from "./okta-client-secret";+import {+ TOpenRouterApiKeyRotation,+ TOpenRouterApiKeyRotationGeneratedCredentials,+ TOpenRouterApiKeyRotationInput,+ TOpenRouterApiKeyRotationListItem,+ TOpenRouterApiKeyRotationWithConnection+} from "./open-router-api-key";import {TOracleDBCredentialsRotation,TOracleDBCredentialsRotationInput,@@ -109,7 +116,8 @@ export type TSecretRotationV2 =| TRedisCredentialsRotation| TMongoDBCredentialsRotation| TDatabricksServicePrincipalSecretRotation- | TUnixLinuxLocalAccountRotation;+ | TUnixLinuxLocalAccountRotation+ | TOpenRouterApiKeyRotation;export type TSecretRotationV2WithConnection =| TPostgresCredentialsRotationWithConnection@@ -124,7 +132,8 @@ export type TSecretRotationV2WithConnection =| TRedisCredentialsRotationWithConnection| TMongoDBCredentialsRotationWithConnection| TDatabricksServicePrincipalSecretRotationWithConnection- | TUnixLinuxLocalAccountRotationWithConnection;+ | TUnixLinuxLocalAccountRotationWithConnection+ | TOpenRouterApiKeyRotationWithConnection;export type TSecretRotationV2GeneratedCredentials =| TSqlCredentialsRotationGeneratedCredentials@@ -135,7 +144,8 @@ export type TSecretRotationV2GeneratedCredentials =| TOktaClientSecretRotationGeneratedCredentials| TRedisCredentialsRotationGeneratedCredentials| TDatabricksServicePrincipalSecretRotationGeneratedCredentials- | TUnixLinuxLocalAccountRotationGeneratedCredentials;+ | TUnixLinuxLocalAccountRotationGeneratedCredentials+ | TOpenRouterApiKeyRotationGeneratedCredentials;export type TSecretRotationV2Input =| TPostgresCredentialsRotationInput@@ -150,7 +160,8 @@ export type TSecretRotationV2Input =| TRedisCredentialsRotationInput| TMongoDBCredentialsRotationInput| TDatabricksServicePrincipalSecretRotationInput- | TUnixLinuxLocalAccountRotationInput;+ | TUnixLinuxLocalAccountRotationInput+ | TOpenRouterApiKeyRotationInput;export type TSecretRotationV2ListItem =| TPostgresCredentialsRotationListItem@@ -165,7 +176,8 @@ export type TSecretRotationV2ListItem =| TRedisCredentialsRotationListItem| TMongoDBCredentialsRotationListItem| TDatabricksServicePrincipalSecretRotationListItem- | TUnixLinuxLocalAccountRotationListItem;+ | TUnixLinuxLocalAccountRotationListItem+ | TOpenRouterApiKeyRotationListItem;export type TSecretRotationV2TemporaryParameters =| TLdapPasswordRotationInput["temporaryParameters"]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.tsindex ef30328102..33931ba644 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@@ -9,6 +9,7 @@ import { MongoDBCredentialsRotationSchema } from "@app/ee/services/secret-rotatiimport { MsSqlCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/mssql-credentials";import { MySqlCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/mysql-credentials";import { OktaClientSecretRotationSchema } from "@app/ee/services/secret-rotation-v2/okta-client-secret";+import { OpenRouterApiKeyRotationSchema } from "@app/ee/services/secret-rotation-v2/open-router-api-key";import { OracleDBCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/oracledb-credentials";import { PostgresCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/postgres-credentials";import { RedisCredentialsRotationSchema } from "@app/ee/services/secret-rotation-v2/redis-credentials";@@ -27,5 +28,6 @@ export const SecretRotationV2Schema = z.discriminatedUnion("type", [RedisCredentialsRotationSchema,MongoDBCredentialsRotationSchema,DatabricksServicePrincipalSecretRotationSchema,- UnixLinuxLocalAccountRotationSchema+ UnixLinuxLocalAccountRotationSchema,+ OpenRouterApiKeyRotationSchema]);diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 2f27ca4967..b960fd4828 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3013,6 +3013,11 @@ export const SecretRotations = {servicePrincipalId: "The ID of the Databricks Service Principal to rotate the OAuth secret for.",servicePrincipalName: "The name of the Databricks Service Principal to rotate the OAuth secret for.",clientId: "The client ID of the Databricks Service Principal to rotate the OAuth secret for."+ },+ OPEN_ROUTER_API_KEY: {+ name: "The name for the generated OpenRouter API key.",+ limit: "The optional spending limit in USD for the generated API key.",+ limitReset: "The type of limit reset for the API key (daily, weekly, monthly, or null for no reset)."}},SECRETS_MAPPING: {@@ -3059,6 +3064,9 @@ export const SecretRotations = {DATABRICKS_SERVICE_ACCOUNT_SECRET: {clientId: "The name of the secret that the client ID will be mapped to.",clientSecret: "The name of the secret that the rotated OAuth client secret will be mapped to."+ },+ OPEN_ROUTER_API_KEY: {+ apiKey: "The name of the secret that the rotated OpenRouter API key will be mapped to."}}};diff --git a/backend/src/services/app-connection/open-router/open-router-connection-fns.ts b/backend/src/services/app-connection/open-router/open-router-connection-fns.tsindex ae36a9d837..a635e33754 100644--- a/backend/src/services/app-connection/open-router/open-router-connection-fns.ts+++ b/backend/src/services/app-connection/open-router/open-router-connection-fns.ts@@ -5,7 +5,7 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enumsimport { OpenRouterConnectionMethod } from "./open-router-connection-enums";import { TOpenRouterConnectionConfig } from "./open-router-connection-types";-const OPEN_ROUTER_API_BASE_URL = "https://openrouter.ai/api/v1";+export const OPEN_ROUTER_API_BASE_URL = "https://openrouter.ai/api/v1";export const getOpenRouterConnectionListItem = () => {return {