🚀 Introducing Agent Gateway — governance, observability, and control for your AI agents.  Register for live webinar ↗
curl --request POST \
--url https://api.portkey.ai/v1/policies/usage-limits \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: <api-key>' \
--data '
{
"name": "Monthly Cost Limit per API Key",
"conditions": [
{
"key": "workspace_id",
"value": "workspace-123"
}
],
"group_by": [
{
"key": "api_key"
}
],
"type": "cost",
"credit_limit": 1000,
"alert_threshold": 800,
"periodic_reset": "monthly"
}
'{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"object": "policy_usage_limits"
}Create a new usage limits policy to control total usage (cost or tokens) over a period.
curl --request POST \
--url https://api.portkey.ai/v1/policies/usage-limits \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: <api-key>' \
--data '
{
"name": "Monthly Cost Limit per API Key",
"conditions": [
{
"key": "workspace_id",
"value": "workspace-123"
}
],
"group_by": [
{
"key": "api_key"
}
],
"type": "cost",
"credit_limit": 1000,
"alert_threshold": 800,
"periodic_reset": "monthly"
}
'{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"object": "policy_usage_limits"
}Documentation Index
Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Array of conditions that define which requests the policy applies to
1Show child attributes
Array of group by fields that define how usage is aggregated
1Show child attributes
Policy type
cost, tokens Maximum usage allowed
x >= 0Policy name
255"Monthly Cost Limit"
Threshold at which to send alerts. Must be less than credit_limit.
x >= 0Reset period. If not provided, limit is cumulative.
monthly, weekly Workspace ID or slug. Required if not using API key authentication.
Organization ID. Required if not using API key authentication.
Was this page helpful?