Documentation

Six apps. One binary. Everything you need to know.

Install & Quickstart

Get Stockyard running in under a minute.

# Install the binary
curl -sSL stockyard.dev/install | sh

# Start the platform (all 6 apps on port 4200)
stockyard

# Point your app at the proxy
export OPENAI_BASE_URL=http://localhost:4200/v1

# Make a request (goes through the full middleware chain)
curl http://localhost:4200/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'

Open http://localhost:4200/ui for the web console. Open http://localhost:4200/api/apps to see all registered apps.

Note
Stockyard auto-detects your API key provider from its prefix (sk- → OpenAI, sk-ant- → Anthropic, gsk_ → Groq, etc.) and routes to the correct upstream. No extra configuration needed.

Playground

Try Stockyard instantly at /playground. Paste any provider API key, pick a model, and start chatting. The playground includes real-time trace viewing, live middleware toggles, and a built-in A/B model comparison tool. No signup required.

Authentication

Stockyard has a built-in auth system for multi-user deployments. Users get sk-sy- API keys that route requests through the proxy with per-user provider key resolution.

# Create a user (returns an API key)
curl -X POST http://localhost:4200/api/auth/signup \
  -d '{"email":"alice@example.com","name":"Alice"}'

# Use the key to make requests
curl http://localhost:4200/v1/chat/completions \
  -H "Authorization: Bearer sk-sy-..." \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'

# Add a provider key to your account
curl -X PUT http://localhost:4200/api/auth/me/providers/openai \
  -H "Authorization: Bearer sk-sy-..." \
  -d '{"api_key":"sk-proj-..."}'

Key resolution order: user's own provider key → global provider. Users can bring their own keys without sharing them.

Configuration

Stockyard works with zero configuration. All 58 middleware modules are registered on boot with sensible defaults. You can toggle modules on/off at runtime via the API:

# List all modules
curl http://localhost:4200/api/proxy/modules

# Disable a module
curl -X PUT http://localhost:4200/api/proxy/modules/toxicfilter \
  -d '{"enabled": false}'

# Re-enable it
curl -X PUT http://localhost:4200/api/proxy/modules/toxicfilter \
  -d '{"enabled": true}'

Module state persists in the embedded SQLite database. Changes take effect immediately — no restart needed.

License & Pro

Stockyard Community is free for up to 10,000 requests/month and 3 users. To remove all limits, upgrade to Pro ($9.99/month) by setting a license key:

# Set your license key
export STOCKYARD_LICENSE_KEY="SY-eyJ..."

# Restart Stockyard (or set the env var before first start)
stockyard

# Verify your tier and usage
curl http://localhost:4200/api/license

License keys are available at stockyard.dev/pricing. Pro and Enterprise keys unlock unlimited requests, unlimited users, and extended retention. All features and modules are available on every tier.

Console

The web console is served at /ui and gives you a real-time view of all six apps. It shows modules, providers, routes, traces, costs, alerts, templates, workflows, packs, and installed status.

The console is built with Preact and has zero external dependencies. It's embedded in the binary and served alongside the API.

Proxy

The proxy is the gateway layer. Every LLM request passes through a middleware chain of 58 toggleable modules. The proxy is OpenAI API-compatible — any SDK that talks to /v1/chat/completions works out of the box.

Modules

Modules are organized by category:

CategoryModulesPurpose
routingfallbackrouter, modelswitch, regionroute, localsync, abrouterProvider failover, model aliasing, geo routing
cachingcachelayer, embedcache, semanticcacheResponse and embedding caching
costcostcap, tierdrop, idlekill, outputcap, usagepulse, rateshieldSpending limits, rate limiting, usage reporting
safetypromptguard, toxicfilter, guardrail, agegate, hallucicheck, secretscan, agentguardContent moderation, injection detection, PII
transformpromptslim, tokentrim, contextpack, chatmem, langbridge, voicebridgePrompt compression, context management
validatestructuredshield, evalgate, codefenceJSON validation, quality gating
shimsanthrofit, geminishimUse Claude/Gemini with OpenAI SDK
observellmtap, tracelink, alertpulse, driftwatchLogging, tracing, alerting, drift detection

