Docs/Operations

Operations

Configuration reference

Environment variables for ports, models, parsing, storage, and background jobs.
Updated 2026-07-22Applies to SAG v1.2.2

Compose provides working local defaults. Copy .env.example to .env only when you need custom ports, models, parsers, reliability settings, or production storage.

Network and runtime mode

VariableDefaultDescription
WEB_PORT3000Web port on the host
API_PORT8000API port on the host
BIND_ADDRESS127.0.0.1Listen address; configure perimeter protection before using 0.0.0.0 on a server
SAG_ENVIRONMENTdevUse prod in production
SAG_CORS_ORIGINShttp://localhost:3000Frontend origins allowed to call the API with credentials
NEXT_PUBLIC_API_BASEhttp://localhost:8000Build-time API address used by the browser
SAG_SECRET_KEYLocal development defaultJWT signing secret; replace in production
SAG_ALLOW_REGISTRATIONfalseWhether the traditional email registration endpoint is open

LLM

VariableDefaultDescription
SAG_LLM_PROVIDERopenaiLiteLLM provider identifier
SAG_LLM_BASE_URLhttps://api.302ai.cn/v1OpenAI-compatible endpoint; native providers may leave it empty
SAG_LLM_API_KEYEmptyModel key
SAG_LLM_MODELqwen3.6-flashServer-side model identifier
SAG_LLM_MAX_TOKENS20000Maximum generated tokens
SAG_LLM_TIMEOUT_MS60000Per-request timeout in milliseconds
SAG_LLM_MAX_RETRIES2Number of model-request retries

The UI and API start with an empty key, but event extraction, query understanding, precise-retrieval reranking, and answer generation remain unavailable.

Embedding

VariableDefaultDescription
SAG_EMBEDDING_MODELbge-large-en-v1.5Embedding model identifier
SAG_EMBEDDING_BASE_URLhttps://api.302ai.cn/v1Separate Embedding endpoint
SAG_EMBEDDING_API_KEYEmptySeparate key; application settings can reuse the LLM configuration

Embedding is required for document vectorization and fast retrieval. Existing vectors do not move automatically into the semantic space of a new model. Reprocess documents after changing models.

Parsing and chunking

VariableDefaultDescription
SAG_DOCUMENT_PARSERautoSelect MinerU or MarkItDown automatically
SAG_MINERU_BASE_URLhttps://api.302ai.cnMinerU service URL
SAG_MINERU_API_KEYEmptyMinerU key
SAG_MINERU_VERSION2.5MinerU version
SAG_DOCUMENT_EXTRACT_CONCURRENCY5Parallel extraction count
SAG_DOCUMENT_CHUNK_MAX_TOKENS1000Target upper bound for one chunk
SAG_DOCUMENT_CHUNK_MODEstandardChunking mode

Background jobs and engine

VariableDefaultDescription
SAG_JOB_MAX_ATTEMPTS3Maximum attempts for a background job
SAG_ENGINE_CACHE_SIZE16Engine-instance cache capacity
SAG_ENGINE_WARMUP_COUNT4Number of instances warmed on startup
SAG_MINERU_POLL_TIMEOUT300Optional MinerU polling timeout

PostgreSQL

VariableDefaultDescription
POSTGRES_USERsagDatabase user
POSTGRES_PASSWORDNoneRequired production override
POSTGRES_DBsagDatabase name

The production override also sets SAG_SAG_RELATIONAL_PROVIDER=postgres and SAG_SAG_VECTOR_PROVIDER=pgvector. Do not create a partial storage combination by overriding only one half in the default Compose setup.

Found an issue? Treat the public repository as the source of truth.View SAG source