Environment variables
Reference for the environment variables ai-cost-gate reads at startup.
Upstream providers
ai-cost-gate proxies to any OpenAI-compatible endpoint. For each provider you want to use, set the matching credential.
# OpenAI
UPSTREAM_OPENAI_API_KEY=sk-...
UPSTREAM_OPENAI_BASE=https://api.openai.com/v1
# Anthropic (via OpenAI-compatible adapter)
UPSTREAM_ANTHROPIC_API_KEY=sk-ant-...
UPSTREAM_ANTHROPIC_BASE=https://api.anthropic.com/v1
# DeepSeek, Volcano Engine, OpenRouter, or any other OpenAI-compatible endpoint
UPSTREAM_CUSTOM_BASE=https://api.example.com/v1
UPSTREAM_CUSTOM_API_KEY=...Database
DATABASE_URL=sqlite:///data/ai-cost-gate.dbA single SQLite file. The directory must be writable by the container. We recommend a Docker volume.
Admin
ADMIN_TOKEN=change-meRequired for the admin UI and /internal/* endpoints. Rotate this in production.
Server
LISTEN_HOST=0.0.0.0
LISTEN_PORT=3000
PROXY_PORT=8080Budgets (optional)
Defaults that apply when a request doesn't carry project-specific budget headers:
DEFAULT_PER_REQUEST_BUDGET_CENTS=100
DEFAULT_PER_PROJECT_BUDGET_CENTS=10000
DEFAULT_GLOBAL_BUDGET_CENTS=100000auto_stop is opt-in per project. See the dashboard for per-project budget configuration.
Logging
LOG_LEVEL=info
LOG_FORMAT=jsonLOG_LEVEL is one of debug, info, warn, error. LOG_FORMAT=json outputs structured logs suitable for shipping to Loki, CloudWatch, etc.
See also
- Deployment — running ai-cost-gate in production
- Project structure — where each env var is read