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

# Rate limits

> Rate limit configuration and handling for the Andi AI Search API.

Rate limits control how many requests an API key can make within a time window. They protect the service and ensure fair usage across all consumers.

## Default limits

Rate limits are configured per API key through the [API Console](https://console.andiai.com). Limits use a per-second sliding window. The default limit is set when you create a key and can be adjusted based on your needs.

<Info>
  Contact [support](mailto:hello+api@andiai.com) if you need higher rate limits than what's available in the console.
</Info>

## Rate limit headers

The API includes rate limit headers on every response:

| Header                  | Description                                               |
| ----------------------- | --------------------------------------------------------- |
| `X-RateLimit-Limit`     | Maximum requests allowed per second                       |
| `X-RateLimit-Remaining` | Requests remaining in the current window                  |
| `X-RateLimit-Reset`     | Unix timestamp (seconds) when the window resets           |
| `Retry-After`           | Seconds to wait before retrying (only on `429` responses) |

## Handling 429 responses

When you exceed your rate limit, the API returns a `429` status code:

```json theme={null}
{
  "error": "Too Many Requests",
  "message": "Rate limit of N requests per second exceeded"
}
```

Use the rate limit headers to monitor usage and the `Retry-After` header to pace retries:

```python theme={null}
import time
import requests

response = requests.get(
    "https://search-api.andisearch.com/api/v1/search",
    params={"q": "test"},
    headers={"x-api-key": "YOUR_API_KEY"}
)

# Check remaining quota on any response
remaining = int(response.headers.get("X-RateLimit-Remaining", 0))

if response.status_code == 429:
    retry_after = int(response.headers.get("Retry-After", 1))
    time.sleep(retry_after)
    # Retry the request
```

## Monitoring usage

Use the `X-RateLimit-Remaining` header to track how close you are to your limit in real time. For aggregate usage and credit consumption, see the [API Console](https://console.andiai.com).

## Next steps

<CardGroup cols={2}>
  <Card title="Error handling" icon="triangle-exclamation" href="/resources/error-handling">
    Error codes and retry strategies.
  </Card>

  <Card title="Authentication" icon="key" href="/getting-started/authentication">
    API key management and security.
  </Card>
</CardGroup>
