Comprehensive guide to all environment variables supported by Cipher for secure configuration and external service integration.

API Configuration

VariablePurposeValues/DefaultNotes/Usage
OPENAI_API_KEYAPI key for OpenAI servicesRequiredUsed for LLM operations and always required for embedding functionality
ANTHROPIC_API_KEYAPI key for Anthropic Claude modelsOptionalRequired when provider: anthropic in cipher.yml
OPENROUTER_API_KEYAPI key for OpenRouterOptionalRequired when provider: openrouter in cipher.yml
OLLAMA_BASE_URLBase URL for local Ollama instanceDefault: http://localhost:11434/v1Required when provider: ollama in cipher.yml; no API key needed
OPENAI_BASE_URLCustom OpenAI API endpointDefault: https://api.openai.com/v1Override for custom deployments (Azure, proxies, etc.)
AWS_ACCESS_KEY_IDAWS access key for BedrockOptionalRequired when provider: aws-bedrock in cipher.yml
AWS_SECRET_ACCESS_KEYAWS secret key for BedrockOptionalRequired when provider: aws-bedrock in cipher.yml
AWS_REGIONAWS region for BedrockDefault: us-east-1Required when provider: aws-bedrock in cipher.yml
AZURE_OPENAI_API_KEYAPI key for Azure OpenAI ServiceOptionalRequired when provider: azure-openai in cipher.yml
AZURE_OPENAI_ENDPOINTAzure OpenAI endpoint URLOptionalRequired when provider: azure-openai in cipher.yml
AZURE_OPENAI_API_VERSIONAzure OpenAI API versionDefault: 2024-02-15-previewRequired when provider: azure-openai in cipher.yml
GEMINI_API_KEYAPI key for Google AI Studio (Gemini)OptionalRequired when provider: gemini in cipher.yml
GOOGLE_API_KEYAPI key for Google AI Studio (Gemini)OptionalRequired when provider: gemini in cipher.yml
GOOGLE_GEMINI_BASE_URLCustom Gemini API endpointDefault: https://generativelanguage.googleapis.comOverride for custom Gemini deployments
QWEN_API_KEYAPI key for Alibaba Cloud (Qwen)OptionalRequired when provider: qwen in cipher.yml
VOYAGE_API_KEYAPI key for Voyage AIOptionalRequired when using Voyage embeddings
AWS_DEFAULT_REGIONAWS default regionDefault: us-east-1Alternative to AWS_REGION for Bedrock
ALIBABA_API_KEYAPI key for Alibaba Cloud (Qwen)OptionalRequired when provider: qwen in cipher.yml
ALIBABA_BASE_URLCustom Alibaba Cloud API endpointDefault: https://dashscope.aliyuncs.comOverride for custom Qwen deployments

Application Settings

VariablePurposeValues/DefaultNotes/Usage
NODE_ENVNode.js environment modedevelopment, production, testDefault: development
CIPHER_LOG_LEVELControls logging verbosityerror, warn, info, debug, sillyDefault: info
REDACT_SECRETSRedact sensitive info in logstrue, falseDefault: true

Storage Configuration

VariablePurposeValues/DefaultNotes/Usage
STORAGE_CACHE_TYPEType of caching backendin-memory, redisDefault: in-memory
STORAGE_CACHE_HOSTRedis server hostnameDefault: localhostRequired when STORAGE_CACHE_TYPE=redis
STORAGE_CACHE_PORTRedis server portDefault: 6379Number
STORAGE_CACHE_PASSWORDRedis authentication passwordOptionalOnly if Redis requires auth
STORAGE_CACHE_DATABASERedis database numberDefault: 0Number (0-15 typically)
STORAGE_DATABASE_TYPEPersistent storage backendin-memory, sqliteDefault: in-memory
STORAGE_DATABASE_PATHDirectory path for SQLiteExample: ./dataWhere to store the database file
STORAGE_DATABASE_NAMESQLite database filenameDefault: cipher.dbDatabase file name within the path

