Skip to content

Environment Variables

Configure StrataRouter using environment variables for different deployment scenarios.

Core Configuration

Required Variables

Variable Description Default Example
STRATAROUTER_EMBEDDING_DIM Embedding vector dimension 384 768
STRATAROUTER_MODEL_NAME Default embedding model all-MiniLM-L6-v2 text-embedding-ada-002

Optional Variables

Variable Description Default Example
STRATAROUTER_LOG_LEVEL Logging level info debug
STRATAROUTER_CACHE_SIZE Cache size in MB 64 128
STRATAROUTER_THREADS Number of threads CPU count 4
STRATAROUTER_ENABLE_SIMD Enable SIMD optimization true false

Runtime Configuration

Server Settings

Variable Description Default Example
STRATAROUTER_RUNTIME_HOST Runtime server host 0.0.0.0 localhost
STRATAROUTER_RUNTIME_PORT Runtime server port 8080 3000
STRATAROUTER_WORKERS Number of workers CPU count 8
STRATAROUTER_MAX_CONNECTIONS Max concurrent connections 1000 5000

Execution Settings

Variable Description Default Example
STRATAROUTER_TIMEOUT_MS Request timeout in ms 30000 60000
STRATAROUTER_RETRY_ATTEMPTS Max retry attempts 3 5
STRATAROUTER_BATCH_SIZE Batch processing size 32 64
STRATAROUTER_ENABLE_SANDBOX Enable execution sandbox true false

Provider Configuration

OpenAI

Variable Description Required Example
OPENAI_API_KEY OpenAI API key Yes sk-...
OPENAI_ORG_ID Organization ID No org-...
OPENAI_BASE_URL Custom base URL No https://api.openai.com/v1

Anthropic

Variable Description Required Example
ANTHROPIC_API_KEY Anthropic API key Yes sk-ant-...
ANTHROPIC_BASE_URL Custom base URL No https://api.anthropic.com

Google

Variable Description Required Example
GOOGLE_API_KEY Google AI API key Yes AIza...
GOOGLE_PROJECT_ID GCP project ID No my-project

Observability

Metrics & Tracing

Variable Description Default Example
STRATAROUTER_ENABLE_METRICS Enable Prometheus metrics true false
STRATAROUTER_METRICS_PORT Metrics endpoint port 9090 8888
OTEL_EXPORTER_OTLP_ENDPOINT OpenTelemetry endpoint None http://localhost:4317
OTEL_SERVICE_NAME Service name for tracing stratarouter my-router

Logging

Variable Description Default Example
RUST_LOG Rust logging configuration info stratarouter=debug,warn
STRATAROUTER_LOG_FORMAT Log format (json/text) text json
STRATAROUTER_LOG_FILE Log file path None /var/log/stratarouter.log

Storage & Caching

Database

Variable Description Default Example
DATABASE_URL PostgreSQL connection URL None postgres://user:pass@localhost/db
DB_POOL_SIZE Connection pool size 10 20
DB_MAX_LIFETIME_SECS Connection max lifetime 1800 3600

Redis Cache

Variable Description Default Example
REDIS_URL Redis connection URL None redis://localhost:6379
REDIS_POOL_SIZE Connection pool size 10 20
CACHE_TTL_SECS Default cache TTL 3600 7200

Security

Authentication & Authorization

Variable Description Default Example
STRATAROUTER_API_KEY API key for authentication None sr_...
JWT_SECRET JWT signing secret None your-secret-key
ENABLE_RATE_LIMITING Enable rate limiting true false
RATE_LIMIT_PER_MINUTE Requests per minute 100 1000

TLS/SSL

Variable Description Default Example
TLS_CERT_PATH TLS certificate path None /etc/certs/cert.pem
TLS_KEY_PATH TLS private key path None /etc/certs/key.pem
ENABLE_TLS Enable TLS false true

Performance Tuning

HNSW Index

Variable Description Default Example
HNSW_M Max connections per layer 16 32
HNSW_EF_CONSTRUCTION Construction time parameter 200 400
HNSW_EF_SEARCH Search time parameter 100 200

Batch Processing

Variable Description Default Example
BATCH_MAX_WAIT_MS Max wait time for batch 50 100
BATCH_MAX_SIZE Max batch size 32 128
ENABLE_DEDUPLICATION Enable request deduplication true false

Development & Testing

Debug Settings

Variable Description Default Example
STRATAROUTER_ENV Environment (dev/prod) production development
ENABLE_DEBUG_ENDPOINTS Enable debug endpoints false true
PROFILE_REQUESTS Enable request profiling false true
DISABLE_TELEMETRY Disable telemetry false true

Configuration File

You can also use a configuration file instead of environment variables:

# Load from TOML file
export STRATAROUTER_CONFIG_FILE=/etc/stratarouter/config.toml

# Or use .env file
export $(cat .env | xargs)

Example Configurations

Development

# .env.development
STRATAROUTER_ENV=development
STRATAROUTER_LOG_LEVEL=debug
STRATAROUTER_RUNTIME_PORT=8080
ENABLE_DEBUG_ENDPOINTS=true

Production

# .env.production
STRATAROUTER_ENV=production
STRATAROUTER_LOG_LEVEL=info
STRATAROUTER_LOG_FORMAT=json
STRATAROUTER_RUNTIME_PORT=8080
STRATAROUTER_WORKERS=16
ENABLE_TLS=true
DATABASE_URL=postgres://...
REDIS_URL=redis://...

Docker

# docker-compose.yml environment
STRATAROUTER_RUNTIME_HOST=0.0.0.0
STRATAROUTER_RUNTIME_PORT=8080
DATABASE_URL=postgres://db:5432/stratarouter
REDIS_URL=redis://redis:6379
OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317

Precedence

Configuration sources in order of precedence (highest to lowest):

  1. Environment variables
  2. Configuration file (.toml or .env)
  3. Command-line arguments
  4. Default values

Validation

StrataRouter validates all environment variables on startup:

  • Required variables must be present
  • Values must be within valid ranges
  • URLs must be valid and accessible
  • Paths must exist and be readable

Check logs for validation errors:

stratarouter-runtime 2>&1 | grep "CONFIG"

Next Steps