Fixed window custom counter strategy
Fixed window custom counter strategy provides granular control over API traffic, providing limits based on tokens and requests within a fixed time window.
The strategy supports configurations for:
- Maximum requests allowed.
- Flexible time windows for rate limiting (for example, minute, or hour).
The following configuration example defines a fixed window custom counter quota:
/etc/lunar-proxy/quotas/{fileName}.yaml
quotas:
- id: FixedWindowCustomCounter # Unique identifier for the quota
filter:
url: api.openai.com/* # URL pattern to apply the quota
strategy:
fixed_window_custom_counter:
max: 40000 # Maximum requests allowed within the window
interval: 1
interval_unit: minute # Time window duration in minutes
counter_value_path: | # JSONPath used to define where to collect token count
$.request.headers["x-lunar-used-tokens"]