Multi-Backend Storage Configuration

VariablePurposeValues/DefaultNotes/Usage
CIPHER_MULTI_BACKENDEnable multi-backend storage1, 0 (Default: 0)Enables PostgreSQL + SQLite fallback system
CIPHER_PG_URLPostgreSQL connection stringRequired when enabledFull PostgreSQL connection URL
CIPHER_WAL_FLUSH_INTERVALWAL flush interval (ms)Default: 5000How often WAL syncs to backup storage
MULTI_BACKEND_ENABLEDEnable multi-backend storagetrue, false (Default: false)Enables PostgreSQL + SQLite fallback system
MULTI_BACKEND_PRIMARY_TYPEPrimary database typepostgresql, sqlite (Default: postgresql)Primary storage backend
MULTI_BACKEND_FALLBACK_TYPEFallback database typesqlite, postgresql (Default: sqlite)Backup storage when primary fails
POSTGRES_HOSTPostgreSQL server hostnameDefault: localhostRequired when using PostgreSQL
POSTGRES_PORTPostgreSQL server portDefault: 5432Number
POSTGRES_DATABASEPostgreSQL database nameDefault: cipherDatabase name for chat history
POSTGRES_USERNAMEPostgreSQL authentication userDefault: postgresDatabase user
POSTGRES_PASSWORDPostgreSQL authentication passRequiredDatabase password
POSTGRES_SSLEnable SSL for PostgreSQLtrue, false (Default: false)Secure connection to PostgreSQL
MULTI_BACKEND_SYNC_INTERVALCache sync interval (ms)Default: 5000How often cache syncs to fallback
MULTI_BACKEND_MAX_RETRIESMax retry attempts for writesDefault: 3Number of retries for failed operations
MULTI_BACKEND_RETRY_DELAYDelay between retries (ms)Default: 1000Time to wait between retry attempts

Memory Search Configuration

VariablePurposeValues/DefaultNotes/Usage
SEARCH_MEMORY_TYPEWhich memory types to searchknowledge, reflection, both (Default: both)Controls which memory collections are queried

Vector Store Configuration

VariablePurposeValues/DefaultNotes/Usage
VECTOR_STORE_TYPEVector database backend typein-memory, qdrant, milvus (Default: in-memory)Storage for embeddings and similarity search
VECTOR_STORE_HOSTVector database hostnameExample: localhostRequired for Qdrant, Milvus
VECTOR_STORE_PORTVector database portExamples: 6333 (Qdrant), 19530 (Milvus)Number
VECTOR_STORE_URLComplete URL for vector databaseExample: http://localhost:6333Alternative to host/port
VECTOR_STORE_API_KEYAuth for cloud vector databasesOptionalQdrant Cloud, Zilliz Cloud (Milvus)
VECTOR_STORE_USERNAMEUsername for Milvus authOptionalZilliz Cloud and self-hosted Milvus
VECTOR_STORE_PASSWORDPassword for Milvus authOptionalPairs with username
VECTOR_STORE_COLLECTIONName of the knowledge collectionDefault: knowledge_memoryCollection name for storing knowledge embeddings
VECTOR_STORE_DIMENSIONVector embedding dimensionsDefault: 1536Must match embedding model output
VECTOR_STORE_DISTANCEDistance metric for similarityCosine, Euclidean, Dot, Manhattan (Default: Cosine)How vectors are compared for similarity
VECTOR_STORE_ON_DISKStore vectors on disk (Qdrant)true, false (Default: false)Performance vs storage trade-off
VECTOR_STORE_MAX_VECTORSMax vectors in memoryDefault: 10000Memory usage limit for in-memory storage

Reflection Memory Configuration

VariablePurposeValues/DefaultNotes/Usage
REFLECTION_VECTOR_STORE_COLLECTIONName of the reflection memory collectionDefault: reflection_memorySeparate collection for agent reflection/learning
DISABLE_REFLECTION_MEMORYDisable reflection memorytrue, false (Default: true)Performance optimization for simpler use cases

MCP Configuration

VariablePurposeValues/DefaultNotes/Usage
MCP_GLOBAL_TIMEOUTGlobal timeout for all MCP opsDefault: 30000 (ms)Max time to wait for MCP server responses

Event Management Configuration

VariablePurposeValues/DefaultNotes/Usage
EVENT_FILTERING_ENABLEDEnable or disable event filteringtrue, false (Default: false)Controls whether events are filtered during processing
EVENT_FILTERED_TYPESEvent types to filter outComma-separated listExample: tool:executionStarted,tool:executionCompleted,llm:thinking
EVENT_PERSISTENCE_ENABLEDEnable or disable event persistencetrue, false (Default: true)Controls whether events are saved to storage
EVENT_PERSISTENCE_PATHPath to store event log filesDefault: ./data/eventsDirectory where event logs are stored

Knowledge Graph Configuration

VariablePurposeValues/DefaultNotes/Usage
KNOWLEDGE_GRAPH_ENABLEDEnable advanced KG featurestrue, false (Default: false)Enables Neo4j-based relationship modeling
KNOWLEDGE_GRAPH_TYPEKnowledge graph backend typeneo4j, in-memory (Default: in-memory)Choose between Neo4j and in-memory graph
KNOWLEDGE_GRAPH_HOSTNeo4j database hostnameDefault: localhost
KNOWLEDGE_GRAPH_PORTNeo4j bolt protocol portDefault: 7687Number
KNOWLEDGE_GRAPH_URIComplete Neo4j connection URIExample: bolt://localhost:7687Alternative to host/port
KNOWLEDGE_GRAPH_USERNAMENeo4j authentication usernameDefault: neo4j
KNOWLEDGE_GRAPH_PASSWORDNeo4j authentication passwordRequired for Neo4j connection
KNOWLEDGE_GRAPH_DATABASENeo4j database nameDefault: neo4jSupports multiple databases in Neo4j 4.0+

Embedding Configuration (Advanced)

VariablePurposeValues/DefaultNotes/Usage
EMBEDDING_MODELOverride default embedding modelDefault: text-embedding-3-smallControl which OpenAI embedding model to use
EMBEDDING_TIMEOUTTimeout for embedding requestsDefault: 30000 (ms)
EMBEDDING_MAX_RETRIESMax retry attempts for embeddingDefault: 3Number (0-10)
EMBEDDING_PROVIDERDefault embedding provideropenai, gemini, ollama, voyage, qwen, aws-bedrockPrimary embedding service to use
EMBEDDING_FALLBACK_PROVIDERFallback embedding provideropenai, gemini, ollama, voyage, qwen, aws-bedrockBackup provider if primary fails
EMBEDDING_HEALTH_CHECK_INTERVALHealth check frequency (ms)Default: 30000How often to check provider health
EMBEDDING_CIRCUIT_BREAKER_THRESHOLDError threshold for circuit breakerDefault: 5Consecutive errors before circuit breaker trips
EMBEDDING_CIRCUIT_BREAKER_TIMEOUTCircuit breaker timeout (ms)Default: 60000Time to wait before retrying failed provider

Embedding Provider-Specific Configuration

OpenAI Embedding

VariablePurposeValues/DefaultNotes/Usage
OPENAI_EMBEDDING_MODELOpenAI embedding modeltext-embedding-3-small, text-embedding-3-large, text-embedding-ada-002Model for OpenAI embeddings
OPENAI_EMBEDDING_DIMENSIONVector dimension for OpenAIDefault: 1536Must match model output dimension

Gemini Embedding

VariablePurposeValues/DefaultNotes/Usage
GOOGLE_EMBEDDING_MODELGemini embedding modeltext-embedding-004, gemini-embedding-001Model for Gemini embeddings
GOOGLE_EMBEDDING_DIMENSIONVector dimension for GeminiDefault: 768Must match model output dimension

