Configuration management for the rate limiter.
Provides configuration defaults and profile-based settings for rate limiting, concurrency gating, token budgeting, and retry behavior.
Configuration Options
:max_concurrency_per_model- Maximum concurrent requests per model (default: 4, nil/0 disables):max_attempts- Maximum retry attempts (default: 3):base_backoff_ms- Base backoff duration in milliseconds (default: 1000):jitter_factor- Jitter factor for backoff (default: 0.25):non_blocking- Return immediately with retry_at instead of waiting (default: false):disable_rate_limiter- Disable all rate limiting (default: false):adaptive_concurrency- Enable adaptive concurrency (default: false):adaptive_ceiling- Maximum concurrency when adaptive mode is enabled (default: 8):token_budget_per_window- Maximum tokens per window (default: profile-dependent; base is 32_000,:prodprofile sets 500_000; nil disables):window_duration_ms- Duration of budget window in milliseconds (default: 60_000):max_budget_wait_ms- Maximum time to block on over-budget windows before returning (default: nil = no cap):budget_safety_multiplier- Multiplier applied to estimated tokens when reserving budget (default: 1.0):permit_timeout_ms- Maximum time to wait for a concurrency permit before timing out (default: :infinity; set a number to cap wait):profile- Configuration profile (see below)
Profiles
Choose a profile matching your Google Cloud tier. Rate limits are per-project (not per-API key) and vary by model. View your actual limits in AI Studio.
Tier Qualifications
| Tier | Qualification |
|---|---|
| Free | Users in eligible countries |
| Tier 1 | Billing account linked to project |
| Tier 2 | >$250 total spend + 30 days since payment |
| Tier 3 | >$1,000 total spend + 30 days since payment |
Profile Settings
| Profile | Best For | Token Budget |
|---|---|---|
:free_tier | Development, testing | 32,000 |
:paid_tier_1 | Standard production | 1,000,000 |
:paid_tier_2 | High throughput | 2,000,000 |
:paid_tier_3 | Maximum throughput | 4,000,000 |
:dev | Local development | 16,000 |
:prod | Production (default) | 500,000 |
:custom | Explicit settings | - |
Defaults & precedence
build/0uses the:prodprofile by default →token_budget_per_windowis500_000.- The base struct default (
32_000) is overridden by the selected profile. :customuses the base defaults unless you explicitly override fields.- Order of application: base defaults → profile → app config → per-call overrides.
Example Configuration
# Select a tier profile
config :gemini_ex, :rate_limiter, profile: :paid_tier_1
# Or customize specific settings
config :gemini_ex, :rate_limiter,
profile: :prod,
token_budget_per_window: 1_000_000,
max_concurrency_per_model: 8
# Disable token budgeting (not recommended)
config :gemini_ex, :rate_limiter,
token_budget_per_window: nil
Summary
Functions
Build a configuration struct from application config and overrides.
Check if concurrency gating is enabled.
Check if rate limiting is enabled.
Types
@type profile() ::
:dev
| :prod
| :custom
| :free_tier
| :paid_tier_1
| :paid_tier_2
| :paid_tier_3
@type t() :: %Gemini.RateLimiter.Config{ adaptive_ceiling: pos_integer(), adaptive_concurrency: boolean(), base_backoff_ms: pos_integer(), budget_safety_multiplier: float(), disable_rate_limiter: boolean(), jitter_factor: float(), max_attempts: pos_integer(), max_budget_wait_ms: pos_integer() | nil, max_concurrency_per_model: non_neg_integer() | nil, non_blocking: boolean(), permit_timeout_ms: pos_integer() | :infinity, profile: profile(), token_budget_per_window: non_neg_integer() | nil, window_duration_ms: pos_integer() }