# ===================================================================== # DeepTutor Environment Template # ===================================================================== # Copy this file to `.env` and fill in your values. # # Sections: # 1. Ports # 2. LLM (required for chat) # 3. Embedding (required for knowledge base / RAG) # 4. Web Search (optional) # 5. Networking & Frontend (Docker / remote deployments) # 6. Security # 7. Authentication & Multi-User # 8. PocketBase sidecar (optional auth + storage) # 9. Storage / Attachments (optional) # # Only LLM_* are strictly required to start the app. Everything else has # sensible defaults — uncomment and set only what you actually need. # --------------------------------------------------------------------- # 1. Ports # --------------------------------------------------------------------- BACKEND_PORT=8001 FRONTEND_PORT=3782 # Used by docker-compose to expose the optional PocketBase sidecar. The # Python backend itself reaches PocketBase via POCKETBASE_URL below. POCKETBASE_PORT=8090 # --------------------------------------------------------------------- # 2. LLM (Required) # --------------------------------------------------------------------- # Supported bindings: openai, anthropic, deepseek, gemini, azure_openai, # lm_studio, ollama, vllm, openrouter, siliconflow, dashscope, ... # Full list: `deeptutor provider list`. LLM_BINDING=openai LLM_MODEL=gpt-4o-mini LLM_API_KEY=sk-xxx LLM_HOST=https://api.openai.com/v1 # Required for Azure OpenAI; leave blank otherwise. LLM_API_VERSION= # Optional: control reasoning / thinking effort. # DeepSeek: "high" or "max" enables thinking; "minimal" disables. # OpenAI o-series: "low", "medium", "high". # Leave empty to auto-detect from the model name. LLM_REASONING_EFFORT= # --------------------------------------------------------------------- # 3. Embedding (Required for knowledge base / RAG) # --------------------------------------------------------------------- # Supported bindings: openai, azure_openai, cohere, jina, ollama, vllm, # siliconflow, aliyun, gemini, custom. # # IMPORTANT (v1.3.0+): EMBEDDING_HOST is the FULL endpoint URL — it is # called verbatim, no path is appended. (LLM_HOST above remains a # chat-completions base URL.) Examples: # OpenAI: https://api.openai.com/v1/embeddings # Gemini: https://generativelanguage.googleapis.com/v1beta/openai/embeddings # Cohere v4: https://api.cohere.com/v2/embed # Jina: https://api.jina.ai/v1/embeddings # Ollama: http://localhost:11434/api/embed # SiliconFlow: https://api.siliconflow.cn/v1/embeddings # Aliyun: https://dashscope.aliyuncs.com/api/v1/services/embeddings/multimodal-embedding/multimodal-embedding EMBEDDING_BINDING=openai EMBEDDING_MODEL=text-embedding-3-large EMBEDDING_API_KEY=sk-xxx EMBEDDING_HOST=https://api.openai.com/v1/embeddings # Required for Azure embedding deployments; leave blank otherwise. EMBEDDING_API_VERSION= # Leave EMBEDDING_DIMENSION empty to let DeepTutor auto-fill it from the # provider's response on the first successful "Test connection". Override # only when you need to force a specific Matryoshka dim (e.g. Qwen3-Embedding # 1024/1536/2048/2560/4096, OpenAI text-embedding-3-large 3072). EMBEDDING_DIMENSION= # Whether to send the `dimensions` request parameter to the embedding endpoint: # true -> always send (OpenAI text-embedding-3*, Qwen3-Embedding, # Qwen3-VL-Embedding) # false -> never send (set this if your provider returns HTTP 400 # when `dimensions` is present) # / unset -> auto-detect from the model family. EMBEDDING_SEND_DIMENSIONS= # Per-provider API-key fallbacks. Used when the active embedding profile in # the catalog has no api_key set; the Settings UI also pre-fills these on # first launch so you don't have to retype them. SILICONFLOW_API_KEY= DASHSCOPE_API_KEY= COHERE_API_KEY= JINA_API_KEY= GEMINI_API_KEY= # ⚠️ Docker + local LLM (LM Studio / Ollama / vLLM) # ──────────────────────────────────────────────────────────────────── # When running DeepTutor in Docker and your LLM/embedding model runs on # the HOST machine: # - Do NOT use "localhost" or "127.0.0.1" — inside the container these # refer to the container itself, not the host. # - macOS / Windows Docker Desktop: # http://host.docker.internal:/v1 # - Linux: use the host's LAN IP (e.g. http://192.168.1.100:/v1) # or run Docker with --network=host. # # Example (LM Studio on port 1234): # LLM_BINDING=lm_studio # LLM_HOST=http://host.docker.internal:1234/v1 # EMBEDDING_BINDING=lm_studio # EMBEDDING_HOST=http://host.docker.internal:1234/v1/embeddings # --------------------------------------------------------------------- # 4. Web Search (Optional) # --------------------------------------------------------------------- # Providers: brave, tavily, serper, jina, perplexity, searxng, duckduckgo. SEARCH_PROVIDER= SEARCH_API_KEY= # Required for self-hosted SearXNG instances; optional override for other # providers that need an explicit base URL. SEARCH_BASE_URL= # Optional HTTP/HTTPS proxy for outbound search traffic. SEARCH_PROXY= # --------------------------------------------------------------------- # 5. Networking & Frontend (Docker / remote deployments) # --------------------------------------------------------------------- # Public backend URL the browser hits when the frontend is served from a # different host than the backend (cloud / remote-server deployments). NEXT_PUBLIC_API_BASE_EXTERNAL= # Alternative direct backend URL for the Next.js client when it differs # from http://localhost:${BACKEND_PORT}. Leave blank for the standard # local setup. NEXT_PUBLIC_API_BASE= # Optional extra origin appended to the FastAPI CORS allowlist (e.g. a # custom domain). localhost / 127.0.0.1 / Docker hosts are always allowed. CORS_ORIGIN= # --------------------------------------------------------------------- # 6. Security # --------------------------------------------------------------------- # Skip TLS verification for outbound HTTP. Keep this false in production — # only flip it on for local self-signed certs or air-gapped testing. DISABLE_SSL_VERIFY=false # --------------------------------------------------------------------- # 7. Authentication & Multi-User # --------------------------------------------------------------------- # Set AUTH_ENABLED=true to require login when hosting publicly. Leave as # false for local/localhost usage — no login needed. AUTH_ENABLED=false # JWT signing secret. If blank, DeepTutor creates and reuses a stable # local secret at multi-user/_system/auth/auth_secret. Set explicitly for # production (especially across multiple workers). Generate one with: # python -c "import secrets; print(secrets.token_hex(32))" AUTH_SECRET= # Login session lifetime in hours. AUTH_TOKEN_EXPIRE_HOURS=24 # Set to true when serving over HTTPS so the auth cookie is marked Secure. AUTH_COOKIE_SECURE=false # Optional frontend override. Leave blank to let the web app derive it # from AUTH_ENABLED — start_web.py already mirrors AUTH_ENABLED into this # variable for the Next.js middleware. NEXT_PUBLIC_AUTH_ENABLED= # --- Multi-user setup (recommended) --- # With AUTH_ENABLED=true and no AUTH_USERNAME / AUTH_PASSWORD_HASH set, # navigate to /register in the browser. The first user to register # automatically becomes admin and can manage other users from # /admin/users; the public /register endpoint closes itself after the # first admin exists. Users are stored in # multi-user/_system/auth/users.json. # --- Single-user env-var setup (legacy / simple) --- # Alternatively, set AUTH_USERNAME and AUTH_PASSWORD_HASH directly. This # user is always treated as admin. When multi-user/_system/auth/users.json # exists, it takes priority and these env vars are ignored. # Username for the single admin account (single-user mode only). AUTH_USERNAME= # Bcrypt hash of the password. Generate with: # python -c "from deeptutor.services.auth import hash_password; print(hash_password('yourpassword'))" AUTH_PASSWORD_HASH= # --------------------------------------------------------------------- # 8. PocketBase sidecar (Optional auth + storage) # --------------------------------------------------------------------- # Leave POCKETBASE_URL blank to use the built-in SQLite/JSON backend # (default). Set it to route auth, sessions, and KB storage through # PocketBase instead. # # When running via docker compose, PocketBase is always started; it is # only used by the backend if POCKETBASE_URL is set here. # # NOTE: PocketBase mode is currently SINGLE-USER ONLY. The default schema # has no `role` field on `users` (every login resolves to role=user, no # admin), and session/message/turn queries are not filtered by user_id. # Multi-user deployments must keep POCKETBASE_URL blank and use the # default JSON/SQLite backend. # # Local Docker: POCKETBASE_URL=http://pocketbase:8090 # Local bare: POCKETBASE_URL=http://localhost:8090 POCKETBASE_URL= # Admin credentials used by the Python backend to manage PocketBase # collections. Set these after creating your admin in the PocketBase UI. POCKETBASE_ADMIN_EMAIL= POCKETBASE_ADMIN_PASSWORD= # Public PocketBase URL for OAuth redirects (remote server deployments). # Leave blank when browsing from the same machine running Docker. POCKETBASE_EXTERNAL_URL= # --------------------------------------------------------------------- # 9. Storage / Attachments (Optional) # --------------------------------------------------------------------- # Where the chat turn runtime persists user-uploaded files (PDF, DOCX, # images, …) so the preview drawer can re-fetch the originals after the # in-memory base64 is dropped. # # Defaults to /data/user/workspace/chat/attachments, which is # already mounted as a volume in docker-compose.yml — leave blank for # the standard Docker / Linux deployment. Override only when running # multiple backend instances against shared storage (e.g. NFS). CHAT_ATTACHMENT_DIR=