For self-hosting, configure AI through environment variables in apps/web/.env.
If you used inbox-zero setup, many of these values are configured automatically.
Start here:
API keys require billing credits on the provider’s platform. A ChatGPT Plus or Claude Pro subscription does not include API access.
Providers
Use one of these provider values before the colon in *_LLMS entries:
Tiers
For most self-hosted setups, configure the default tier and optionally override cheaper or role-specific tiers:
DEFAULT_LLMS (required): normal AI tasks.
ECONOMY_LLMS (optional): lower-cost model for high-volume tasks. If unset, it falls back to default.
CHAT_LLMS (optional): assistant chat. If unset, it falls back to default.
DRAFT_LLMS (optional): reply drafting. If unset, it falls back to default.
NANO_LLMS (optional): lightweight classification and extraction. If unset, it falls back to economy/default behavior.
Each value is an ordered comma-separated list in provider:model format. The first valid entry is the primary model. Later valid entries are ordered fallbacks. Model names can contain colons; only the first colon separates the provider from the model.
Minimal example:
Provider-specific keys (for example OPENAI_API_KEY, ANTHROPIC_API_KEY) also work. See Environment Variables for the full list.
App Settings
The app also has Settings → AI for per-user keys/models, but self-hosted deployments usually keep configuration at the environment-variable level.
Sensitive Data Protection
Self-hosted deployments can choose how LLM requests handle sensitive data matches before they are sent to an AI provider. The current scanner targets likely credentials/tokens and payment-card-like numbers; it is not a full DLP or PHI classifier.
ALLOW preserves the default behavior. REDACT replaces matched values before the LLM request. BLOCK stops the request when a match is found. Leave NEXT_PUBLIC_SENSITIVE_DATA_POLICY_LOCKED=false to let users choose per account in Settings, or set it to true to enforce the deployment default for all accounts and hide the setting from the UI.
Decision Models
Some classification steps (rule selection, cold email detection, sender categorization, thread status) can use a decision model instead of an LLM. Decision models answer typed questions about structured state and return calibrated probabilities. They run through the AI SDK’s decision model interface, so switching models is a config change:
Use the same provider:model format as the *_LLMS variables. Supported providers are openrouter, aigateway, openai, and typesafe. Keys resolve the same way too: the provider’s key (OPENROUTER_API_KEY, AI_GATEWAY_API_KEY, or OPENAI_API_KEY), falling back to LLM_API_KEY. Direct TypeSafe always needs TYPESAFE_API_KEY.
The decision model receives the same email content as the LLM it replaces, with the same sensitive data policy applied. Users who set their own AI key are not enrolled by default. If a decision call fails, that step falls back to the configured LLM.
Provider-specific details
azure-foundry requires AZURE_FOUNDRY_API_KEY and AZURE_FOUNDRY_BASE_URL. Use the deployment name as the model portion of the azure-foundry:<deployment> entry.
cerebras uses CEREBRAS_API_KEY (or LLM_API_KEY) against https://api.cerebras.ai/v1. Example chat model: CHAT_LLMS=cerebras:qwen-3.8-27b.
openai-compatible also requires OPENAI_COMPATIBLE_BASE_URL. Set OPENAI_COMPATIBLE_AUTH_HEADER=api-key when the server expects an api-key header instead of bearer authorization. This can point at Cerebras (https://api.cerebras.ai/v1) if you do not want the dedicated provider, but then you cannot also use a local OpenAI-compatible server.
ollama can use OLLAMA_BASE_URL and OLLAMA_MODEL.
Fallbacks
Add fallbacks by adding more entries to the same role list:
Unsupported providers, entries without configured credentials, entries without models, and duplicates are skipped with warnings.
Legacy variables
The old DEFAULT_LLM_PROVIDER / DEFAULT_LLM_MODEL, role-specific *_LLM_PROVIDER / *_LLM_MODEL, and *_LLM_FALLBACKS variables are deprecated but still supported for existing deployments. At startup, they are converted into the corresponding *_LLMS value. New deployments and CLI-generated env files should use *_LLMS.
CLI LLM providers
codex-cli and claude-code are experimental self-host options. They use
third-party community AI SDK provider packages that spawn local CLI tools, so
they are disabled unless CLI_LLM_ENABLED=true.
Use them only on trusted self-hosted deployments. Review the provider package
source, pin exact package versions, and make sure you comply with the relevant
OpenAI or Anthropic terms for your authentication method.
Codex example:
Claude Code example: