Skip to content

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

fix: PR feedback

IgorHortaead474fe5b56
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.ts
index c817ca9941..e916c1e7fe 100644
--- 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.ts
@@ -44,7 +44,7 @@ export const openRouterApiKeyRotationFactory: TRotationFactory<
> = (secretRotation) => {
const {
connection,
- parameters: { name, limit, limitReset },
+ parameters: { name, limit, limitReset, includeByokInLimit },
secretsMapping
} = secretRotation;
@@ -59,6 +59,7 @@ export const openRouterApiKeyRotationFactory: TRotationFactory<
name: string;
limit?: number | null;
limit_reset?: string | null;
+ include_byok_in_limit?: boolean | null;
} = { name };
if (limit !== undefined && limit !== null) {
@@ -67,6 +68,9 @@ export const openRouterApiKeyRotationFactory: TRotationFactory<
if (limitReset !== undefined && limitReset !== null) {
requestBody.limit_reset = limitReset;
}
+ if (includeByokInLimit !== undefined && includeByokInLimit !== null) {
+ requestBody.include_byok_in_limit = includeByokInLimit;
+ }
const { data } = await request.post<TOpenRouterApiKeyCreateResponse>(
`${OPEN_ROUTER_API_BASE_URL}/keys`,
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.ts
index cf779a4d1d..81c277dba5 100644
--- 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.ts
@@ -32,7 +32,12 @@ const OpenRouterApiKeyRotationParametersSchema = z.object({
.nativeEnum(OpenRouterLimitReset)
.optional()
.nullable()
- .describe(SecretRotations.PARAMETERS.OPEN_ROUTER_API_KEY.limitReset)
+ .describe(SecretRotations.PARAMETERS.OPEN_ROUTER_API_KEY.limitReset),
+ includeByokInLimit: z
+ .boolean()
+ .optional()
+ .nullable()
+ .describe(SecretRotations.PARAMETERS.OPEN_ROUTER_API_KEY.includeByokInLimit)
});
const OpenRouterApiKeyRotationSecretsMappingSchema = z.object({
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.ts
index bdf70c1226..f7d71ef362 100644
--- 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.ts
@@ -27,6 +27,7 @@ export interface TOpenRouterApiKeyRotationParameters {
name: string;
limit?: number | null;
limitReset?: "daily" | "weekly" | "monthly" | null;
+ includeByokInLimit?: boolean | null;
}
export interface TOpenRouterApiKeyRotationSecretsMapping {
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index ffc8d2787f..2b99dc3131 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -3023,7 +3023,9 @@ export const SecretRotations = {
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)."
+ limitReset: "The type of limit reset for the API key (daily, weekly, monthly, or null for no reset).",
+ 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."
}
},
SECRETS_MAPPING: {
diff --git a/docs/documentation/platform/secret-rotation/open-router-api-key.mdx b/docs/documentation/platform/secret-rotation/open-router-api-key.mdx
index 345a2174d3..ef955eab03 100644
--- a/docs/documentation/platform/secret-rotation/open-router-api-key.mdx
+++ b/docs/documentation/platform/secret-rotation/open-router-api-key.mdx
@@ -35,6 +35,7 @@ description: "Learn how to automatically rotate OpenRouter API keys."
- **Key name** – Display name for the key in OpenRouter (required).
- **Limit** (optional) – Spending limit in USD for this key.
- **Limit reset** (optional) – How often the limit resets: daily, weekly, or monthly.
+ - **Include BYOK in limit** (optional) – When enabled, usage from your own provider keys ([BYOK](https://openrouter.ai/docs/guides/overview/auth/byok)—Bring Your Own Key) counts toward this key’s spending limit. When disabled, only OpenRouter credits are counted. See [OpenRouter BYOK](https://openrouter.ai/docs/guides/overview/auth/byok) for details.
5. Specify the secret name that the rotated API key will be mapped to. Then click **Next**.
@@ -82,7 +83,8 @@ description: "Learn how to automatically rotate OpenRouter API keys."
"parameters": {
"name": "my-app-key",
"limit": 100,
- "limitReset": "monthly"
+ "limitReset": "monthly",
+ "includeByokInLimit": false
},
"secretsMapping": {
"apiKey": "OPEN_ROUTER_API_KEY"
@@ -110,7 +112,8 @@ description: "Learn how to automatically rotate OpenRouter API keys."
"parameters": {
"name": "my-app-key",
"limit": 100,
- "limitReset": "monthly"
+ "limitReset": "monthly",
+ "includeByokInLimit": false
}
}
}
@@ -118,6 +121,15 @@ description: "Learn how to automatically rotate OpenRouter API keys."
</Tab>
</Tabs>
+## Include BYOK in limit (optional)
+
+**BYOK** (Bring Your Own Key) on OpenRouter lets you use your own provider API keys (e.g. OpenAI, Anthropic) so you pay providers directly; OpenRouter charges a small fee on those requests. The **Include BYOK in limit** option controls whether that BYOK usage counts toward this key’s spending limit:
+
+- **Enabled (Yes)** – Usage from your own provider keys is included in the limit. Once the limit is reached, the key is subject to OpenRouter’s rate limits until the next reset.
+- **Disabled (No)** – Only OpenRouter credit usage counts toward the limit. BYOK usage is tracked separately and does not consume the limit.
+
+This is optional; if you don’t use BYOK or don’t set a limit, you can leave it off. For more details, see [OpenRouter BYOK](https://openrouter.ai/docs/guides/overview/auth/byok) and [OpenRouter limits](https://openrouter.ai/docs/api/reference/limits).
+
## How It Works
Infisical uses OpenRouter’s [Provisioning API](https://openrouter.ai/docs/guides/overview/auth/provisioning-api-keys) to:
diff --git a/docs/images/secret-rotations-v2/open-router-api-key/parameters.png b/docs/images/secret-rotations-v2/open-router-api-key/parameters.png
index e9594c9356..8af4d01cca 100644
Binary files a/docs/images/secret-rotations-v2/open-router-api-key/parameters.png and b/docs/images/secret-rotations-v2/open-router-api-key/parameters.png differ
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenRouterApiKeyRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenRouterApiKeyRotationParametersFields.tsx
index c186085a2f..a1ce12ee67 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenRouterApiKeyRotationParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenRouterApiKeyRotationParametersFields.tsx
@@ -1,7 +1,7 @@
import { Controller, useFormContext } from "react-hook-form";
import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
-import { FormControl, Input, Select, SelectItem } from "@app/components/v2";
+import { FormControl, Input, Select, SelectItem, Switch } from "@app/components/v2";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import { OpenRouterLimitReset } from "@app/hooks/api/secretRotationsV2/types/open-router-api-key-rotation";
@@ -88,6 +88,29 @@ export const OpenRouterApiKeyRotationParametersFields = () => {
</FormControl>
)}
/>
+ <Controller
+ name="parameters.includeByokInLimit"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Include BYOK in limit"
+ isOptional
+ tooltipText="When enabled, usage from your own provider keys (BYOK - Bring Your Own Key) counts toward this key's spending limit. When disabled, only OpenRouter credits are counted. See OpenRouter BYOK docs for details."
+ >
+ <Switch
+ className="bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"
+ id="include-byok-in-limit"
+ thumbClassName="bg-mineshaft-800"
+ onCheckedChange={(checked) => onChange(checked)}
+ isChecked={value ?? false}
+ >
+ <p className="w-[9.6rem]">{value ? "Yes" : "No"}</p>
+ </Switch>
+ </FormControl>
+ )}
+ />
</>
);
};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/OpenRouterApiKeyRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/OpenRouterApiKeyRotationReviewFields.tsx
index adc694d543..03143902e7 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/OpenRouterApiKeyRotationReviewFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/OpenRouterApiKeyRotationReviewFields.tsx
@@ -33,6 +33,11 @@ export const OpenRouterApiKeyRotationReviewFields = () => {
{LIMIT_RESET_LABELS[parameters.limitReset] || parameters.limitReset}
</GenericFieldLabel>
)}
+ {parameters.includeByokInLimit != null && (
+ <GenericFieldLabel label="Include BYOK in limit">
+ {parameters.includeByokInLimit ? "Yes" : "No"}
+ </GenericFieldLabel>
+ )}
</SecretRotationReviewSection>
<SecretRotationReviewSection label="Secrets Mapping">
<GenericFieldLabel label="API Key">{apiKey}</GenericFieldLabel>
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/open-router-api-key-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/open-router-api-key-rotation-schema.ts
index 4c812a8283..2a86f492d7 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/open-router-api-key-rotation-schema.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/open-router-api-key-rotation-schema.ts
@@ -10,7 +10,8 @@ export const OpenRouterApiKeyRotationSchema = z
parameters: z.object({
name: z.string().trim().min(1, "Key name required"),
limit: z.number().positive().optional().nullable(),
- limitReset: z.nativeEnum(OpenRouterLimitReset).optional().nullable()
+ limitReset: z.nativeEnum(OpenRouterLimitReset).optional().nullable(),
+ includeByokInLimit: z.boolean().optional().nullable()
}),
secretsMapping: z.object({
apiKey: z.string().trim().min(1, "API Key secret name required")
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/open-router-api-key-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/open-router-api-key-rotation.ts
index 893e8c9546..0dcd7dbe24 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/open-router-api-key-rotation.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/open-router-api-key-rotation.ts
@@ -17,6 +17,7 @@ export type TOpenRouterApiKeyRotation = TSecretRotationV2Base & {
name: string;
limit?: number | null;
limitReset?: OpenRouterLimitReset | null;
+ includeByokInLimit?: boolean | null;
};
secretsMapping: {
apiKey: string;