Guardrails
Guardrails are governance policies bound to API keys. When an API key is created, the system copies the policy into a snapshot. When a model request enters api-gateway, the gateway validates against that snapshot instead of reading the latest policy each time.
This means editing a policy may not change behavior for existing keys. To apply a new policy, create a new key, validate it, then revoke the old key.
Enforced Constraints
The current api-gateway enforces these constraints on POST /openai/v1/chat/completions:
Execution Order
Tier Constraints
The final allowed tier set is built from multiple layers:
allowed_tiersfrom the policy snapshot, ortierswhenallowed_tiersis empty.- The API key’s own
tier. - The request body’s
tier. - Wallet balance checks remove tiers with zero balance.
If no tier remains, the request fails. For model: "auto", if the selected tier cannot be frozen due to insufficient wallet balance, the gateway can retry routing to another allowed tier.
IP Policy
The gateway resolves client IP from:
Rules support exact IPs and CIDR ranges:
Model Policy
Budget and Wallet
API key validation returns limit_total, limit_daily, and limit_weekly. Policies can also include daily_limit / weekly_limit. In the current gateway path, wallet balance and freeze are the direct enforcement points: