Skip to main content

Configuration

The complete non-embeddings environment reference for the RAG API — server, authentication, vector database (pgvector and MongoDB Atlas), chunking, batching, document processing, logging, and proxy settings.

The RAG API is configured entirely through environment variables, set in config/.env under the same names the container reads (documented below). This page covers everything except the embeddings-provider settings, which have their own Embeddings providers page.

Server

NamePurposeDefaultRequired
RAG_HOSTBind address for the FastAPI server0.0.0.0No
RAG_PORTPort for the FastAPI server8000No
RAG_UPLOAD_DIRDirectory for uploaded files awaiting processing./uploads/No
RAG_THREAD_POOL_SIZEWorker threads for CPU-bound sync work (parsing, embeddings)min(cpu_count, 8)No

The server exposes GET /health, GET /docs, and GET /openapi.json without authentication; all other routes require a JWT when JWT_SECRET is set.

Authentication

NamePurposeDefaultRequired
JWT_SECRETSecret used to verify HS256 bearer tokens(unset)No

Set JWT_SECRET in production

If JWT_SECRET is unset, the API runs without authentication — any client that can reach it can index or query documents. In the stack, set it to the same secret the IntelliAsk app uses to sign RAG requests. All routes except /health, /docs, and /openapi.json then require an Authorization: Bearer <token> header.

Vector database

The RAG API supports two vector backends, selected by VECTOR_DB_TYPE.

NamePurposeDefaultRequired
VECTOR_DB_TYPEBackend: pgvector or atlas-mongopgvectorNo

PostgreSQL + pgvector (default)

NamePurposeDefaultRequired
DB_HOSTPostgreSQL host (or socket path if using Unix sockets)dbNo
DB_PORTPostgreSQL port5432No
POSTGRES_DBDatabase name (must have the pgvector extension)mydatabaseNo
POSTGRES_USERDatabase user (needs CREATE TABLE/CREATE INDEX)myuserNo
POSTGRES_PASSWORDDatabase passwordmypasswordNo
POSTGRES_USE_UNIX_SOCKETConnect via Unix socket instead of TCPfalseNo
COLLECTION_NAMEpgvector collection/table name for embeddingstestcollectionNo

Connection string forms:

  • TCP: postgresql+psycopg2://user:pass@host:port/dbname
  • Unix socket (POSTGRES_USE_UNIX_SOCKET=true): postgresql+psycopg2://user:pass@/dbname?host=/socket/path

Requires the pgvector extension (≥ 0.5.0). In the stack this is provided by the bundled Vector DB component, which shares the same DB_*/POSTGRES_* keys above.

MongoDB Atlas (alternative)

Used only when VECTOR_DB_TYPE=atlas-mongo.

NamePurposeDefaultRequired
ATLAS_MONGO_DB_URIMongoDB Atlas connection string (SRV URI)mongodb://127.0.0.1:27018/IntelliAskNo
COLLECTION_NAMECollection name for embeddingstestcollectionNo
ATLAS_SEARCH_INDEXAtlas vector search index name (must exist)vector_indexNo
MONGO_VECTOR_COLLECTIONDeprecated — legacy override for collection + index(unset)No

An Atlas vector search index must be created on the collection before indexing, for example:

{
  "fields": [
    { "type": "vector", "path": "embedding", "numDimensions": 1536, "similarity": "cosine" },
    { "type": "filter", "path": "file_id" }
  ]
}

Chunking & retrieval

NamePurposeDefaultRequired
CHUNK_SIZEChunk size in tokens for text splitting1500No
CHUNK_OVERLAPOverlapping tokens between adjacent chunks100No

Larger chunks preserve more context per vector but use more memory; overlap is typically 10–20% of CHUNK_SIZE to avoid losing context at boundaries.

Batching (memory tuning)

Embedding runs in memory-bounded batches. Peak memory ≈ EMBEDDING_BATCH_SIZE × EMBEDDING_MAX_QUEUE_SIZE.

NamePurposeDefaultRequired
EMBEDDING_BATCH_SIZEChunks embedded per batch (0 disables batching)500No
EMBEDDING_MAX_QUEUE_SIZEMax batches buffered in memory during async processing3No
ProfileSuggested settings
Memory-constrained (< 2 GB)EMBEDDING_BATCH_SIZE=100, EMBEDDING_MAX_QUEUE_SIZE=2
DefaultEMBEDDING_BATCH_SIZE=500, EMBEDDING_MAX_QUEUE_SIZE=3
High-throughputEMBEDDING_BATCH_SIZE=750, EMBEDDING_MAX_QUEUE_SIZE=5

Document processing

NamePurposeDefaultRequired
PDF_EXTRACT_IMAGESExtract and process images embedded in PDFsfalseNo

Logging & debugging

NamePurposeDefaultRequired
DEBUG_RAG_APIVerbose debug logging (also enables /db/* debug routes)falseNo
DEBUG_PGVECTOR_QUERIESLog every pgvector SQL query with timingfalseNo
CONSOLE_JSONEmit structured JSON logs (for log aggregation)falseNo

DEBUG_PGVECTOR_QUERIES has a significant performance cost and DEBUG_RAG_API exposes debug database routes — keep both false in production.

Proxy (corporate networks)

NamePurposeDefaultRequired
HTTP_PROXYHTTP proxy for all outbound requests from the container(unset)No
HTTPS_PROXYHTTPS proxy for all outbound requests(unset)No

These apply to every external call (OpenAI, HuggingFace, Google, AWS, …) — useful in air-gapped or proxied environments.

Applying changes

The RAG API reads env at startup, so after editing any RAG_* value recreate the service:

intelliask up rag-api

RAG is disabled by default

RAG is an optional module the stack ships disabled (it needs an embeddings provider first). If rag-api isn't running, enable the module instead — this clears it from DISABLED_MODULES and starts it:

intelliask module enable rag

Disable it again with intelliask module disable rag.

Run intelliask env doctor first to confirm the variables are wired between config/.env and the compose files.

Last updated on