The kinds
The console’s Policies page has four tabs: Rate limits, Budgets, Model restrictions and Logging config. Access policies and token limits have no tab, but they are enforced like the rest and are written through the API.
The first five are evaluated in the order shown above, cheapest and most decisive first. A request refused by an access policy never consumes a rate-limit token, and a request refused by any of them never reaches a provider.
The per-request token ceilings are checked when the request is first evaluated, against the prompt as submitted (the output ceiling needs no count), and again after PII redaction against the prompt that will be sent. Tokens-per-minute limits and token budgets are judged only after the prompt is counted, which happens after redaction, guardrails and the cache lookup. A cache hit consumes no upstream tokens, so it is not charged against a token rate limit, but it is still refused by a per-request ceiling.
Scope
Every policy names a scope, and the chain runs outermost to innermost:team_id, service_account_id, user_id, api_key_id or end_user_id; naming two is refused). An end user is one of your own users, identified by the id your backend sends in X-ManyLayers-Metadata; it is organization-scoped, so end_user_id is valid at organization scope too. Leaving the target unset governs everything in the scope. scope: "organization" governs every workspace of the product; it needs gateway.ratelimits.manage plus the permission for that kind of policy, held across the product, and it cannot name an API key or service account, which belong to one workspace.
Semantics worth knowing
Model restrictions. No policy means every model the workspace resolves. An allow-list permits only what it names; a deny-list refuses what it names; when both match a model, deny wins. Two allow-lists at different rungs intersect rather than combine. A restriction may name a model on every provider account (gpt-4o) or on one (openai-dev/gpt-4o). A virtual model is judged target by target: an allow-list that does not list it still lets it serve the targets the list does permit, while a deny-list that names it refuses it outright. Team-level models lists and virtual account allowlists are checked separately and also have to pass.
Access policies. A deny bans the identity it names, and must name a team, service account, user, API key or end user. An allow is stronger than it looks: one enabled allow policy turns its scope into an allow-list, and every identity it does not name is refused. A deny always beats an allow. An optional endpoints list (exact request paths such as /v1/embeddings) confines the policy to those paths; empty means all. Requests to /v1/messages and /v1/responses are matched as /v1/chat/completions, so list that path to govern them; a policy listing /v1/messages or /v1/responses never matches.
Rate limits target a user, a team, a model, or a subject and a model together — user, team, model, user + model, team + model. Arun on gpt-4o-mini is one rule with both dimensions, not two rules: it caps that pair and neither Arun’s other models nor other people’s use of that model. A rule with no model named caps every model.
Each rule is its own ceiling on its own counter, and every rule that matches a request must allow it. A request under a 100/min workspace rule, a 50/min team rule and a 10/min user+model rule has to satisfy all three; the first to refuse is the one you are told about. The team and key limit columns (rpm_limit, tpm_limit) are checked first; policy rules then follow, outermost first. Two rules on the same dimensions are two independent ceilings rather than one merged one. See Rate limiting.
The model is the logical name — what a request carries in its model field. Rate limits and budgets also accept an account address (openai-dev/gpt-4o) and account/* for every model on a provider account. A limit on enterprise-smart keeps applying when you re-point it from OpenAI to Azure. An alias resolves to the model it points at, so switching to an alias does not escape the limit.
Token limits cap one request — its input, its requested completion, or the total (input plus requested completion). They are not rate limits: tokens_per_minute on a rate limit governs consumption over time, these govern a single request and are checked before the provider is called. Zero means no limit, at least one must be set, and a total cannot be smaller than the input or output ceiling. A request that names no max_tokens (max_completion_tokens and max_output_tokens also count) is not refused by an output ceiling, because the gateway cannot know what a provider will generate.
Budgets are measured from the same usage records your invoice comes from, so a budget and a bill cannot disagree. See Budgets.
Logging config rules decide whether a scope’s request and response bodies are recorded on the audit log (log_requests) and what is redacted from the stored copy (redaction: PII, secrets, custom regex patterns). Redaction changes only what is stored; the model receives and returns the content unchanged.
Disabled is not zero. A disabled policy is the absence of a limit, not a limit of zero. It stays listed so it can be turned back on.
How a change reaches the gateway
500 policy evaluation failed rather than being reported as a limit. A rate-limit check never fails this way: the limiter fails open if Redis errors.
Refusals
Every refusal from the policy engine carries
X-ManyLayers-Limit naming the scope that bound (organization, workspace, team, service_account, user, api_key or end_user), so you know which ceiling to raise. Rate-limit refusals also carry Retry-After; budget refusals deliberately do not, because waiting does not refill a budget. The exceptions: a per-end-user budget refusal carries a budget object in the body instead of the header, and budget_initializing carries Retry-After: 1 because the spend is merely not yet known.
A refusal never names the policy that produced it. The scope is enough to act on, and the configuration of other scopes is not the caller’s business.
API
Console API athttps://app.manylayers.io. All routes are workspace-scoped; pass ?workspace_id= when your credential can reach more than one workspace. Every POST takes a name (optional for budgets) and the optional scope / target fields described above; PATCH takes {"enabled": bool}, except on logging configs, which take {"log_requests": bool}.
The scope, target and (for rate limits and budgets) the model and
applies_per are fixed once a policy exists: moving one changes which requests it governs and which counter it uses, which is a new policy rather than an edit. A duplicate name in the same scope returns 409; for budgets, a duplicate subject, model and period does. GET .../budgets/{id}/consumption needs gateway.budgets.read and returns {dimension, limit_amount, currency, per_subject_limit, consumers[]}: who has spent against that budget.
Permissions
An organization-wide policy needs
gateway.ratelimits.manage and its own kind’s permission across the whole product, not just inside one workspace. See Access control.