Skip to content

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 ​

  1. .env files. The API reads backend/.env when it runs outside Docker. The Docker stack reads .env in the repository root. Environment variables of the process override both. Copy .env.example to start.
  2. Settings saved in the app. An admin can change about 40 of these settings on the Settings page. A saved value overrides .env from 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 ​

SettingDefaultAppWhat it does
LLM_BASE_URLhttp://localhost:1234/v1yesOpenAI-compatible chat endpoint, for example LM Studio
LLM_MODELlocal-modelyesChat model id the server knows, for example qwen/qwen3.6-35b-a3b
LLM_API_KEYlm-studioyesAPI key for the model server
LLM_TIMEOUT_SECONDS300yesTime limit per model call. A thinking draft can take minutes.
LLM_CONCURRENCY2yesModel 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{}yesPer-step changes to thinking and output length, for example {"draft.academic": {"thinking": false, "max_tokens": 6000}}
RUN_CONCURRENCY2yesAnswers running at once. Later ones queue and show their position.
EMBEDDING_MODELtext-embedding-qwen3-embedding-4byesEmbedding model id. Changing it means re-indexing everything.
EMBEDDING_DIMENSIONS2560noVector size. Must match the model. Fixed when the database is created.
EMBEDDING_BATCH_SIZE32yesTexts per embedding request
EMBEDDING_QUERY_PREFIXemptynoPrefix for queries. Empty picks one for the model family.
EMBEDDING_DOCUMENT_PREFIXemptynoPrefix for passages. Empty picks one for the model family.
EMBEDDING_QUERY_INSTRUCTIONa retrieval instructionnoTask instruction for instruction-tuned embedders
RERANKER_URLemptyyesllama.cpp server started with --reranking, for example http://127.0.0.1:5003/v1. Empty means no reranker.
RERANKER_MODELqwen3-reranker-0.6byesReranker model name, shown in Settings. The server decides which model runs.

Database and files ​

SettingDefaultAppWhat it does
DATABASE_URLpostgresql+psycopg://scholarlens:scholarlens@localhost:5002/scholarlensnoPostgres with pgvector. The stack builds it from POSTGRES_PASSWORD.
UPLOAD_DIR./data/uploadsnoWhere uploaded files are kept
MAX_UPLOAD_MB512yesLargest upload
FETCH_MAX_MB50noLargest file an import or web fetch downloads
FETCH_ALLOW_PRIVATEfalsenoDevelopment only: lets imports fetch localhost and LAN addresses

Ingestion ​

SettingDefaultAppWhat it does
CHUNK_SIZE1200noCharacters per chunk
CHUNK_OVERLAP200noCharacters repeated between neighbouring chunks
OCR_ENABLEDtruenoOCR for pages without a text layer
PARSE_TIMEOUT_SECONDS900noA parse that runs longer is stopped. 0 parses in-process (tests).
NODE_SUMMARIES_ENABLEDtrueyesWrite section summaries in the background after indexing
SUMMARY_BATCH_SIZE12noSections per summary job
WHISPER_MODELsmallnoLocal transcription model for videos without captions. Needs the optional whisper extra.
WHISPER_DEVICEcpunoDevice for transcription. CPU keeps the GPU free for the chat model.
WHISPER_MAX_MINUTES180noLongest video to transcribe

Answers and retrieval ​

SettingDefaultAppWhat it does
DEFAULT_STYLEsummaryyesStyle when a message doesn't choose: summary, comprehensive or academic
DEFAULT_TOP_K8yesPassages per search question
MAX_SUB_QUESTIONS4yesExtra search questions for Comprehensive and Academic answers
MAX_GENERATION_ATTEMPTS2noDrafts per answer: the first plus revisions after the claim check
MAX_GRAPH_STEPS24noStep limit for one run of the answer graph
EXECUTION_TIMEOUT_SECONDS300noTime limit for one Summary answer
DEEP_EXECUTION_TIMEOUT_SECONDS600noTime limit for one Comprehensive, Academic or Research answer
COVERAGE_MIN_SCORE0.3yesReranker score a search question's best passage needs to count as covered
EVIDENCE_MIN_SCORE0.1yesReranker score a passage needs to be used as evidence
EVIDENCE_TOKEN_BUDGET12000yesEvidence tokens sent to the drafting model
RETRIEVAL_DENSE_K30noCandidates from vector search
RETRIEVAL_LEXICAL_K30noCandidates from full-text search
RETRIEVAL_CANDIDATES40yesFused candidates passed to the reranker
DUPLICATE_THRESHOLD0.8yesHow alike (0-1) a new Library item must be to one already there to be flagged as a possible duplicate
RETRIEVAL_LEXICAL_WEIGHT0.25noWeight of a lexical rank against a dense rank in the fusion
RETRIEVAL_MMR_LAMBDA0.75noRelevance against variety when picking passages (1 = relevance only)
RETRIEVAL_NEIGHBOUR_RADIUS1noNeighbouring 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 ​

