# agg2api configuration. # # Copy to `.env` and set the token. Every variable is optional except # AGG2API_ADMIN_TOKEN, which is REQUIRED whenever AGG2API_HOST is not a loopback # address — the gateway refuses to start without it rather than expose an # unauthenticated admin API that hands out provider credentials. # # The prefix is AGG2API_ plus the config.example.json key, uppercased. # Bearer token for /admin/*. Generate one: # openssl rand -hex 32 AGG2API_ADMIN_TOKEN=change-me # Listen address. 0.0.0.0 inside a container is required for the published port to # reach the process; the compose file binds it to host loopback. AGG2API_HOST=0.0.0.0 AGG2API_PORT=8787 # SQLite file. Keep this inside the mounted volume, or every restart loses your # providers, routes and keys. AGG2API_DB_PATH=/app/data/agg2api.db # Require a client key on /v1. Create keys under Admin → API keys first, then flip # this on; otherwise every request starts returning 401. AGG2API_REQUIRE_CLIENT_KEY=false # Routing default for models whose route does not name one. AGG2API_DEFAULT_STRATEGY=priority # Upstream deadline per attempt (ms). Lower it for interactive use. AGG2API_REQUEST_TIMEOUT_MS=300000 # Model/credit refresh cadence (seconds). 0 disables the background pass. AGG2API_DISCOVERY_INTERVAL_S=3600 # Usage retention. 0 keeps everything and lets the database grow without bound. AGG2API_LOG_RETENTION_DAYS=30 # Session→provider pin lifetime (ms) for cache affinity; 0 disables it. AGG2API_SESSION_TTL_MS=1800000 AGG2API_SESSION_MAX_ENTRIES=10000 # Circuit breaker cooldown bounds. A provider that fails is skipped for # min(BASE * 2^failures, MAX) — 5s, 10s, 20s, ... capped at 5min. # # NOTE: FAILURE_THRESHOLD is currently only an on/off switch: any value > 0 enables the # breaker, any value <= 0 disables it. A single failure removes the provider for the whole # cooldown. The number is NOT compared against a failure count yet. AGG2API_BREAKER_FAILURE_THRESHOLD=3 AGG2API_BREAKER_COOLDOWN_BASE_MS=5000 AGG2API_BREAKER_COOLDOWN_MAX_MS=300000