From 19b0a18ed508e0762f6b6cfc1a5c0fc127dbf92a Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:00:08 +0000 Subject: [PATCH 1/7] Update product/enterprise-offering/budget-policies.mdx --- .../enterprise-offering/budget-policies.mdx | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index d9dcd2e7..9991248a 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -90,12 +90,56 @@ All policy endpoints are under: Usage limits policies allow you to set maximum usage (cost or tokens) that can be consumed over a period. When the limit is reached, requests will be blocked until the limit resets. -### Policy Types - -Usage limits policies support two types: - -- **`cost`**: Limit based on total cost (in dollars) -- **`tokens`**: Limit based on total tokens consumed +### Parameters + + + A descriptive name for the policy to help identify its purpose. + + + + Defines which requests the policy applies to. Must be a non-empty array of condition objects. + + + + The field to match against. Valid values: `api_key`, `workspace_id`, or any key starting with `metadata.` (e.g., `metadata._user`, `metadata.team`). + + + + The value to match. Use `*` as a wildcard to match all values for the specified key. + + + + + + Defines how usage is aggregated. Must be a non-empty array of group objects. + + + + The field to group by. Valid values: `api_key`, `workspace_id`, or any key starting with `metadata.` (e.g., `metadata._user`). + + + + + + The type of usage to limit. Valid values: + - `cost` - Limit based on total cost in dollars + - `tokens` - Limit based on total tokens consumed + + + + The maximum usage allowed. For `cost` type, this is in dollars. For `tokens` type, this is the number of tokens. + + + + Optional threshold to trigger alerts before the limit is reached. Must be less than `credit_limit`. + + + + How often the usage counter resets. Valid values: + - `daily` - Resets every day at midnight UTC + - `weekly` - Resets every Monday at midnight UTC + - `monthly` - Resets on the first day of each month at midnight UTC + ### Validation Rules From 7d0fba1bed4e5e0b346454c6b24bf655c243f084 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:00:21 +0000 Subject: [PATCH 2/7] Update product/enterprise-offering/budget-policies.mdx --- .../enterprise-offering/budget-policies.mdx | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index 9991248a..64236475 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -207,20 +207,52 @@ Limit tokens per user (via metadata): Rate limits policies allow you to control the rate of requests or tokens consumed per minute, hour, or day. When the rate limit is exceeded, requests will be throttled. -### Policy Types +### Parameters + + + A descriptive name for the policy to help identify its purpose. + -Rate limits policies support two types: + + Defines which requests the policy applies to. Must be a non-empty array of condition objects. + + + + The field to match against. Valid values: `api_key`, `workspace_id`, or any key starting with `metadata.` (e.g., `metadata._user`, `metadata.team`). + + + + The value to match. Use `*` as a wildcard to match all values for the specified key. + + + -- **`requests`**: Limit based on number of requests -- **`tokens`**: Limit based on number of tokens + + Defines how rate limits are aggregated. Must be a non-empty array of group objects. + + + + The field to group by. Valid values: `api_key`, `workspace_id`, or any key starting with `metadata.` (e.g., `metadata._user`). + + + -### Rate Units + + The type of rate limit. Valid values: + - `requests` - Limit based on number of requests + - `tokens` - Limit based on number of tokens + -Rate limits can be specified in three units: + + The time unit for the rate limit. Valid values: + - `rpm` - Requests or tokens per minute + - `rph` - Requests or tokens per hour + - `rpd` - Requests or tokens per day + -- **`rpm`**: Requests/Tokens per minute -- **`rph`**: Requests/Tokens per hour -- **`rpd`**: Requests/Tokens per day + + The maximum number of requests or tokens allowed per time unit. + ### Validation Rules From 780133e1971c0a4b3205a4bb1a1e807cc9b830c2 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:15:10 +0000 Subject: [PATCH 3/7] Update product/enterprise-offering/budget-policies.mdx --- .../enterprise-offering/budget-policies.mdx | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index 64236475..d4623d4c 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -11,14 +11,33 @@ Requires **1.17.0** or higher version of the Gateway. # Policies -Policies allow you to set usage limits and rate limits for your workspaces. There are two types of policies: +Policies allow you to set usage limits and rate limits for your workspaces. -- **Usage Limits Policies**: Control the total usage (cost or tokens) over a period -- **Rate Limits Policies**: Control the rate of requests or tokens per minute/hour/day +## Policy Types + +There are two types of policies you can configure: + + + Control the total usage (cost or tokens) over a period. When the limit is reached, requests will be blocked until the limit resets based on the periodic reset schedule (daily, weekly, or monthly). + + **Use cases:** + - Set monthly budget caps per API key + - Limit token consumption per user + - Control costs across teams or projects + + + + Control the rate of requests or tokens per minute/hour/day. When the rate limit is exceeded, requests will be throttled to prevent overuse. + + **Use cases:** + - Prevent API abuse with request rate limits + - Control token consumption velocity + - Manage load across different user groups + ## Policy Structure -Both policy types share common concepts: +All policies share common structural concepts: ### Conditions From 865344d6ff421c433adeaf786081fdae0aeff9af Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:15:17 +0000 Subject: [PATCH 4/7] Update product/enterprise-offering/budget-policies.mdx --- product/enterprise-offering/budget-policies.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index d4623d4c..725e5d0a 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -109,14 +109,14 @@ All policy endpoints are under: Usage limits policies allow you to set maximum usage (cost or tokens) that can be consumed over a period. When the limit is reached, requests will be blocked until the limit resets. -### Parameters +### Policy structure A descriptive name for the policy to help identify its purpose. - Defines which requests the policy applies to. Must be a non-empty array of condition objects. + Defines which requests the policy applies to. Must be a non-empty array of condition objects. See [Conditions](#conditions) section above for valid keys. @@ -130,7 +130,7 @@ Usage limits policies allow you to set maximum usage (cost or tokens) that can b - Defines how usage is aggregated. Must be a non-empty array of group objects. + Defines how usage is aggregated. Must be a non-empty array of group objects. See [Group By](#group-by) section above for valid keys. From ae9183ea7a359ed4e7af0b3ce17164a45c1b6323 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:15:23 +0000 Subject: [PATCH 5/7] Update product/enterprise-offering/budget-policies.mdx --- .../enterprise-offering/budget-policies.mdx | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index 725e5d0a..36484102 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -173,54 +173,56 @@ Usage limits policies allow you to set maximum usage (cost or tokens) that can b ### Examples -#### 1: Monthly Cost Limit per API Key + + + Limit each API key to $1000 per month: -Limit each API key to $1000 per month: - -```json -{ - "name": "Monthly Cost Limit per API Key", - "conditions": [ - { - "key": "api_key", - "value": "*" - } - ], - "group_by": [ + ```json { - "key": "api_key" + "name": "Monthly Cost Limit per API Key", + "conditions": [ + { + "key": "api_key", + "value": "*" + } + ], + "group_by": [ + { + "key": "api_key" + } + ], + "type": "cost", + "credit_limit": 1000.0, + "alert_threshold": 800.0, + "periodic_reset": "monthly" } - ], - "type": "cost", - "credit_limit": 1000.0, - "alert_threshold": 800.0, - "periodic_reset": "monthly" -} -``` - -#### 2: Token Limit by User - -Limit tokens per user (via metadata): + ``` + + + + Limit tokens per user (via metadata): -```json -{ - "name": "Token Limit per User", - "conditions": [ + ```json { - "key": "api_key", - "value": "*" + "name": "Token Limit per User", + "conditions": [ + { + "key": "api_key", + "value": "*" + } + ], + "group_by": [ + { + "key": "metadata._user" + } + ], + "type": "tokens", + "credit_limit": 1000000, + "periodic_reset": "weekly" } - ], - "group_by": [ - { - "key": "metadata._user" - } - ], - "type": "tokens", - "credit_limit": 1000000, - "periodic_reset": "weekly" -} -``` + ``` + + ## Rate Limits Policies From be44b3640e2669dd72be910a0b3b97144c24aaa3 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:15:29 +0000 Subject: [PATCH 6/7] Update product/enterprise-offering/budget-policies.mdx --- product/enterprise-offering/budget-policies.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index 36484102..4942d4c3 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -228,14 +228,14 @@ Usage limits policies allow you to set maximum usage (cost or tokens) that can b Rate limits policies allow you to control the rate of requests or tokens consumed per minute, hour, or day. When the rate limit is exceeded, requests will be throttled. -### Parameters +### Policy structure A descriptive name for the policy to help identify its purpose. - Defines which requests the policy applies to. Must be a non-empty array of condition objects. + Defines which requests the policy applies to. Must be a non-empty array of condition objects. See [Conditions](#conditions) section above for valid keys. @@ -249,7 +249,7 @@ Rate limits policies allow you to control the rate of requests or tokens consume - Defines how rate limits are aggregated. Must be a non-empty array of group objects. + Defines how rate limits are aggregated. Must be a non-empty array of group objects. See [Group By](#group-by) section above for valid keys. From 00214a787c0fbeafc1fa28b640686a412fd134ae Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:15:36 +0000 Subject: [PATCH 7/7] Update product/enterprise-offering/budget-policies.mdx --- .../enterprise-offering/budget-policies.mdx | 126 +++++++++--------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/product/enterprise-offering/budget-policies.mdx b/product/enterprise-offering/budget-policies.mdx index 4942d4c3..a567a0dc 100644 --- a/product/enterprise-offering/budget-policies.mdx +++ b/product/enterprise-offering/budget-policies.mdx @@ -288,74 +288,76 @@ Rate limits policies allow you to control the rate of requests or tokens consume ### Examples -#### 1: Requests per Minute per API Key - -Limit each API key to 100 requests per minute: + + + Limit each API key to 100 requests per minute: -```json -{ - "name": "100 RPM per API Key", - "conditions": [ - { - "key": "api_key", - "value": "*" - } - ], - "group_by": [ + ```json { - "key": "api_key" + "name": "100 RPM per API Key", + "conditions": [ + { + "key": "api_key", + "value": "*" + } + ], + "group_by": [ + { + "key": "api_key" + } + ], + "type": "requests", + "unit": "rpm", + "value": 100 } - ], - "type": "requests", - "unit": "rpm", - "value": 100 -} -``` - -#### 2: Tokens per Hour by User - -Limit tokens per user (via metadata) to 10,000 per hour: + ``` + + + + Limit tokens per user (via metadata) to 10,000 per hour: -```json -{ - "name": "10K Tokens per Hour per User", - "conditions": [ - { - "key": "api_key", - "value": "*" - } - ], - "group_by": [ + ```json { - "key": "metadata._user" + "name": "10K Tokens per Hour per User", + "conditions": [ + { + "key": "api_key", + "value": "*" + } + ], + "group_by": [ + { + "key": "metadata._user" + } + ], + "type": "tokens", + "unit": "rph", + "value": 10000 } - ], - "type": "tokens", - "unit": "rph", - "value": 10000 -} -``` - -#### 3: Daily Request Limit - -Limit total requests per day for a workspace: + ``` + + + + Limit total requests per day for a workspace: -```json -{ - "name": "10K Requests per Day", - "conditions": [ - { - "key": "api_key", - "value": "*" - } - ], - "group_by": [ + ```json { - "key": "workspace_id" + "name": "10K Requests per Day", + "conditions": [ + { + "key": "api_key", + "value": "*" + } + ], + "group_by": [ + { + "key": "workspace_id" + } + ], + "type": "requests", + "unit": "rpd", + "value": 10000 } - ], - "type": "requests", - "unit": "rpd", - "value": 10000 -} -``` \ No newline at end of file + ``` + + \ No newline at end of file