Skip to main content

Overview

Rate limits determine how many requests you can make to an API within a specific time window. Understanding and optimizing for these limits is crucial for building reliable applications with free LLM APIs.

Types of Rate Limits

Request-Based

Limits the number of API calls per time period (e.g., 20 requests/minute)

Token-Based

Limits the number of tokens processed per time period (e.g., 60,000 tokens/minute)

Quota-Based

Total allowance over longer periods (e.g., 1,000 requests/month)

Provider Rate Limits Comparison

High Volume Providers

These providers are suitable for production applications with consistent traffic.

Medium Volume Providers

Good for development and small to medium applications.

Low Volume Providers

These are best for prototyping and low-traffic applications.

Token Limit Strategies

High Token Throughput Providers

Token limits are often more important than request limits for applications processing large documents or generating long-form content.

Handling Rate Limits

1. Exponential Backoff

Implement retry logic with exponential backoff:

2. Rate Limit Headers

Monitor rate limit headers in API responses:
Not all providers return rate limit headers. Check the provider’s documentation for specifics.

3. Request Queuing

Implement a queue to stay within rate limits:

4. Token Counting

Count tokens before sending requests:

Multi-Provider Load Balancing

Distribute requests across multiple providers:
Pro Tip: Use Vercel AI Gateway for automatic provider routing, caching, and observability.

Monitoring and Alerts

Track your usage to avoid hitting limits:

Best Practices

Cache Responses

Store and reuse responses for identical requests to reduce API calls

Batch Requests

Group multiple queries when possible to maximize token efficiency

Use Streaming

Stream responses to provide faster perceived performance without extra requests

Implement Fallbacks

Have backup providers ready when primary provider hits limits
Reduce token usage:
  • Use concise system messages
  • Avoid repeating context in conversations
  • Use smaller models when appropriate
  • Truncate long inputs intelligently
Spread requests throughout the day:For providers with daily limits (e.g., Cerebras with 14,400 req/day):
  • Max sustainable rate: ~10 requests/minute
  • Consider off-peak processing for batch jobs
  • Queue non-urgent requests

Provider-Specific Tips

Rate Limit: 20 req/min, 50 req/day (1000 with $10 topup)Optimization Strategies:
  • Use the $10 lifetime topup for 20x increase
  • Models share a common quota - choose wisely
  • Consider switching to Groq for high-volume workloads
OpenRouter’s topup is one-time and never expires, making it excellent value.

Next Steps

Best Practices

Learn more optimization techniques and security practices

Provider Comparison

Compare providers to find the best fit for your use case