Skip to main content

Overview

Helicone’s caching feature stores and reuses responses from previous API requests, dramatically reducing costs and latency. When a cached response is returned, you avoid making a new request to the AI provider entirely.
Caching is particularly effective for:
  • Repeated queries (e.g., FAQ responses)
  • Static prompts with consistent outputs
  • Development and testing environments
  • High-traffic applications with common requests

Key Benefits

Cost Reduction

Save up to 90% on API costs by serving cached responses instead of making new requests

Lower Latency

Cached responses are returned instantly, reducing response times from seconds to milliseconds

Bucket Caching

Store multiple variations of responses for the same prompt to maintain output diversity

Flexible TTL

Control cache expiration with custom time-to-live settings from hours to months

Quick Start

Enable caching by adding the Helicone-Cache-Enabled header to your requests:

Cache Headers

Basic Caching

Advanced Options

Bucket Caching

Bucket caching stores multiple response variations for the same request, useful for non-deterministic outputs:
With bucket caching enabled:
  1. The first 10 requests generate new responses and fill the cache bucket
  2. Subsequent requests randomly select from the 10 cached responses
  3. Users experience variety without the cost of new API calls

Cache Key Generation

Helicone generates cache keys based on:
  • Request URL and endpoint
  • Request body (excluding ignored keys)
  • Authorization headers
  • Custom cache headers
  • Cache seed (if provided)

Ignoring Request Fields

Exclude fields from cache key generation to cache similar requests together:

Cache Seeds

Use cache seeds to segment caches by user, tenant, or environment:

TTL Configuration

Control how long responses stay cached:
Common TTL values:
  • max-age=3600 - 1 hour
  • max-age=86400 - 1 day
  • max-age=604800 - 1 week (default)
  • max-age=2592000 - 30 days

Cache Response Headers

Helicone adds headers to indicate cache status:

Best Practices

Set shorter TTLs for dynamic content and longer TTLs for static responses:
  • FAQ responses: 7-30 days
  • News summaries: 1-6 hours
  • Product descriptions: 7+ days
  • Embeddings: 30+ days
For creative content or varied responses, use bucket caching with higher temperatures to maintain diversity while reducing costs.
Track the Helicone-Cache header in your logs to measure cache effectiveness and optimize your caching strategy.
Use cache seeds to separate caches for different users, tenants, or environments when responses should be personalized.
Use shorter TTLs and smaller bucket sizes during development to iterate quickly on cache configurations.

Limitations

  • Maximum cache TTL: 365 days
  • Maximum bucket size: 20 responses
  • Cache timeout: 2 seconds (falls back to fresh request if cache is slow)
  • Streaming responses are cached after completion

Rate Limiting

Control API usage with custom rate limits

Cost Tracking

Monitor spending and savings from caching