SettingDefaultAppWhat it does
WEB_SEARCH_ENABLEDfalseyesAllows web search at all. Each Space still chooses off, auto or always.
TAVILY_API_KEYemptyyesThe first web provider
TAVILY_MONTHLY_CREDITS1000yesTavily credits a month. Past it, SearXNG takes over.
SEARXNG_URLemptyyesSelf-hosted fallback, for example http://127.0.0.1:5008
WEB_SCHOLARLYtrueyesSearch OpenAlex and arXiv too
OPENALEX_MAILTOemptyyesContact e-mail for OpenAlex's polite pool
WEB_CACHE_HOURS24yesHow long search results are cached
MCP_BROWSER_URLemptyyesPlaywright MCP server for pages that need JavaScript, for example http://127.0.0.1:5005/mcp
MCP_TIMEOUT_SECONDS45noTime limit per browser page
SIGNIN_BROWSER_CDP_URLemptyyesDevTools endpoint of the sign-in browser, for example http://127.0.0.1:5006. Empty turns sign-in off.
SIGNIN_BROWSER_VNC127.0.0.1:5007yesHost and port of the sign-in browser's screen
SIGNIN_SESSION_MINUTES15yesAn open sign-in window closes after this long
ACCESS_GRANT_DAYS14yesHow long a saved sign-in is used
ACCESS_GRANT_KEYemptynoKey that seals saved sign-ins. Empty derives it from JWT_SECRET.

Code sandbox ​

SettingDefaultAppWhat it does
SANDBOX_URLemptyyesThe 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_TOKENemptyyesShared token. The sandbox must have the same one.
SANDBOX_CELL_SECONDS30yesTime limit per cell. The sandbox caps it at 120.
DEFAULT_CODE_POLICYautoyesCode policy of new Spaces: auto, ask or off

Accounts and security ​

SettingDefaultAppWhat it does
JWT_SECRETnonenoSigns sign-in tokens. At least 32 characters.
ACCESS_TOKEN_MINUTES15noLifetime of a sign-in token. It renews itself while you use the app.
REFRESH_TOKEN_DAYS30noHow long you stay signed in without using the app
COOKIE_SECUREfalsenoSet true when serving over HTTPS
CORS_ORIGINShttp://localhost:5021,http://127.0.0.1:5021 (the stack: port 5000)noBrowser origins allowed to call the API
ADMIN_USERNAMEemptynoCreates this admin on an empty database at start-up (headless install)
ADMIN_PASSWORDemptynoIts password, at least 6 characters
ALLOW_INSECURE_DEFAULTSfalsenoLets the API start with a weak secret. Throwaway experiments only.
LOGIN_MAX_FAILURES5noFailed sign-ins before the account locks
LOGIN_LOCKOUT_MINUTES15noHow long it stays locked
SELF_SIGNUP_ENABLEDfalseyesAnyone may register. An admin approves each account.
STORAGE_QUOTA_MB2048yesStorage per user. Admins are exempt.
DAILY_RUN_LIMIT200yesAnswers per user per day. 0 means no limit.
SETTINGS_KEYemptynoEncrypts 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 ​

SettingDefaultAppWhat it does
RUN_WORKER_IN_APItruenoRun the job worker inside the API. The stack sets false and runs a separate worker.
WORKER_POLL_SECONDS1.0noHow often the worker looks for jobs
JOB_MAX_ATTEMPTS3noTries before a job is marked failed
JOB_STALE_SECONDS120noA job whose worker stopped reporting is taken over after this long
STALE_EXECUTION_SECONDS30noA run with no heartbeat for this long is treated as cut off
RECOVERY_INTERVAL_SECONDS15noHow often the API looks for cut-off runs
MAX_RUN_RESUMES2noTimes a cut-off run resumes from its last finished step
CHECKPOINT_RETENTION_DAYS30noHow long a stopped (failed or timed-out) answer keeps its saved steps for Continue; a completed answer's go at once
WAITING_RUN_HOURS24noA run paused for the student gives up after this long
ATTACHMENT_WAIT_SECONDS300noHow long a question waits for its attachment to be indexed
EVENT_RETENTION_HOURS720noHow long run events are kept for replay

Logs and tracing ​

SettingDefaultAppWhat it does
LOG_FORMATtextnotext for people, json for one object per line
LOG_LEVELINFOnoDEBUG, INFO, WARNING or ERROR
LANGSMITH_TRACINGfalsenoSend traces to LangSmith
LANGSMITH_API_KEYemptynoLangSmith key
LANGSMITH_PROJECTscholar-lensnoLangSmith project name

Stack only ​

These are read by scholarlens-stack.yml, not by the API.

SettingDefaultWhat it does
POSTGRES_PASSWORDnoneDatabase password. Required.
BIND_ADDRESS127.0.0.1Address the API and UI ports bind to. Use 0.0.0.0 only on a trusted network.
BACKEND_PORT5001API port
FRONTEND_PORT5000UI port
POSTGRES_PORT5002Database port on the host
SANDBOX_RUNTIMErunscContainer runtime of the sandbox. runc only with SANDBOX_ALLOW_RUNC=true.
SANDBOX_ALLOW_RUNCfalseLets the sandbox start without gVisor. Development only.
SANDBOX_BRIDGE_PORT5009Host port of the Windows relay to the sandbox
SEARXNG_SECRETemptySearXNG's own secret
RERANKER_PORT, RERANKER_GPU_PORT, BROWSER_MCP_PORT, SIGNIN_CDP_PORT, SIGNIN_VNC_PORT, SEARXNG_PORT5003, 5004, 5005, 5006, 5007, 5008Host ports of the optional services
TTS_PORT, TTS_GPU_PORT5010, 5011Host ports of the voice services (Kokoro, Chatterbox)

For tools and tests, SETTINGS_FROM_DATABASE=false makes the API ignore settings saved in the app.