Configuration reference
Every setting Scholar Lens reads from its environment, with its default. This page is for whoever installs and runs the server.
Where settings come from
.envfiles. The API readsbackend/.envwhen it runs outside Docker. The Docker stack reads.envin the repository root. Environment variables of the process override both. Copy.env.exampleto start.- Settings saved in the app. An admin can change about 40 of these settings on the Settings page. A saved value overrides
.envfrom the next API restart. Those settings are marked App below. See Settings, users and quality.
Names are case-insensitive. Lists and objects are written as JSON.
IMPORTANT
JWT_SECRET must be at least 32 characters. The API refuses to start with a short or default secret. Generate one with openssl rand -hex 32.
Models
| Setting | Default | App | What it does |
|---|---|---|---|
LLM_BASE_URL | http://localhost:1234/v1 | yes | OpenAI-compatible chat endpoint, for example LM Studio |
LLM_MODEL | local-model | yes | Chat model id the server knows, for example qwen/qwen3.6-35b-a3b |
LLM_API_KEY | lm-studio | yes | API key for the model server |
LLM_TIMEOUT_SECONDS | 300 | yes | Time limit per model call. A thinking draft can take minutes. |
LLM_CONCURRENCY | 2 | yes | Model calls in flight at once. Match LM Studio's parallel slots. Others wait in priority order: answers, then checks, then background work. |
LLM_PRESET_OVERRIDES | {} | yes | Per-step changes to thinking and output length, for example {"draft.academic": {"thinking": false, "max_tokens": 6000}} |
RUN_CONCURRENCY | 2 | yes | Answers running at once. Later ones queue and show their position. |
EMBEDDING_MODEL | text-embedding-qwen3-embedding-4b | yes | Embedding model id. Changing it means re-indexing everything. |
EMBEDDING_DIMENSIONS | 2560 | no | Vector size. Must match the model. Fixed when the database is created. |
EMBEDDING_BATCH_SIZE | 32 | yes | Texts per embedding request |
EMBEDDING_QUERY_PREFIX | empty | no | Prefix for queries. Empty picks one for the model family. |
EMBEDDING_DOCUMENT_PREFIX | empty | no | Prefix for passages. Empty picks one for the model family. |
EMBEDDING_QUERY_INSTRUCTION | a retrieval instruction | no | Task instruction for instruction-tuned embedders |
RERANKER_URL | empty | yes | llama.cpp server started with --reranking, for example http://127.0.0.1:5003/v1. Empty means no reranker. |
RERANKER_MODEL | qwen3-reranker-0.6b | yes | Reranker model name, shown in Settings. The server decides which model runs. |
Database and files
| Setting | Default | App | What it does |
|---|---|---|---|
DATABASE_URL | postgresql+psycopg://scholarlens:scholarlens@localhost:5002/scholarlens | no | Postgres with pgvector. The stack builds it from POSTGRES_PASSWORD. |
UPLOAD_DIR | ./data/uploads | no | Where uploaded files are kept |
MAX_UPLOAD_MB | 512 | yes | Largest upload |
FETCH_MAX_MB | 50 | no | Largest file an import or web fetch downloads |
FETCH_ALLOW_PRIVATE | false | no | Development only: lets imports fetch localhost and LAN addresses |
Ingestion
| Setting | Default | App | What it does |
|---|---|---|---|
CHUNK_SIZE | 1200 | no | Characters per chunk |
CHUNK_OVERLAP | 200 | no | Characters repeated between neighbouring chunks |
OCR_ENABLED | true | no | OCR for pages without a text layer |
PARSE_TIMEOUT_SECONDS | 900 | no | A parse that runs longer is stopped. 0 parses in-process (tests). |
NODE_SUMMARIES_ENABLED | true | yes | Write section summaries in the background after indexing |
SUMMARY_BATCH_SIZE | 12 | no | Sections per summary job |
WHISPER_MODEL | small | no | Local transcription model for videos without captions. Needs the optional whisper extra. |
WHISPER_DEVICE | cpu | no | Device for transcription. CPU keeps the GPU free for the chat model. |
WHISPER_MAX_MINUTES | 180 | no | Longest video to transcribe |
Answers and retrieval
| Setting | Default | App | What it does |
|---|---|---|---|
DEFAULT_STYLE | summary | yes | Style when a message doesn't choose: summary, comprehensive or academic |
DEFAULT_TOP_K | 8 | yes | Passages per search question |
MAX_SUB_QUESTIONS | 4 | yes | Extra search questions for Comprehensive and Academic answers |
MAX_GENERATION_ATTEMPTS | 2 | no | Drafts per answer: the first plus revisions after the claim check |
MAX_GRAPH_STEPS | 24 | no | Step limit for one run of the answer graph |
EXECUTION_TIMEOUT_SECONDS | 300 | no | Time limit for one Summary answer |
DEEP_EXECUTION_TIMEOUT_SECONDS | 600 | no | Time limit for one Comprehensive, Academic or Research answer |
COVERAGE_MIN_SCORE | 0.3 | yes | Reranker score a search question's best passage needs to count as covered |
EVIDENCE_MIN_SCORE | 0.1 | yes | Reranker score a passage needs to be used as evidence |
EVIDENCE_TOKEN_BUDGET | 12000 | yes | Evidence tokens sent to the drafting model |
RETRIEVAL_DENSE_K | 30 | no | Candidates from vector search |
RETRIEVAL_LEXICAL_K | 30 | no | Candidates from full-text search |
RETRIEVAL_CANDIDATES | 40 | yes | Fused candidates passed to the reranker |
DUPLICATE_THRESHOLD | 0.8 | yes | How alike (0-1) a new Library item must be to one already there to be flagged as a possible duplicate |
RETRIEVAL_LEXICAL_WEIGHT | 0.25 | no | Weight of a lexical rank against a dense rank in the fusion |
RETRIEVAL_MMR_LAMBDA | 0.75 | no | Relevance against variety when picking passages (1 = relevance only) |
RETRIEVAL_NEIGHBOUR_RADIUS | 1 | no | Neighbouring chunks added around each passage as context |
The coverage and evidence thresholds apply only with a reranker. Without one, fused scores are only relative.
Web research
| Setting | Default | App | What it does |
|---|---|---|---|
WEB_SEARCH_ENABLED | false | yes | Allows web search at all. Each Space still chooses off, auto or always. |
TAVILY_API_KEY | empty | yes | The first web provider |
TAVILY_MONTHLY_CREDITS | 1000 | yes | Tavily credits a month. Past it, SearXNG takes over. |
SEARXNG_URL | empty | yes | Self-hosted fallback, for example http://127.0.0.1:5008 |
WEB_SCHOLARLY | true | yes | Search OpenAlex and arXiv too |
OPENALEX_MAILTO | empty | yes | Contact e-mail for OpenAlex's polite pool |
WEB_CACHE_HOURS | 24 | yes | How long search results are cached |
MCP_BROWSER_URL | empty | yes | Playwright MCP server for pages that need JavaScript, for example http://127.0.0.1:5005/mcp |
MCP_TIMEOUT_SECONDS | 45 | no | Time limit per browser page |
SIGNIN_BROWSER_CDP_URL | empty | yes | DevTools endpoint of the sign-in browser, for example http://127.0.0.1:5006. Empty turns sign-in off. |
SIGNIN_BROWSER_VNC | 127.0.0.1:5007 | yes | Host and port of the sign-in browser's screen |
SIGNIN_SESSION_MINUTES | 15 | yes | An open sign-in window closes after this long |
ACCESS_GRANT_DAYS | 14 | yes | How long a saved sign-in is used |
ACCESS_GRANT_KEY | empty | no | Key that seals saved sign-ins. Empty derives it from JWT_SECRET. |
Code sandbox
| Setting | Default | App | What it does |
|---|---|---|---|
SANDBOX_URL | empty | yes | The sandbox: http://sandbox:5009 in the stack, http://172.31.250.10:5009 from the Linux host, http://127.0.0.1:5009 through the Windows relay. Empty means no code. |
SANDBOX_TOKEN | empty | yes | Shared token. The sandbox must have the same one. |
SANDBOX_CELL_SECONDS | 30 | yes | Time limit per cell. The sandbox caps it at 120. |
DEFAULT_CODE_POLICY | auto | yes | Code policy of new Spaces: auto, ask or off |
Accounts and security
| Setting | Default | App | What it does |
|---|---|---|---|
JWT_SECRET | none | no | Signs sign-in tokens. At least 32 characters. |
ACCESS_TOKEN_MINUTES | 15 | no | Lifetime of a sign-in token. It renews itself while you use the app. |
REFRESH_TOKEN_DAYS | 30 | no | How long you stay signed in without using the app |
COOKIE_SECURE | false | no | Set true when serving over HTTPS |
CORS_ORIGINS | http://localhost:5021,http://127.0.0.1:5021 (the stack: port 5000) | no | Browser origins allowed to call the API |
ADMIN_USERNAME | empty | no | Creates this admin on an empty database at start-up (headless install) |
ADMIN_PASSWORD | empty | no | Its password, at least 6 characters |
ALLOW_INSECURE_DEFAULTS | false | no | Lets the API start with a weak secret. Throwaway experiments only. |
LOGIN_MAX_FAILURES | 5 | no | Failed sign-ins before the account locks |
LOGIN_LOCKOUT_MINUTES | 15 | no | How long it stays locked |
SELF_SIGNUP_ENABLED | false | yes | Anyone may register. An admin approves each account. |
STORAGE_QUOTA_MB | 2048 | yes | Storage per user. Admins are exempt. |
DAILY_RUN_LIMIT | 200 | yes | Answers per user per day. 0 means no limit. |
SETTINGS_KEY | empty | no | Encrypts secrets saved in the app. Empty derives it from JWT_SECRET. |
WARNING
If SETTINGS_KEY or ACCESS_GRANT_KEY is empty, changing JWT_SECRET makes the saved secrets and sign-ins unreadable. Keep a copy of these keys with your backups.
Runs and jobs
| Setting | Default | App | What it does |
|---|---|---|---|
RUN_WORKER_IN_API | true | no | Run the job worker inside the API. The stack sets false and runs a separate worker. |
WORKER_POLL_SECONDS | 1.0 | no | How often the worker looks for jobs |
JOB_MAX_ATTEMPTS | 3 | no | Tries before a job is marked failed |
JOB_STALE_SECONDS | 120 | no | A job whose worker stopped reporting is taken over after this long |
STALE_EXECUTION_SECONDS | 30 | no | A run with no heartbeat for this long is treated as cut off |
RECOVERY_INTERVAL_SECONDS | 15 | no | How often the API looks for cut-off runs |
MAX_RUN_RESUMES | 2 | no | Times a cut-off run resumes from its last finished step |
CHECKPOINT_RETENTION_DAYS | 30 | no | How long a stopped (failed or timed-out) answer keeps its saved steps for Continue; a completed answer's go at once |
WAITING_RUN_HOURS | 24 | no | A run paused for the student gives up after this long |
ATTACHMENT_WAIT_SECONDS | 300 | no | How long a question waits for its attachment to be indexed |
EVENT_RETENTION_HOURS | 720 | no | How long run events are kept for replay |
Logs and tracing
| Setting | Default | App | What it does |
|---|---|---|---|
LOG_FORMAT | text | no | text for people, json for one object per line |
LOG_LEVEL | INFO | no | DEBUG, INFO, WARNING or ERROR |
LANGSMITH_TRACING | false | no | Send traces to LangSmith |
LANGSMITH_API_KEY | empty | no | LangSmith key |
LANGSMITH_PROJECT | scholar-lens | no | LangSmith project name |
Stack only
These are read by scholarlens-stack.yml, not by the API.
| Setting | Default | What it does |
|---|---|---|
POSTGRES_PASSWORD | none | Database password. Required. |
BIND_ADDRESS | 127.0.0.1 | Address the API and UI ports bind to. Use 0.0.0.0 only on a trusted network. |
BACKEND_PORT | 5001 | API port |
FRONTEND_PORT | 5000 | UI port |
POSTGRES_PORT | 5002 | Database port on the host |
SANDBOX_RUNTIME | runsc | Container runtime of the sandbox. runc only with SANDBOX_ALLOW_RUNC=true. |
SANDBOX_ALLOW_RUNC | false | Lets the sandbox start without gVisor. Development only. |
SANDBOX_BRIDGE_PORT | 5009 | Host port of the Windows relay to the sandbox |
SEARXNG_SECRET | empty | SearXNG's own secret |
RERANKER_PORT, RERANKER_GPU_PORT, BROWSER_MCP_PORT, SIGNIN_CDP_PORT, SIGNIN_VNC_PORT, SEARXNG_PORT | 5003, 5004, 5005, 5006, 5007, 5008 | Host ports of the optional services |
TTS_PORT, TTS_GPU_PORT | 5010, 5011 | Host ports of the voice services (Kokoro, Chatterbox) |
For tools and tests, SETTINGS_FROM_DATABASE=false makes the API ignore settings saved in the app.