Setting Quotas
Create and manage usage quotas for your customers
Quotas allow you to limit usage for specific customers or dimensions.
Creating a Quota
const quota = await client.quotas.create({
customerId: 'customer_123',
eventType: 'model_call',
limit: 1000,
window: 'monthly',
unit: 'total_tokens',
});quota = await client.quotas.create(
customer_id="customer_123",
event_type="model_call",
limit=1000,
window="monthly",
unit="total_tokens",
)Dimension-Based Quotas
Create quotas filtered by custom properties.
const quota = await client.quotas.create({
customerId: 'customer_123',
eventType: 'model_call',
limit: 100,
window: 'daily',
unit: 'count',
dimensions: {
user_id: 'user_456',
},
});quota = await client.quotas.create(
customer_id="customer_123",
event_type="model_call",
limit=100,
window="daily",
unit="count",
dimensions={"user_id": "user_456"},
)Checking Quotas
Before processing a request, check if the quota allows it.
const result = await client.quotas.check({
customerId: 'customer_123',
eventType: 'model_call',
});
if (!result.allowed) {
throw new Error('Quota exceeded');
}result = await client.quotas.check(
customer_id="customer_123",
event_type="model_call",
)
if not result.allowed:
raise Exception("Quota exceeded")Next Steps
- Rate Limiting - Control request frequency
- Quota Reference - Learn about quota dimensions