Docs

API Reference

Schema reference for routes.json, policy options, and environment config. Gateway behavior is declared here.

routes.json

The top-level file defines routes, upstream targets, and each route's policy chains.

Route object

routes.json: route object
{
  "path": "/v1/chat/completions",     // required: URL path to match
  "methods": ["POST"],              // required: HTTP methods to match
  "upstream": "https://...",        // required: upstream base URL
  "pathRewrite": "/chat/completions", // optional: rewrite path before forwarding
  "policies": {
    "inbound": [ ... ],            // run before forwarding
    "outbound": [ ... ]            // run after upstream response
  },
  "corsPolicy": "anything"         // optional: named CORS policy
}

Path parameters

Define dynamic segments with :param. Policies receive the matched value as a request property.

path parameters
"path": "/models/:modelId/completions"

Policy schema

Each entry in an inbound or outbound array is a policy object:

policy object
{
  "name": "my-rate-limit",          // unique name, referenced in logs
  "policyType": "rate-limit-inbound", // policy identifier
  "options": { ... }              // policy-specific options
}

Built-in policy types

policyTypeDirectionDescription
api-key-inboundinboundValidate Zuplo-managed API keys in Authorization header
rate-limit-inboundinboundRequest rate limiter (fixed window, sliding window, or token bucket)
token-budget-inboundinboundDaily token budget per consumer. Reads usage from upstream response.
jwt-inboundinboundJWT validation with JWKS endpoint, RS256/ES256 support
llm-routing-inboundinboundRoute to a provider chain with failover and load balancing
mcp-session-guard-inboundinboundAuth and rate limiting for MCP sessions
request-log-outboundoutboundLog request + response metadata to a configured sink
header-inject-outboundoutboundAdd or override response headers

Environment config

Put secrets and environment-specific values in zuplo.env.json. Reference them in policies with $env(KEY_NAME).

zuplo.env.json
{
  "OPENAI_API_KEY": "sk-...",
  "ANTHROPIC_API_KEY": "sk-ant-...",
  "JWKS_URL": "https://auth.yourapp.com/.well-known/jwks.json"
}

Response codes

HTTP codeMeaning
401API key missing or invalid
403Consumer does not have access to this route
429Rate limit exceeded. Retry-After header included.
502All upstream providers failed (LLM routing exhausted)
503Gateway policy error (misconfigured policy options)