Every module is wrapped with toggle.Wrap and checks enabled state on every request. Disable a module and it's bypassed instantly.

Providers

Stockyard supports 16 LLM providers out of the box. Set an environment variable and the provider is auto-configured on boot:

ProviderEnv VarModels
OpenAIOPENAI_API_KEYgpt-4o, gpt-4.1, o3-mini, etc.
AnthropicANTHROPIC_API_KEYclaude-sonnet-4-5, claude-haiku-4-5
Google GeminiGEMINI_API_KEYgemini-2.5-pro, gemini-2.0-flash
GroqGROQ_API_KEYllama-3.3-70b, mixtral-8x7b
MistralMISTRAL_API_KEYmistral-large, codestral
DeepSeekDEEPSEEK_API_KEYdeepseek-chat, deepseek-reasoner
TogetherTOGETHER_API_KEYLlama 3.1, Qwen 2.5
FireworksFIREWORKS_API_KEYLlama 3.3, Qwen 2.5
PerplexityPERPLEXITY_API_KEYsonar-pro, sonar
xAIXAI_API_KEYgrok-3, grok-2
CohereCOHERE_API_KEYcommand-r-plus, command-a
OpenRouterOPENROUTER_API_KEYAny model via OpenRouter
ReplicateREPLICATE_API_TOKENAny model via Replicate
Azure OpenAIAZURE_OPENAI_API_KEYAzure-hosted models
Ollama(auto at :11434)Any local model
LM Studio(auto at :1234)Any local model

Any OpenAI-compatible API works as a custom provider via the user settings or config file.

Routes

Routes map model patterns to providers. When a request comes in for gpt-4o, the router checks the routes table and sends it to the matching provider.

# List routes
curl http://localhost:4200/api/proxy/routes

Observe

Every proxy request is automatically traced. Observe records model, tokens, cost, latency, and status for every call.

# Get recent traces
curl http://localhost:4200/api/observe/traces?limit=20

# Daily cost breakdown
curl http://localhost:4200/api/observe/costs

# Create an alert
curl -X POST http://localhost:4200/api/observe/alerts \
  -d '{"name":"cost-spike","metric":"cost","condition":"gt","threshold":10}'

Trust

Trust maintains a hash-chained audit ledger. Every proxy request gets an entry with a SHA-256 hash linking it to the previous entry. This creates a tamper-evident log.

# View the audit ledger
curl http://localhost:4200/api/trust/ledger?limit=10

# List policies
curl http://localhost:4200/api/trust/policies

Studio

Studio manages versioned prompt templates, A/B experiments, and benchmarks.

# Run an A/B test across models
curl -X POST http://localhost:4200/api/studio/experiments/run \
  -d '{
    "name": "speed-vs-quality",
    "prompt": "Explain quantum computing in one paragraph",
    "models": ["gpt-4o","claude-sonnet-4-5-20250929","gemini-2.0-flash"],
    "runs": 3,
    "eval": "length"
  }'

Eval methods: length (longer = better), concise (shorter = better), json (valid JSON), contains (keyword match), or empty for cost comparison.

# Run a multi-prompt benchmark
curl -X POST http://localhost:4200/api/studio/benchmarks/run \
  -d '{
    "name": "model-eval-q1",
    "models": ["gpt-4o-mini","deepseek-chat"],
    "prompts": [
      {"name":"summarize","prompt":"Summarize: ...","eval":"concise"},
      {"name":"code","prompt":"Write fizzbuzz","eval":"contains","eval_arg":"for"}
    ],
    "runs": 3
  }'

# Create a versioned prompt template
curl -X POST http://localhost:4200/api/studio/templates \
  -d '{"slug":"summarizer","name":"Summarizer","content":"Summarize: {{text}}"}'