Ollama Embedding

VariablePurposeValues/DefaultNotes/Usage
OLLAMA_EMBEDDING_MODELOllama embedding modelnomic-embed-text, all-minilmModel for Ollama embeddings
OLLAMA_EMBEDDING_DIMENSIONVector dimension for OllamaDefault: 384Must match model output dimension

Voyage Embedding

VariablePurposeValues/DefaultNotes/Usage
VOYAGE_API_KEYVoyage AI API keyRequiredRequired when using Voyage embeddings
VOYAGE_EMBEDDING_MODELVoyage embedding modelvoyage-large-2, voyage-code-2Model for Voyage embeddings
VOYAGE_EMBEDDING_DIMENSIONVector dimension for VoyageDefault: 1024Must match model output dimension

Qwen Embedding

VariablePurposeValues/DefaultNotes/Usage
ALIBABA_EMBEDDING_MODELQwen embedding modeltext-embedding-v1, text-embedding-v2Model for Qwen embeddings
ALIBABA_EMBEDDING_DIMENSIONVector dimension for QwenDefault: 1536Must match model output dimension

AWS Bedrock Embedding

VariablePurposeValues/DefaultNotes/Usage
AWS_EMBEDDING_MODELAWS Bedrock embedding modelamazon.titan-embed-text-v1:0Model for AWS Bedrock embeddings
AWS_EMBEDDING_DIMENSIONVector dimension for AWS BedrockDefault: 1536Must match model output dimension

Required vs Optional Variables

Always Required

  • OPENAI_API_KEY - For embeddings, even with other LLM providers

Required for Specific Providers

  • ANTHROPIC_API_KEY - When using Anthropic
  • OPENROUTER_API_KEY - When using OpenRouter
  • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION (or AWS_DEFAULT_REGION) - When using AWS Bedrock
  • AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT - When using Azure OpenAI Service
  • GEMINI_API_KEY or GOOGLE_API_KEY - When using Google AI Studio (Gemini)
  • QWEN_API_KEY or ALIBABA_API_KEY - When using Alibaba Cloud (Qwen)
  • VOYAGE_API_KEY - When using Voyage AI embeddings

Required for External Services

  • Redis: STORAGE_CACHE_HOST when STORAGE_CACHE_TYPE=redis
  • PostgreSQL: POSTGRES_PASSWORD when MULTI_BACKEND_ENABLED=true and MULTI_BACKEND_PRIMARY_TYPE=postgresql
  • Qdrant: VECTOR_STORE_HOST or VECTOR_STORE_URL when VECTOR_STORE_TYPE=qdrant
  • Milvus: VECTOR_STORE_HOST or VECTOR_STORE_URL when VECTOR_STORE_TYPE=milvus
  • Neo4j: KNOWLEDGE_GRAPH_PASSWORD when KNOWLEDGE_GRAPH_ENABLED=true and KNOWLEDGE_GRAPH_TYPE=neo4j

Example .env File

# API Configuration (Required)
OPENAI_API_KEY=sk-proj-your-openai-key-here
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key-here
OPENROUTER_API_KEY=sk-or-your-openrouter-key-here
QWEN_API_KEY=your-qwen-api-key-here
GEMINI_API_KEY=your-gemini-api-key-here
VOYAGE_API_KEY=your-voyage-api-key-here

# AWS Bedrock Configuration (Optional)
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
AWS_REGION=us-east-1

# Azure OpenAI Configuration (Optional)
AZURE_OPENAI_API_KEY=your-azure-openai-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_VERSION=2024-02-15-preview

# Google AI Studio Configuration (Optional)
GOOGLE_API_KEY=your-google-api-key
GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com

# Alibaba Cloud Configuration (Optional)
ALIBABA_API_KEY=your-alibaba-api-key
ALIBABA_BASE_URL=https://dashscope.aliyuncs.com

