Skip to content

rate & budget limit for API keys, with email notifs #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"pages": [
"product/administration/enforcing-request-metadata",
"product/administration/enforce-orgnization-level-guardrails",
"product/administration/enforce-workspace-level-guardials"
"product/administration/enforce-workspace-level-guardials",
"product/administration/enforce-budget-and-rate-limit"
]
},
{
Expand Down Expand Up @@ -2096,4 +2097,4 @@
"seo": {
"indexing": "all"
}
}
}
Binary file added images/product/email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions product/administration/enforce-budget-and-rate-limit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: "Enforce Budget Limits and Rate Limits for Your API Keys"
description: "Configure budget and rate limits on API keys to effectively manage AI spending and usage across your organization"
---

<Info>
Available on **Enterprise** plan and select **Pro** customers.
</Info>

## Overview
For enterprises deploying AI at scale, maintaining financial oversight and operational control is crucial. Portkey's governance features for API keys provide finance teams, IT departments, and executives with the transparency and guardrails needed to confidently scale AI adoption across the organization.

By implementing budget and rate limits on API keys at both organization and workspace levels, you can:

- Prevent unexpected cost overruns through automated spending caps
- Maintain performance and availability through usage rate controls
- Receive timely notifications when thresholds are approached
- Enforce consistent governance policies across teams and departments

These capabilities ensure your organization can innovate with AI while maintaining predictable costs and usage patterns.


## Budget Limits

Budget limits allow you to set maximum LLM spending or token usage thresholds on your API keys, automatically preventing further usage when limits are reached.

When creating or editing an API key, you can establish spending parameters that align with your financial planning:




### Setting Up Budget Limits

When creating a new API key or editing an existing one:

1. Toggle on **Add Budget Limit**
2. Choose between two limit types:
- **Cost**: Set a maximum spend in USD (minimum $1)
- **Tokens**: Set a maximum token usage

<Frame caption="Budget limit configuration">
<img src="/images/product/budget-limits-options.png" />
</Frame>

### Alert Thresholds

You can configure alert thresholds to receive notifications before reaching your full budget:

1. Enter a value in the **Alert Threshold** field
2. When usage reaches this threshold, notifications will be sent to configured recipients
3. The API key continues to function until the full budget limit is reached

### Periodic Reset Options

Budget limits can be set to automatically reset at regular intervals:

<Frame caption="Periodic reset options">
<img src="/images/product/periodic-reset.png" />
</Frame>

- **No Periodic Reset**: The budget limit applies until exhausted
- **Reset Weekly**: Budget limits reset every Sunday at 12 AM UTC
- **Reset Monthly**: Budget limits reset on the 1st of each month at 12 AM UTC

## Rate Limits

Rate limits control how frequently an API key can be used, helping you maintain application performance and prevent unexpected usage spikes.

### Setting Up Rate Limits

When creating a new API key or editing an existing one:

1. Toggle on **Add Rate Limit**
2. Choose your limit type:
- **Requests**: Limit based on number of API calls
- **Tokens**: Limit based on token consumption
3. Specify the limit value and time interval

<Frame caption="Rate limit configuration">
<img src="/images/product/rate-limit.png" />
</Frame>

### Time Intervals

Rate limits can be applied using three different time intervals:

- **Per Minute**: For granular control of high-frequency applications
- **Per Hour**: For balanced control of moderate usage
- **Per Day**: For broader usage management

When a rate limit is reached, subsequent requests are rejected until the time interval resets.

## Email Notifications

Email notifications keep relevant stakeholders informed about API key usage and when limits are approached or reached.

### Configuring Notifications

To set up email notifications for an API key with budget limits:

1. Toggle on **Email Notifications** when creating/editing an API key
2. Add recipient email addresses:
- Type an email address and click **New** or press Enter
- Add multiple recipients as needed

<Frame caption="Email notification setup">
<img src="/images/product/email.png" />
</Frame>

### Default Recipients

When limits are reached or thresholds are crossed, Portkey automatically sends notifications to:

- Organization administrators
- Organization owners
- The API key creator/owner

You can add additional recipients such as finance team members, department heads, or project managers who need visibility into AI usage.

## Availability

These features are available to Portkey Enterprise customers and select Pro users. To enable these features for your account, please contact [[email protected]](mailto:[email protected]) or join the [Portkey Discord](https://portkey.ai/community) community.

To learn more about the Portkey Enterprise plan, [schedule a consultation](https://portkey.sh/demo-16).