Skip to main content

Overview

Helicone’s rate limiting feature allows you to control API usage by enforcing request or cost-based quotas. Set limits per user, organization, custom property, or globally to prevent overuse and manage budgets.
Rate limiting is ideal for:
  • Preventing individual users from exceeding quotas
  • Managing costs across teams or departments
  • Enforcing fair usage in multi-tenant applications
  • Protecting against runaway API consumption

Key Benefits

Flexible Policies

Rate limit by requests, cost (in cents), time windows, and custom segments

Fine-Grained Control

Apply limits per user, property, or globally across your entire organization

Cost Management

Set budget limits in cents to prevent unexpected spending

Instant Feedback

Users receive immediate 429 responses when limits are exceeded with retry information

Quick Start

Apply rate limiting by adding the Helicone-RateLimit-Policy header:

Policy Format

The Helicone-RateLimit-Policy header uses this format:

Required Parameters

  • quota: Maximum number of requests or cents allowed
  • w: Time window in seconds (minimum: 60, maximum: 31536000)

Optional Parameters

  • u: Unit of measurement (request or cents, default: request)
  • s: Segmentation type (user, custom property name, or omit for global)

Policy Examples

Request-Based Limits

Cost-Based Limits

Custom Property Segments

Segmentation Types

Rate limit applies across all requests:

Response Headers

When rate limiting is active, Helicone adds headers to every response:

Rate Limit Exceeded (429 Response)

When limits are exceeded:

Common Time Windows

Advanced Use Cases

Implement different limits for different user tiers:
Set cost limits per department:
Handle rate limits with fallback logic:
Use decimal values for testing cost limits:

Best Practices

  1. Start conservative: Begin with lower limits and increase based on usage patterns
  2. Monitor metrics: Track rate limit hits in your Helicone dashboard
  3. Implement retry logic: Handle 429 responses gracefully with exponential backoff
  4. Use appropriate segments: Choose user, property, or global based on your use case
  5. Set realistic windows: Align time windows with your application’s usage patterns
  6. Combine with caching: Use caching to reduce requests and stay under limits

Limitations

  • Minimum time window: 60 seconds
  • Maximum time window: 31,536,000 seconds (1 year)
  • Policy validation happens on every request
  • Cost-based limits use Helicone’s cost calculations

Caching

Reduce requests with intelligent caching

Webhooks

Get notified when limits are exceeded