Full environment variable reference for self-hosting Amarnai.
All configuration is done through environment variables in a single .env file at the monorepo root. For self-hosting, copy .env.selfhost.example as a starting point (.env.example is the local-development template and defaults to mock AI).
Redirect URI registered in Google Cloud Console (e.g. https://mail.yourdomain.com/api/gmail/callback)
TOKEN_ENCRYPTION_KEY
Yes
64-char hex string (32 bytes) for AES-256-GCM encryption of stored OAuth refresh tokens (Gmail + Outlook share it). No fallback; startup fails without it. openssl rand -hex 32
Setting MS_GRAPH_CLIENT_ID and MS_GRAPH_CLIENT_SECRET together enables the Outlook provider. See Prerequisites for the Microsoft Entra app registration.
Variable
Required
Description
MS_GRAPH_CLIENT_ID
For Outlook
Microsoft Entra confidential Web app client ID
MS_GRAPH_CLIENT_SECRET
For Outlook
Client secret for the same app registration
MS_GRAPH_TENANT
For Outlook
Authority/tenant. Use the literal common for multitenant + personal accounts (not a GUID). Default common
MS_GRAPH_SUBSCRIPTION_SECRET
For push
clientState echoed on every Graph change-notification so the webhook can verify it. openssl rand -hex 32
MS_GRAPH_NOTIFICATION_URL
For push
Public HTTPS URL Graph posts change notifications to (e.g. https://api.yourdomain.com/webhooks/outlook). Unset means polling-only
OUTLOOK_OAUTH_CALLBACK_URL
For Outlook
Redirect URI registered for the app (e.g. https://mail.yourdomain.com/api/outlook/callback)
Set AI_PROVIDER=frontier and EMBEDDING_PROVIDER=frontier for production. The default AI_PROVIDER=mock (with EMBEDDING_PROVIDER=mock) is for tests; ollama is for local development.
The recommended production configuration is Gemini through its OpenAI-compatible endpoint (cheap and free within Google's quota):
AI_PROVIDER=frontierFRONTIER_LLM_PROVIDER=geminiFRONTIER_LLM_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/FRONTIER_LLM_MODEL=gemini-2.5-flash-liteFRONTIER_LLM_API_KEY=<Google AI Studio key>EMBEDDING_PROVIDER=frontierFRONTIER_EMBEDDING_PROVIDER=geminiFRONTIER_EMBEDDING_MODEL=gemini-embedding-001FRONTIER_EMBEDDING_DIMENSIONS=768FRONTIER_EMBEDDING_API_KEY=<Google AI Studio key>
OpenAI (or any OpenAI-compatible endpoint) is a supported alternative: set FRONTIER_LLM_PROVIDER=openai, FRONTIER_LLM_MODEL=gpt-4o-mini, and for embeddings FRONTIER_EMBEDDING_PROVIDER=openai, FRONTIER_EMBEDDING_MODEL=text-embedding-3-small.
Variable
Default
Description
AI_PROVIDER
mock
frontier for production, ollama for local dev, mock for tests
FRONTIER_LLM_PROVIDER
openai
LLM backend: gemini, openai, or any OpenAI-compatible provider
FRONTIER_LLM_API_KEY
—
API key for the LLM provider
FRONTIER_LLM_MODEL
gpt-4o-mini
Model name (production: gemini-2.5-flash-lite)
FRONTIER_LLM_BASE_URL
—
Base URL for the provider. For Gemini: https://generativelanguage.googleapis.com/v1beta/openai/
ROUTING_LLM_MODEL
falls back to LLM model
Optional cheaper model for routing decisions
DRAFT_LLM_MODEL
falls back to LLM model
Optional model for draft generation
TAXONOMY_LLM_MODEL
falls back to LLM model
Optional model for taxonomy generation. Keep on a capable tier (the cheapest tiers are the most throttled)
EMBEDDING_PROVIDER
frontier
frontier for production, ollama for local dev, mock for tests
FRONTIER_EMBEDDING_PROVIDER
gemini
Embedding backend: gemini or any OpenAI-compatible provider
FRONTIER_EMBEDDING_API_KEY
—
API key for the embedding provider
FRONTIER_EMBEDDING_MODEL
gemini-embedding-001
Embedding model name (e.g. text-embedding-3-small for OpenAI)
FRONTIER_EMBEDDING_BASE_URL
—
Override base URL for OpenAI-compatible embedding endpoints
FRONTIER_EMBEDDING_DIMENSIONS
768
Output vector size. Use the same model and dimensions everywhere you embed