BrainAPI
BrainAPI
Operate

For the complete BrainAPI documentation index, see llms.txt. A markdown version of any docs page is available by appending .md to its URL. Docs MCP: /docs/mcp.

Configuration

Configure BrainAPI security, models, storage, ingestion, retrieval, plugins, and observability

BrainAPI reads configuration from the project .env. Start from .env.example, choose one coherent provider and storage combination, and keep the API, worker, and MCP processes on the same settings.

Security and brains

VariableDefaultPurpose
BRAINPAT_TOKENRequiredSystem administrator PAT.
BRAIN_CREATION_ALLOWEDfalse in runtime when unsetCreate a missing selected brain automatically. The example file opts into true.
DEFAULT_BRAIN_FALLBACKfalse in runtime when unsetResolve a missing selection to default. The example file opts into true.
CONSOLE_ENABLEDtrueServe the web console from the API process.

Use explicit brain creation and selection in production. See Authentication and brains.

Model providers

MODELS_MODE is required and must be local or remote. It determines provider defaults, but explicit provider variables win:

VariableLocal defaultRemote default
LLM_SMALL_PROVIDERollamagcp_vertex
LLM_LARGE_PROVIDERollamaazure
EMBEDDINGS_PROVIDERollamaazure

Supported configured providers include Ollama, Azure, Google Vertex AI, Amazon Bedrock, OpenAI, Anthropic, and DeepSeek where the requested model role is implemented. BrainAPI validates credentials only for providers in use.

Embedding dimensions must match the selected model and existing indexes. Changing a dimension without rebuilding vector indexes causes shape or retrieval failures.

Storage

VariableRuntime defaultCommon alternatives
DATA_DBmongopostgresql
GRAPH_DBneo4jnetworkx
VECTOR_DBmilvuspostgresql

Search requires DATA_DB=postgresql. PostgreSQL Search uses halfvec HNSW for embedding dimensions above 2000 and float32 reranking after ANN candidate generation.

Configure only credentials relevant to the chosen backends: POSTGRES_*, MONGO_*, NEO4J_*, MILVUS_*, and REDIS_*. Redis stores task and brain/PAT cache state and backs Celery in the common deployment.

Ingestion pipeline

VariableRuntime defaultMeaning
PIPELINE_MODEaccurateaccurate or lightweight.
OCR_MODEdoclingdocparser or local docling; .env.example opts into docparser.
AGENTIC_ARCHITECTUREcustomcustom or langchain.
RUN_GRAPH_CONSOLIDATORfalseEnable LLM graph consolidation.
RUN_OBSERVATIONSfalseGenerate observation notes.
JANITOR_BATCH_SIZE20Relationships per Janitor batch.
INGEST_JANITOR_MAX_LLM_CALLS2Janitor LLM-call ceiling per session.
INGEST_ARCHITECT_MODEbatchbatch, schema, or tooler.

The remaining INGEST_ARCHITECT_* controls tune unit splitting, escalation, prior context, and scratchpad size. Keep defaults until an ingestion evaluation identifies a concrete failure.

Search and Context

VariableDefaultConstraint
SEARCH_ENABLEDfalseRequires PostgreSQL.
SEARCH_USE_DENSEtrueAt least one of dense/BM25 must be enabled.
SEARCH_USE_BM25trueAt least one of dense/BM25 must be enabled.
SEARCH_FUSIONrrfrrf or cc.
SEARCH_FUSION_ALPHA0.5Convex-combination weight for cc.
SEARCH_BM25_K11.2BM25 term saturation.
SEARCH_BM25_B0.75BM25 length normalization.
SEARCH_COMMUNITY_LABELSTYPE,CLASS,TOPICLabels eligible as community hubs.
SEARCH_NEIGHBOR_FANOUT50Maximum one-hop members per seed.
SEARCH_LITERAL_FILLfalseOpt into literal-fill behavior.
CONTEXT_PASSAGE_MODEhybridhybrid, bm25, dense, or ilike when Search is enabled.

SEARCH_FTS_REGCONFIG selects a PostgreSQL FTS configuration globally. SEARCH_FTS_BRAINS limits that selection to named brains. Read Search theory before tuning ranking constants.

Plugins and MCP

PLUGINS_DIR defaults to plugins; PLUGIN_REGISTRY_URL defaults to https://registry.brain-api.dev. Publisher credentials are required only for registry mutation. MCP OAuth deployments use MCP_OAUTH_ISSUER_URL and MCP_RESOURCE_SERVER_URL.

Observability

TRACE_TRACKER_ENABLED=false disables trace tracking by default. Queue, slow-request, heartbeat, resource, health-timeout, and loop-iteration variables set bounded monitoring thresholds. Search callers can also request profile_stages=true to inspect query-stage timing.

Validate a configuration

brainapi doctor

Then verify the API root, worker/task flow, selected storage backends, MCP health, and any installed plugin health endpoints. Use Health and troubleshooting when validation fails.

Edit on GitHub

Last updated on

On this page