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

# Rate Limits

> API rate limits and best practices

## Rate Limit Tiers

| Tier     | Requests/Hour | Burst/Minute |
| -------- | ------------- | ------------ |
| Standard | 1,000         | 100          |
| Premium  | 5,000         | 500          |

<Note>
  Contact your account manager to upgrade to Premium tier.
</Note>

## Rate Limit Headers

All responses include rate limit information:

```
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1706634000
```

| Header                  | Description                          |
| ----------------------- | ------------------------------------ |
| `X-RateLimit-Limit`     | Maximum requests per hour            |
| `X-RateLimit-Remaining` | Requests remaining in current window |
| `X-RateLimit-Reset`     | Unix timestamp when limit resets     |

## Rate Limit Response

When rate limited, you'll receive a `429` response:

```json theme={null}
{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded",
    "details": {
      "retry_after": 3600,
      "limit": 1000,
      "remaining": 0
    }
  }
}
```

## Best Practices

<AccordionGroup>
  <Accordion title="Implement exponential backoff">
    ```javascript theme={null}
    async function requestWithBackoff(url, options, maxRetries = 3) {
      for (let i = 0; i < maxRetries; i++) {
        const response = await fetch(url, options);
        
        if (response.status !== 429) {
          return response;
        }
        
        const retryAfter = response.headers.get('Retry-After') || 60;
        await new Promise(r => setTimeout(r, retryAfter * 1000));
      }
      throw new Error('Max retries exceeded');
    }
    ```
  </Accordion>

  <Accordion title="Cache persona data">
    Persona profiles rarely change. Cache them for 1 hour:

    ```javascript theme={null}
    const CACHE_TTL = 60 * 60 * 1000; // 1 hour
    const cache = new Map();

    async function getPersonas() {
      const cached = cache.get('personas');
      if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
        return cached.data;
      }
      
      const data = await fetchPersonas();
      cache.set('personas', { data, timestamp: Date.now() });
      return data;
    }
    ```
  </Accordion>

  <Accordion title="Batch operations">
    Send topics to multiple personas in one request instead of multiple requests:

    ```javascript theme={null}
    // Good: One request
    await createTopic(content, [persona1, persona2, persona3]);

    // Bad: Three requests
    await createTopic(content, [persona1]);
    await createTopic(content, [persona2]);
    await createTopic(content, [persona3]);
    ```
  </Accordion>

  <Accordion title="Monitor usage">
    Track your rate limit usage:

    ```javascript theme={null}
    function trackRateLimit(response) {
      const remaining = response.headers.get('X-RateLimit-Remaining');
      const limit = response.headers.get('X-RateLimit-Limit');
      
      if (remaining < limit * 0.1) {
        console.warn(`Rate limit warning: ${remaining}/${limit} remaining`);
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Endpoint-Specific Limits

Some endpoints have additional limits:

| Endpoint           | Limit     |
| ------------------ | --------- |
| `POST /topics`     | 100/hour  |
| `GET /personas`    | 1000/hour |
| `GET /topics/{id}` | 1000/hour |

## Need Higher Limits?

Contact [partners@unleeshed.ai](mailto:partners@unleeshed.ai) to discuss:

* Premium tier upgrades
* Enterprise custom limits
* Dedicated infrastructure
