ChatAI Docs

Environment reference

Full environment variable reference for ChatAI self-hosting and development.

Copy .env.example to .env and fill in values. Docker Compose loads .env for the app service and overrides DATABASE_URL / BETTER_AUTH_URL / UPLOAD_DIR as needed.

Core

VariableRequiredDefault / examplePurpose
DATABASE_URLYes (runtime)postgresql://chatai:chatai@localhost:5432/chataiPooled or direct Postgres URL for the app
DATABASE_URL_UNPOOLEDNeon migrationsDirect (non-pooler) Neon URL for migrations
BETTER_AUTH_SECRETYesAuth signing secret (min 16 chars)
BETTER_AUTH_URLYeshttp://localhost:3000Public origin browsers use for this instance
UPLOAD_DIRNo./uploads (Docker: /app/uploads)File upload storage
SEED_DEMO_ON_STARTNoWhen 1, Docker entrypoint seeds demo user after health (dev/demo only)
SEED_DEMO_EMAIL / SEED_DEMO_PASSWORDNodemo@chatai.local / DemoPass123!Overrides for demo seed

Auth (optional)

VariablePurpose
GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRETEnable GitHub OAuth; leave blank to disable
RESEND_API_KEYSend password-reset emails via Resend. Without it, reset links are logged to the server console
EMAIL_FROMFrom address for Resend (e.g. ChatAI <noreply@yourdomain.com>; defaults to Resend sandbox from-address)

Chat providers

VariablePurpose
AI_PROVIDERopenai, openai-compatible, anthropic, google, openrouter, azure, ollama, groq
AI_API_KEYDefault OpenAI-compatible key; Ollama accepts a placeholder like ollama
AI_BASE_URLOpenAI-compatible base URL (default https://api.openai.com/v1)
AI_MODELDefault chat model (e.g. gpt-4o-mini, llama3.2)
OLLAMA_BASE_URLOllama OpenAI-compatible endpoint (Compose: http://ollama:11434/v1)
ANTHROPIC_API_KEYAnthropic
GOOGLE_GENERATIVE_AI_API_KEYGoogle Gemini
OPENROUTER_API_KEYOpenRouter
GROQ_API_KEYGroq
AZURE_OPENAI_API_KEY / AZURE_OPENAI_RESOURCEAzure OpenAI

Missing credentials for the selected provider return 503 (provider X is not configured on this instance).

Embeddings

VariableDefaultPurpose
EMBEDDING_PROVIDERopenaiopenai, openai-compatible, cohere, voyage
EMBEDDING_MODELtext-embedding-3-smallEmbedding model id
EMBEDDING_DIMENSIONS1536Must match chunks.embedding (vector(1536))
VOYAGE_API_KEYVoyage embeddings
COHERE_API_KEYCohere embeddings and optional rerank

Changing embedding width on an existing database requires a full reprocess strategy; the column width is fixed in schema migrations today.

Rate limits and quality

VariableDefaultPurpose
API_RATE_LIMIT_PER_MINUTE60Per-API-key REST limit (widget publicId chat is not limited here)
COHERE_API_KEYPrefer Cohere rerank when set

Ollama Compose profile

See Local models (Ollama). Summary:

  • Profile: docker compose --profile local-models up
  • Prefer hybrid: Ollama for chat, 1536-d embeddings elsewhere
  • Fully local nomic-embed-text (768-d) is not compatible with vector(1536) yet

Playwright e2e (local / CI)

VariablePurpose
E2E_EMAIL / E2E_PASSWORDSeeded e2e user (pnpm e2e:seed)
E2E_ASSISTANT_IDSeeded assistant public id
E2E_BASE_URLApp origin under test

Do not commit .env.e2e.