Configuration

Complete guide to configuring InferXgate environment variables and settings.

InferXgate is configured primarily through environment variables. This guide covers all available configuration options.

Environment Variables

Required Variables

These variables must be set for InferXgate to function:

# Database connection (PostgreSQL)
DATABASE_URL=postgresql://user:password@localhost:5432/inferxgate

# JWT secret for authentication (use a strong random string)
JWT_SECRET=your-secure-random-string-at-least-32-chars

Provider API Keys

Add API keys for the providers you want to use:

# Anthropic (Claude models)
ANTHROPIC_API_KEY=sk-ant-api03-...

# OpenAI (GPT models)
OPENAI_API_KEY=sk-...

# Google Gemini
GEMINI_API_KEY=...

# Azure OpenAI
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_VERSION=2024-02-01

Server Settings

# Server port (default: 3000)
PORT=3000

# Host to bind to (default: 0.0.0.0)
HOST=0.0.0.0

# Log level: error, warn, info, debug, trace (default: info)
LOG_LEVEL=info

# Enable JSON structured logging (default: false)
LOG_JSON=false

Caching Configuration

# Redis connection URL
REDIS_URL=redis://localhost:6379

# Enable caching (default: true)
ENABLE_CACHING=true

# Cache TTL in seconds (default: 3600)
CACHE_TTL_SECONDS=3600

# Maximum cache size in MB (default: 1024)
CACHE_MAX_SIZE_MB=1024

Authentication Settings

# Require authentication for API requests (default: false)
REQUIRE_AUTH=false

# JWT token expiry in seconds (default: 86400 = 24 hours)
JWT_EXPIRY_SECONDS=86400

# Allowed email domains for registration (comma-separated)
ALLOWED_EMAIL_DOMAINS=company.com,partner.com

# Enable GitHub OAuth
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...

Rate Limiting

# Enable rate limiting (default: true)
ENABLE_RATE_LIMIT=true

# Requests per minute per API key (default: 60)
RATE_LIMIT_RPM=60

# Requests per day per API key (default: 10000)
RATE_LIMIT_RPD=10000

Load Balancing

# Load balancing strategy: round_robin, least_latency, least_cost, random
LOAD_BALANCE_STRATEGY=round_robin

# Enable automatic failover (default: true)
ENABLE_FAILOVER=true

# Provider health check interval in seconds (default: 30)
HEALTH_CHECK_INTERVAL=30

Connection Settings

# Connection pool size per provider (default: 10)
CONNECTION_POOL_SIZE=10

# Request timeout in seconds (default: 300)
REQUEST_TIMEOUT_SECONDS=300

# TCP keepalive interval in seconds (default: 60)
TCP_KEEPALIVE_SECONDS=60

Configuration File

For complex setups, you can use a YAML configuration file:

# config.yaml
server:
  port: 3000
  host: "0.0.0.0"

database:
  url: "postgresql://user:pass@localhost:5432/inferxgate"
  max_connections: 20

redis:
  url: "redis://localhost:6379"
  pool_size: 10

providers:
  anthropic:
    api_key: ${ANTHROPIC_API_KEY}
    enabled: true
  openai:
    api_key: ${OPENAI_API_KEY}
    enabled: true
  gemini:
    api_key: ${GEMINI_API_KEY}
    enabled: true

caching:
  enabled: true
  ttl_seconds: 3600
  max_size_mb: 1024

auth:
  require_auth: true
  jwt_secret: ${JWT_SECRET}
  jwt_expiry_seconds: 86400
  allowed_domains:
    - company.com
    - partner.com

rate_limit:
  enabled: true
  requests_per_minute: 60
  requests_per_day: 10000

load_balancing:
  strategy: round_robin
  failover: true
  health_check_interval: 30

Load with:

./inferxgate --config config.yaml

Provider-Specific Configuration

Anthropic

ANTHROPIC_API_KEY=sk-ant-api03-...

# Optional: Custom base URL
ANTHROPIC_BASE_URL=https://api.anthropic.com

# Optional: API version
ANTHROPIC_VERSION=2024-01-01

OpenAI

OPENAI_API_KEY=sk-...

# Optional: Organization ID
OPENAI_ORG_ID=org-...

# Optional: Custom base URL (for proxies)
OPENAI_BASE_URL=https://api.openai.com/v1

Google Gemini

GEMINI_API_KEY=...

# Optional: Region
GEMINI_REGION=us-central1

# Optional: Project ID (for Vertex AI)
GEMINI_PROJECT_ID=my-project

Azure OpenAI

AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com

# API version (required)
AZURE_OPENAI_API_VERSION=2024-02-01

# Deployment mappings (model -> deployment)
AZURE_OPENAI_DEPLOYMENTS=gpt-4:my-gpt4-deployment,gpt-35-turbo:my-gpt35-deployment

Multiple API Keys

For load balancing across multiple API keys:

# Comma-separated list of keys
ANTHROPIC_API_KEYS=sk-ant-key1,sk-ant-key2,sk-ant-key3

# Or with weights
ANTHROPIC_API_KEYS=sk-ant-key1:50,sk-ant-key2:30,sk-ant-key3:20

Environment-Specific Configs

Development

LOG_LEVEL=debug
REQUIRE_AUTH=false
ENABLE_RATE_LIMIT=false

Production

LOG_LEVEL=info
LOG_JSON=true
REQUIRE_AUTH=true
ENABLE_RATE_LIMIT=true
ENABLE_CACHING=true

Validating Configuration

Check your configuration:

# Validate config file
./inferxgate --validate-config

# Show current configuration (redacted secrets)
./inferxgate --show-config

# Test provider connections
./inferxgate --test-providers

Next Steps