# Application Settings
NODE_ENV=production
CIPHER_LOG_LEVEL=info
REDACT_SECRETS=true

# Vector Store Configuration
VECTOR_STORE_TYPE=qdrant
VECTOR_STORE_HOST=localhost
VECTOR_STORE_PORT=6333
VECTOR_STORE_COLLECTION=knowledge_memory
VECTOR_STORE_DIMENSION=1536
VECTOR_STORE_DISTANCE=Cosine

# Knowledge Graph Configuration
KNOWLEDGE_GRAPH_ENABLED=true
KNOWLEDGE_GRAPH_TYPE=neo4j
KNOWLEDGE_GRAPH_HOST=localhost
KNOWLEDGE_GRAPH_PORT=7687
KNOWLEDGE_GRAPH_USERNAME=neo4j
KNOWLEDGE_GRAPH_PASSWORD=your-neo4j-password

# Storage Configuration
STORAGE_CACHE_TYPE=redis
STORAGE_CACHE_HOST=localhost
STORAGE_CACHE_PORT=6379
STORAGE_DATABASE_TYPE=sqlite
STORAGE_DATABASE_PATH=./data
STORAGE_DATABASE_NAME=cipher.db

# Multi-Backend Storage Configuration
CIPHER_MULTI_BACKEND=1
CIPHER_PG_URL=postgres://cipheruser:cipherpass@localhost:5432/cipherdb
CIPHER_WAL_FLUSH_INTERVAL=5000
MULTI_BACKEND_ENABLED=true
MULTI_BACKEND_PRIMARY_TYPE=postgresql
MULTI_BACKEND_FALLBACK_TYPE=sqlite
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DATABASE=cipher
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=your-postgres-password
POSTGRES_SSL=false
MULTI_BACKEND_SYNC_INTERVAL=5000
MULTI_BACKEND_MAX_RETRIES=3
MULTI_BACKEND_RETRY_DELAY=1000

# Memory Configuration
SEARCH_MEMORY_TYPE=both
DISABLE_REFLECTION_MEMORY=false
REFLECTION_VECTOR_STORE_COLLECTION=reflection_memory

# MCP Configuration
MCP_GLOBAL_TIMEOUT=30000

# Event Management Configuration
EVENT_FILTERING_ENABLED=false
EVENT_FILTERED_TYPES=tool:executionStarted,tool:executionCompleted,llm:thinking
EVENT_PERSISTENCE_ENABLED=true
EVENT_PERSISTENCE_PATH=./data/events

# Embedding Configuration (Advanced)
EMBEDDING_PROVIDER=openai
EMBEDDING_FALLBACK_PROVIDER=gemini
EMBEDDING_MODEL=text-embedding-3-small
EMBEDDING_TIMEOUT=30000
EMBEDDING_MAX_RETRIES=3
EMBEDDING_HEALTH_CHECK_INTERVAL=30000
EMBEDDING_CIRCUIT_BREAKER_THRESHOLD=5
EMBEDDING_CIRCUIT_BREAKER_TIMEOUT=60000

# OpenAI Embedding Configuration
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_EMBEDDING_DIMENSION=1536

# Gemini Embedding Configuration
GOOGLE_EMBEDDING_MODEL=text-embedding-004
GOOGLE_EMBEDDING_DIMENSION=768

# Ollama Embedding Configuration
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
OLLAMA_EMBEDDING_DIMENSION=384

# Voyage Embedding Configuration
VOYAGE_API_KEY=your-voyage-api-key
VOYAGE_EMBEDDING_MODEL=voyage-large-2
VOYAGE_EMBEDDING_DIMENSION=1024

# Qwen Embedding Configuration
ALIBABA_EMBEDDING_MODEL=text-embedding-v1
ALIBABA_EMBEDDING_DIMENSION=1536

# AWS Bedrock Embedding Configuration
AWS_EMBEDDING_MODEL=amazon.titan-embed-text-v1:0
AWS_EMBEDDING_DIMENSION=1536