Configuration

Environment variables and runtime options.

Core

VariableDefaultDescription
PORT4200HTTP server listen port
STOCKYARD_ADMIN_KEYnoneAdmin API key. Required for all /api/* management endpoints. If unset, management API is open (dev mode only).
STOCKYARD_DB_PATH./stockyard.dbPath to SQLite database file. Use a persistent volume in production.
STOCKYARD_REQUIRE_AUTHfalseWhen true, all /v1/* proxy requests require a valid sk-sy- API key.
STOCKYARD_TRUST_PROXYnoneWhen set, trusts X-User-Id and X-Customer-ID headers from upstream reverse proxies.

Provider Keys

Configure LLM providers by setting environment variables. Stockyard auto-detects which providers are available based on which keys are set.

VariableProvider
OPENAI_API_KEYOpenAI (GPT-4o, o1, o3)
ANTHROPIC_API_KEYAnthropic (Claude)
GEMINI_API_KEYGoogle Gemini
GROQ_API_KEYGroq
MISTRAL_API_KEYMistral
TOGETHER_API_KEYTogether AI
DEEPSEEK_API_KEYDeepSeek
FIREWORKS_API_KEYFireworks AI
PERPLEXITY_API_KEYPerplexity
OPENROUTER_API_KEYOpenRouter
XAI_API_KEYxAI (Grok)
COHERE_API_KEYCohere
REPLICATE_API_TOKENReplicate
AZURE_OPENAI_API_KEYAzure OpenAI
AZURE_OPENAI_ENDPOINTAzure OpenAI endpoint URL

Users can also store per-user provider keys via the API (PUT /api/auth/me/providers/{provider}). Per-user keys override global environment keys for that user's requests.

Local Providers

VariableDefaultDescription
OLLAMA_BASE_URLhttp://localhost:11434Ollama server URL
LMSTUDIO_BASE_URLhttp://localhost:1234LM Studio server URL

Billing

VariableDescription
STRIPE_SECRET_KEYStripe API key for subscription billing
STRIPE_WEBHOOK_SECRETStripe webhook signing secret

Persistence

Stockyard stores everything in a single SQLite file. In production, mount a persistent volume at the database path:

# Docker
docker run -v stockyard-data:/data \
  -e STOCKYARD_DB_PATH=/data/stockyard.db \
  ghcr.io/stockyard-dev/stockyard
# Railway
# Mount a volume at /data and set:
STOCKYARD_DB_PATH=/data/stockyard.db

Back up by copying the file:

cp /data/stockyard.db /data/backup-$(date +%Y%m%d).db

Runtime Configuration

Most configuration beyond provider keys is managed at runtime through the API or dashboard. This includes middleware modules, routing rules, trust policies, spend caps, and alert rules. Changes take effect immediately without restart.

# Enable a middleware module
curl -X PUT https://your-host/api/proxy/modules/cache \
  -H "X-Admin-Key: $ADMIN_KEY" \
  -d '{"enabled": true}'

# Set a spend cap
curl -X POST https://your-host/api/config \
  -H "X-Admin-Key: $ADMIN_KEY" \
  -d '{"spend_caps": {"default": {"daily": 50.0, "monthly": 500.0}}}'

Production Checklist

1. Set STOCKYARD_ADMIN_KEY to a strong random value.

2. Set STOCKYARD_REQUIRE_AUTH=true so proxy requests require API keys.

3. Mount a persistent volume for the SQLite database.

4. Set at least one provider API key.

5. Set up a reverse proxy (Caddy, nginx) for TLS termination.

Explore: Model aliasing · Why SQLite · vs LiteLLM