Forge

Forge is a DAG workflow engine. Define multi-step workflows where each step can be an LLM call, a transform, or a tool call. Steps declare dependencies and execute in topological order.

# Create a workflow
curl -X POST http://localhost:4200/api/forge/workflows \
  -d '{
    "slug": "draft-and-critique",
    "name": "Draft + Critique",
    "steps": [
      {"id":"draft","type":"llm","config":{"model":"gpt-4o-mini","prompt":"Write about {{input}}"}},
      {"id":"critique","type":"llm","depends_on":["draft"],
       "config":{"prompt":"Critique: {{steps.draft.output}}"}},
      {"id":"final","type":"transform","depends_on":["draft","critique"],
       "config":{"expression":"concat"}}
    ]
  }'

# Run it
curl -X POST http://localhost:4200/api/forge/workflows/draft-and-critique/run \
  -d '{"input": "the future of AI"}'

# Check status
curl http://localhost:4200/api/forge/runs/{run_id}

Step types: llm (calls the proxy), transform (concat, extract_json, first_line), tool (external tool calls).

Template variables: {{input}} for the run input, {{steps.step_id.output}} for dependency outputs.

Exchange

Exchange is a config pack marketplace. Packs bundle providers, modules, routes, workflows, templates, policies, and alerts into one installable unit.

# List available packs
curl http://localhost:4200/api/exchange/packs

# Install a pack (applies all contents to the system)
curl -X POST http://localhost:4200/api/exchange/packs/safety-essentials/install

# View installed packs
curl http://localhost:4200/api/exchange/installed

# Uninstall (cleanly removes everything the pack added)
curl -X DELETE http://localhost:4200/api/exchange/installed/1
Starter packs
6 packs ship by default: Safety Essentials, Cost Control, OpenAI Quickstart, Anthropic Quickstart, Multi-Provider Failover, and Evaluation Suite.

API Reference

All endpoints are served on the same port as the proxy. Full OpenAPI 3.1 spec available at /api/openapi.json.

MethodPathDescription
GET/api/openapi.jsonOpenAPI 3.1 specification
GET/api/appsList registered apps
GET/healthHealth check
POST/v1/chat/completionsProxy LLM request
GET/api/proxy/modulesList modules
PUT/api/proxy/modules/{name}Toggle module
GET/api/proxy/providersList providers
GET/api/proxy/routesList routes
GET/api/observe/tracesRecent traces
GET/api/observe/costsCost rollups
GET/api/observe/alertsAlert rules
POST/api/observe/alertsCreate alert
GET/api/observe/anomaliesDetected anomalies
GET/api/trust/ledgerAudit ledger
GET/api/trust/policiesTrust policies
POST/api/trust/policiesCreate policy
GET/api/trust/evidenceEvidence packs
GET/api/studio/templatesPrompt templates
POST/api/studio/templatesCreate template
GET/api/studio/experimentsExperiments
POST/api/studio/experiments/runRun A/B test
GET/api/studio/experiments/{id}Get experiment results
POST/api/studio/benchmarks/runRun benchmark suite
POST/api/auth/signupCreate user + API key
GET/api/auth/meCurrent user info
GET/api/auth/me/usageMy usage stats (requests, cost, tokens)
PUT/api/auth/me/providers/{name}Add provider key
GET/api/plansPricing plans
GET/api/forge/workflowsList workflows
POST/api/forge/workflowsCreate workflow
POST/api/forge/workflows/{slug}/runRun workflow
GET/api/forge/runs/{id}Get run status
GET/api/forge/toolsTool registry
GET/api/exchange/packsAvailable packs
GET/api/exchange/packs/{slug}Pack detail
POST/api/exchange/packs/{slug}/installInstall pack
GET/api/exchange/installedInstalled packs
DELETE/api/exchange/installed/{id}Uninstall pack
GET/api/exchange/environmentsEnvironments
POST/api/exchange/environments/{name}/syncSync environment