Sawalni API
APIsDocumentationOpen portal ↗
Omneity Labs API collection ↗Integration quickstart →API keys and playgrounds →
Guides

Rate Limits

Sawalni enforces rate limits to ensure fair usage and system stability.

Default Limits

TierRequests/minTokens/min
Free6040,000
Pro300200,000
EnterpriseCustomCustom

Rate Limit Headers

Every API response includes rate limit information:

text
X-RateLimit-Limit: 60 X-RateLimit-Remaining: 45 X-RateLimit-Reset: 1704556800

Handling 429 Errors

When you exceed your limit, you'll receive a 429 Too Many Requests response:

json
{ "error": { "message": "Rate limit exceeded", "type": "rate_limit_error", "code": "rate_limit_exceeded" } }

Best Practices

  1. Implement exponential backoff — Wait 1s, 2s, 4s, 8s… between retries
  2. Cache responses when the same input produces deterministic output
  3. Batch requests — Use array inputs for embeddings
  4. Monitor headers — Check X-RateLimit-Remaining proactively
  5. Upgrade your tier if you consistently hit limits

Example: Retry with Backoff

python
import time from openai import OpenAI, RateLimitError client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.sawalni.com/v1" ) def chat_with_retry(messages, max_retries=3): for attempt in range(max_retries): try: return client.chat.completions.create( model="sawalni-beta", messages=messages ) except RateLimitError: wait = 2 ** attempt print(f"Rate limited, waiting {wait}s...") time.sleep(wait) raise Exception("Max retries exceeded")