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
| Variable | Default | Description |
|---|---|---|
WEB_PORT | 3000 | Web port on the host |
API_PORT | 8000 | API port on the host |
BIND_ADDRESS | 127.0.0.1 | Listen address; configure perimeter protection before using 0.0.0.0 on a server |
SAG_ENVIRONMENT | dev | Use prod in production |
SAG_CORS_ORIGINS | http://localhost:3000 | Frontend origins allowed to call the API with credentials |
NEXT_PUBLIC_API_BASE | http://localhost:8000 | Build-time API address used by the browser |
SAG_SECRET_KEY | Local development default | JWT signing secret; replace in production |
SAG_ALLOW_REGISTRATION | false | Whether the traditional email registration endpoint is open |
LLM
| Variable | Default | Description |
|---|---|---|
SAG_LLM_PROVIDER | openai | LiteLLM provider identifier |
SAG_LLM_BASE_URL | https://api.302ai.cn/v1 | OpenAI-compatible endpoint; native providers may leave it empty |
SAG_LLM_API_KEY | Empty | Model key |
SAG_LLM_MODEL | qwen3.6-flash | Server-side model identifier |
SAG_LLM_MAX_TOKENS | 20000 | Maximum generated tokens |
SAG_LLM_TIMEOUT_MS | 60000 | Per-request timeout in milliseconds |
SAG_LLM_MAX_RETRIES | 2 | Number 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
| Variable | Default | Description |
|---|---|---|
SAG_EMBEDDING_MODEL | bge-large-en-v1.5 | Embedding model identifier |
SAG_EMBEDDING_BASE_URL | https://api.302ai.cn/v1 | Separate Embedding endpoint |
SAG_EMBEDDING_API_KEY | Empty | Separate 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
| Variable | Default | Description |
|---|---|---|
SAG_DOCUMENT_PARSER | auto | Select MinerU or MarkItDown automatically |
SAG_MINERU_BASE_URL | https://api.302ai.cn | MinerU service URL |
SAG_MINERU_API_KEY | Empty | MinerU key |
SAG_MINERU_VERSION | 2.5 | MinerU version |
SAG_DOCUMENT_EXTRACT_CONCURRENCY | 5 | Parallel extraction count |
SAG_DOCUMENT_CHUNK_MAX_TOKENS | 1000 | Target upper bound for one chunk |
SAG_DOCUMENT_CHUNK_MODE | standard | Chunking mode |
Background jobs and engine
| Variable | Default | Description |
|---|---|---|
SAG_JOB_MAX_ATTEMPTS | 3 | Maximum attempts for a background job |
SAG_ENGINE_CACHE_SIZE | 16 | Engine-instance cache capacity |
SAG_ENGINE_WARMUP_COUNT | 4 | Number of instances warmed on startup |
SAG_MINERU_POLL_TIMEOUT | 300 | Optional MinerU polling timeout |
PostgreSQL
| Variable | Default | Description |
|---|---|---|
POSTGRES_USER | sag | Database user |
POSTGRES_PASSWORD | None | Required production override |
POSTGRES_DB | sag | Database 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