Skip to content

Environment variables

The gateway reads environment variables at startup and at request time. None of them accept runtime overrides via HTTP; restart required to change.

Required for production

Name Source Notes
SMART_GATEWAY_API_KEY .env.production The bearer token accepted from clients. Length > 10 enforced. Note: the value is not cryptographically verified against an allowlist in v1.0.0.
OPENROUTER_API_KEY .env.production OpenRouter API key. Server-side only. Never sent to clients.
OPENROUTER_BASE_URL .env.production Defaults to https://openrouter.ai/api/v1.

Optional / defaults

Name Default Notes
MODEL_GATEWAY_BACKEND openrouter openrouter or litellm. v1.0.0 uses openrouter exclusively.
LITELLM_BASE_URL http://litellm:4000/v1 Only used if MODEL_GATEWAY_BACKEND=litellm.
LITELLM_MASTER_KEY unset Only used if MODEL_GATEWAY_BACKEND=litellm.
POSTGRES_USER sgwproduction PostgreSQL user (production compose).
POSTGRES_PASSWORD required PostgreSQL password.
POSTGRES_DB sgwproduction PostgreSQL database.
DATABASE_URL derived postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@db:5432/$POSTGRES_DB.
LOG_LEVEL INFO INFO, WARNING, ERROR.
ALLOW_FREE_MODEL_FOR_PRIVATE_REPOS false Operator-standing policy. Flipping requires a privacy review.
ROUTING_POLICY_PATH frozen-v3/config/routing-policy.yaml Override path inside the container.
MODELS_CONFIG_PATH frozen-v3/config/models.yaml Override path inside the container.
LITELLM_IMAGE ghcr.io/berriai/litellm:main-latest DEV ONLY. Must be pinned before any production use.
RELEASE_SHA set by deploy Commit SHA of the deployed build.
RELEASE_TAG set by deploy Tag name. Empty for ad-hoc builds.

What is never read from environment

  • The model field in a request — always parsed from JSON body.
  • The OpenRouter completion ID — generated by OpenRouter.
  • Routing policy thresholds — they live in routing-policy.yaml, not in env vars.

Filesystem layout

/srv/apps/smart-supervisor-production/
├── .env.production         # 0600 root:root
├── docker-compose.production.yml
├── Dockerfile
└── frozen-v3/
    └── config/
        ├── routing-policy.yaml
        └── models.yaml

The container mounts frozen-v3/config/ read-only into /app/config/ (see docker-compose.production.yml::volumes).

How to read the running configuration

The structured log line at startup includes the active freeze ID:

docker logs smart-supervisor-production-gateway-1 | grep freeze

A 403 from the privacy gate is a sign that the active policy has free_model_fail_closed: true (the v1.0.0 default). A 200 on a sensitive request to smart-router-free is a sign that the registry's allow_sensitive flag was changed for Nemotron — that should never happen, and if it does, treat it as a security incident.

See also

  • Reference → Configuration.
  • env.production.template — the canonical template.
  • docs-internal/operations/secret-rotation.md — how to change credentials safely.