curl --request POST \
--url https://api.portkey.ai/v1/policies/rate-limits \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: <api-key>' \
--data '
{
"name": "100 RPM per API Key",
"conditions": [
{
"key": "workspace_id",
"value": "workspace-123"
}
],
"group_by": [
{
"key": "api_key"
}
],
"type": "requests",
"unit": "rpm",
"value": 100
}
'{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"object": "policy_usage_limits"
}Create Rate Limits Policy
Create a new rate limits policy to control the rate of requests or tokens consumed per minute, hour, or day.
POST
/
policies
/
rate-limits
curl --request POST \
--url https://api.portkey.ai/v1/policies/rate-limits \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: <api-key>' \
--data '
{
"name": "100 RPM per API Key",
"conditions": [
{
"key": "workspace_id",
"value": "workspace-123"
}
],
"group_by": [
{
"key": "api_key"
}
],
"type": "requests",
"unit": "rpm",
"value": 100
}
'{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"object": "policy_usage_limits"
}Authorizations
Body
application/json
Array of conditions that define which requests the policy applies to
Minimum array length:
1Show child attributes
Show child attributes
Array of group by fields that define how usage is aggregated
Minimum array length:
1Show child attributes
Show child attributes
Policy type
Available options:
requests, tokens Rate unit:
rpm- Requests/Tokens per minuterph- Requests/Tokens per hourrpd- Requests/Tokens per day
Available options:
rpm, rph, rpd Rate limit value
Policy name
Maximum string length:
255Example:
"100 Requests per Minute"
Workspace ID or slug. Required if not using API key authentication.
Organization ID. Required if not using API key authentication.
Was this page helpful?
โI

