You can apply Model Rules at the org level by attaching it as an Org Guardrail, giving you complete coverage across all workspaces and API keys.
Use cases
- PHI-compliant workloads: Workspaces that process Protected Health Information (PHI) can have default metadata indicating their compliance requirements. Based on that metadata, you can restrict those workspaces to only access models that meet your data handling standards (e.g., only models hosted in specific regions or on specific providers).
- Tiered model access: Offer different model access based on customer tier — free users get cost-efficient models, enterprise users get unrestricted access.
- Team-specific model policies: Research teams may need access to frontier models, while support teams only need smaller, faster models.
- Cost control: Prevent specific workspaces or API keys from accessing expensive models by mapping their metadata to a restricted model list.
Using Model Rules with Portkey
1. Add a Model Rules check
- Navigate to the
Guardrailspage and clickCreate - Search for
Model Rulesand clickAdd - Fill in the parameters described below
Parameters
The rules object that defines how the allowed model list is resolved. See Rules JSON shape below.
When
true, any model resolved by the rules is blocked instead of allowed.Rules JSON shape
The default list of allowed models, used when no
metadata entry matches the request.Maps request metadata keys to metadata values, which then map to allowed model lists. If a metadata entry matches the request, its model list replaces
defaults for that request.A metadata key from the request, such as
customer_tier or team.The list of allowed models when the metadata key equals this value.
Wildcard
Any entry in an allowed model list can be*. When * is present, every requested model matches that list.
["*"]— allow every model["gpt-4.1-mini", "*"]— equivalent to["*"], any model matches- Combined with
not: true,["*"]blocks every model
Example rules
- Requests with no matching metadata default to
gpt-4.1-mini - Enterprise customers can access any model
- Free-tier customers are restricted to
gpt-4.1-mini - The research team can access
claude-3-7-sonnetandgpt-4.1
2. Set a guardrail action
When you create the guardrail, set the action so failing requests are denied. In most cases you’ll want:- Deny: block the request when the model does not pass the rules
3. Attach the guardrail
Once the guardrail is saved, you’ll get a Guardrail ID. You can apply it in any of these ways:- Add it to
input_guardrailsin a Portkey Config - Attach it to a Workspace so it applies to all requests in that workspace
- Attach it as an Org Guardrail so it applies across the entire organization
4. Make a request with metadata
Send request metadata so the guardrail can resolve the correct model list.customer_tier: enterprise metadata (which allows *), so the request for claude-3-7-sonnet is permitted.

