Skip to content

Environment Variables ​

Environment variables are read once at startup from the process environment and a .env file in the current working directory. Changing them requires a restart. Runtime settings (providers, models, limits, logging policy, and security thresholds) are configured in the admin console and hot-reloaded without a restart.

User-facing ​

VariableDefaultEffect
DATABASE_URLunsetFull database URL. Takes precedence over LLM_PROXY_DB_PATH. postgresql:// is rewritten to postgresql+asyncpg://
LLM_PROXY_DB_PATHplatform data dir + config.dbSQLite file path (used only when DATABASE_URL is unset)
JWT_SECRETauto-generatedJWT signing secret override; ignored if shorter than 32 chars. Changing it invalidates all sessions
ENCRYPTION_KEYauto-generatedProvider-key encryption override; ignored if shorter than 32 chars. Changing it makes existing stored provider keys undecryptable
LOG_LEVELINFOApplication log level; --log-level overrides
TRUSTED_PROXIESRFC1918 + loopback + link-local rangesCIDR list allowed to set X-Forwarded-For and X-Real-IP. Replaces the default list; empty trusts nobody; invalid CIDR fails startup
REDIS_ENABLEDfalseMaster Redis switch; when false, rate limiting stays in-memory and config caching is off
REDIS_URLredis://localhost:6379Redis connection URL
REDIS_RATE_LIMIT_ENABLEDfalseRedis-backed sliding-window rate limiting (requires REDIS_ENABLED=true)
REDIS_CACHE_ENABLEDfalseRedis cache for provider and model config lookups
REDIS_LOGGING_ENABLEDfalseReserved; no effect. Logs are always stored in the SQL database
UVICORN_WORKERSautoUvicorn worker count. Unset uses cgroup-aware CPU count capped at 16 on PostgreSQL, and always 1 on SQLite. --workers overrides
UVICORN_TIMEOUT_KEEPALIVE600Keep-alive timeout in seconds
UPDATE_CHECK__ENABLEDtrueDouble underscore. Controls whether /api/system/info checks GitHub for newer releases

Advanced ​

Connection pools, timeouts, and background writer tuning. Change only when needed.

VariableDefaultEffect
HTTP_MAX_CONNECTIONS200Outbound HTTP connection pool size for provider calls
HTTP_MAX_KEEPALIVE200Outbound HTTP keep-alive pool size
HTTP_DISABLE_HTTP2trueDisables HTTP/2 on outbound provider calls by default
HTTP_CLIENT_BACKENDautoOutbound HTTP backend: auto, httpx2, or aiohttp. auto selects aiohttp unless an outbound proxy (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) is configured, in which case it uses httpx2
HTTP_ALLOWED_HOSTSemptyComma-separated hosts exempt from the SSRF private-address ban, for self-hosted providers on private networks and internal image hosts. Every entry weakens SSRF protection
HTTP_MAX_DOWNLOAD_BYTES20971520 (20 MiB)Maximum size buffered for a client-supplied image or file URL, enforced while streaming. Matches the 20 MB per-image ceiling of OpenAI and Gemini (Anthropic is 5 MB)
HTTP_MAX_REQUEST_DOWNLOAD_BYTES67108864 (64 MiB)Total inlined media a single request may retain across all URLs it references (matches the request body limit). Peak memory per request is this total plus at most four in-flight downloads
HTTP_MAX_RESPONSE_BYTES67108864 (64 MiB)Maximum buffered upstream response size. Larger responses fail with 502
DB_POOL_SIZEmin((cpu_count * 2 + 1) / workers, 80 / (2 * workers)), min 1PostgreSQL pool size per worker process (ignored for SQLite). The second bound caps total connections around 80 (overflow defaults to pool size) so workers do not exhaust max_connections. The DB_POOL_SIZE=10 and DB_MAX_OVERFLOW=10 lines in .env.example are examples, not defaults
DB_MAX_OVERFLOWsame as pool sizePostgreSQL overflow connections per worker
DB_POOL_RECYCLE_SECONDS3600 (min 60)PostgreSQL connection recycle interval in seconds
DB_POOL_TIMEOUT_SECONDS30 (min 1)PostgreSQL pool checkout timeout in seconds
REDIS_POOL_SIZE10Redis connection pool size
REDIS_TIMEOUT5.0Redis socket and connect timeout in seconds
REDIS_RATE_LIMIT_PREFIXrate_limit:Rate-limit key prefix
REDIS_CACHE_PREFIXcache:Config-cache key prefix
REDIS_CACHE_TTL_PROVIDER_CONFIG300Provider-config cache TTL in seconds
REDIS_CACHE_TTL_MODEL_MAPPING300Model-mapping cache TTL in seconds
REDIS_LOGGING_PREFIX / _TTL_DAYS / _BATCH_SIZE / _FLUSH_INTERVAL_MSlogs: / 30 / 50 / 250Reserved; no effect
LOG_WRITE_QUEUE_SIZE2000Request-log writer queue depth; records are dropped when full
LOG_WRITE_BATCH_SIZE100Request-log batch size
LOG_WRITE_FLUSH_INTERVAL_MS500Request-log flush interval in milliseconds
USAGE_WRITE_QUEUE_SIZE2000Usage writer queue depth
USAGE_WRITE_BATCH_SIZE200Usage batch size
USAGE_WRITE_FLUSH_INTERVAL_MS500Usage flush interval in milliseconds

Not configurable here ​

These settings are stored in the database and managed from the admin console so changes apply without a restart:

  • Logging policy: retention, body logging, raw stream capture, masking, sampling, sensitive keys
  • Security: lockout thresholds, HSTS, request body size, auth failure delay, rate-limit buckets
  • Network behavior: CORS origins, response keepalive
  • Features: web search, smart routing, provider selection strategy, retry/fallback, circuit breaker, MCP security policy
  • Providers, models, pricing, API keys, users, and MCP servers

.env.example ​

The repository includes a commented .env.example covering every variable above, plus TRUSTED_PROXIES examples for Docker/Traefik and Cloudflare.

Reserved (do not set) ​

LLM_PROXY_LOG_LEVEL, LLM_PROXY_LOG_FILE, and LLM_PROXY_WORKER_COUNT are set by the server launcher before starting uvicorn so worker processes inherit the resolved values. Use LOG_LEVEL, --log-level, --log-file, and --workers instead; values set directly in the environment are overwritten at startup.

MIT licensed