> ## Documentation Index
> Fetch the complete documentation index at: https://docs.synthraai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limiting

> Enterprise-grade rate limiting with token bucket and sliding window algorithms

Synthra provides enterprise-grade rate limiting to prevent abuse while maintaining high throughput.

## Algorithms

### Token Bucket

Allows burst traffic up to bucket capacity. Sub-millisecond check time.

```typescript theme={null}
agent.setRateLimits({
  algorithm: 'token_bucket',
  requestsPerMinute: 100,
  burstCapacity: 150
});
```

### Sliding Window

Precise rate enforcement with no burst allowance. Under 1ms check time.

```typescript theme={null}
agent.setRateLimits({
  algorithm: 'sliding_window',
  requestsPerMinute: 100
});
```

## Rate Limit Tiers

| Tier       | Requests/min | Tokens/min | Burst |
| ---------- | ------------ | ---------- | ----- |
| Free       | 60           | 10,000     | 80    |
| Pro        | 300          | 100,000    | 400   |
| Enterprise | 1,000        | 500,000    | 1,500 |

## Handling Rate Limits

```typescript theme={null}
try {
  const response = await agent.sendMessage(session.id, 'Hello');
} catch (error) {
  if (error.code === 'rate_limit_exceeded') {
    const retryAfter = error.retryAfter;
    await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
    // Retry
  }
}
```

## Check Quota

```typescript theme={null}
const quota = await agent.getRateLimitStatus();
console.log(`Remaining: ${quota.requestsRemaining}`);
```

## Rate Limit Headers

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1709913600
```

<Note>
  Rate limits are enforced per API key by default.
</Note>

<Warning>
  Exceeding rate limits repeatedly may result in temporary API key suspension.
</Warning>
