Guardrails API

Block requests that match a tag, or count what would be blocked, on the models and identities you choose.

Enterprise: this feature is gated behind a separate software license.

Get access

The Guardrails API is an Enterprise feature, gated behind a separate software license; contact founders@experientiallabs.ai to request access.

Manage guardrails with a provisioning key. Your API key determines the organization. Without access, every route answers 404.

TermMeaning
TagA yes or no question the gateway answers about a request, as a probability from 0 to 1
RuleA tag and a threshold. It matches when the probability is at or above the threshold
GuardrailRules, the models and identities they cover, and what a match does

These guardrails are built on tags. The content guardrails you set per group on the Access page are separate and keep running.

GET/v1/guardrails
curl --fail-with-body https://api.experientiallabs.ai/v1/guardrails \
  -H "Authorization: Bearer <YOUR_API_KEY>"
{
  "guardrails": [
    {
      "id": "00000000-0000-4000-8000-000000000010",
      "name": "Content moderation",
      "managed": true,
      "rules": [
        { "tag": "childSexualExploitation" },
        { "tag": "massCasualtyWeapons" },
        { "tag": "fraudAndExtortion" }
      ],
      "models": ["deepseek-v4.1-flash-uncensored", "glm-5.3-uncensored", "glm-5.3-flash-uncensored"]
    }
  ]
}

Choose a tag

Platform tags are ready to use. A custom tag is your own question; custom_tag_limit in the list is how many your organization may hold. These tags are separate from the request tags you send in X-Explabs-Tags.

GET/v1/tagsPOST/v1/tags
FieldWrite
idcamelCase. You use it in rules
questionA yes or no question. Yes means the request matches
definitionWhat counts and what does not. Examples of both make the answer sharper
curl --fail-with-body -X POST https://api.experientiallabs.ai/v1/tags \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "id": "internalConfidential",
  "description": "Confidential company information",
  "question": "Does the message contain confidential company information?",
  "definition": "Confidential: unreleased product plans, customer records, contract terms, internal financial figures, network or security designs. Not confidential: published press releases, public pricing, general industry knowledge."
}'

Test the tag

Score sample text before any request depends on the tag. probability is how likely the answer is yes. Try text that should match and text that should not, then pick a threshold between the two.

POST/v1/tags/evaluate

It is the same check a live request gets. The text goes to a decision model that Experiential hosts, and is not stored.

curl --fail-with-body -X POST https://api.experientiallabs.ai/v1/tags/evaluate \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "tags": ["internalConfidential", "personalData"],
  "input": "Draft the board update. Revenue was 4.2M against a 5M plan and we are pausing the Atlas launch."
}'
{
  "results": [
    { "tag": "internalConfidential", "probability": 0.96 },
    { "tag": "personalData", "probability": 0.02 }
  ]
}

Create a guardrail

A guardrail matches when any of its rules matches. It starts in observe mode: it counts matches, and never blocks, delays or fails a request.

POST/v1/guardrails
FieldChoice
timingparallel (default) checks while the model generates and holds the response until the check passes. before_dispatch finishes the check before the request is sent to a model
models or exclude_modelsCover only these models, or every model except these. Leave both out to cover every model. Both are compared with the model that serves the request
identity_idsCover only these identities. Leave out to cover every identity
on_errorWhat happens when the check does not finish within max_wait_ms, or the request carries content it cannot read: allow or block

Use before_dispatch when the request itself must not leave, such as confidential data and an external model. Use parallel when only the response must be held back. timing, max_wait_ms and on_error take effect in enforce mode.

{
  "name": "Keep confidential data off external models",
  "timing": "before_dispatch",
  "rules": [
    { "tag": "internalConfidential", "threshold": 0.5 }
  ],
  "exclude_models": ["my-local-model"],
  "on_error": "block"
}
curl --fail-with-body -X POST https://api.experientiallabs.ai/v1/guardrails \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  --data @guardrail.json

Observe, then enforce

Let real traffic run, then read the counts. In observe mode, matched is what enforce would have blocked.

GET/v1/guardrails/{guardrail_id}/decisions

When the count looks right, switch the mode. The change applies to new requests within a minute.

PATCH/v1/guardrails/{guardrail_id}
{
  "window": "7d",
  "checked": 18234,
  "matched": 41,
  "blocked": 0,
  "errors": 3,
  "by_tag": [
    { "tag": "internalConfidential", "matched": 41 }
  ]
}
curl --fail-with-body -X PATCH https://api.experientiallabs.ai/v1/guardrails/00000000-0000-4000-8000-000000000011 \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"mode": "enforce"}'

What a blocked request looks like

In enforce mode a blocked request is not charged. The x-gateway-guardrail response header carries the id of your guardrail that blocked it.

OutcomeResponse
A rule matched400 content_filter
The request carries content the check cannot read, on_error: block400 content_filter
The check did not finish in time, on_error: block503 gateway_unavailable, retryable
Either of the last two, on_error: allowThe request continues and counts under errors
{
  "error": {
    "message": "The request was blocked by a gateway guardrail.",
    "type": "invalid_request_error",
    "param": null,
    "code": "content_filter"
  }
}

What a check reads

One check serves every guardrail and routing policy on a request. Waits are not added together: the request waits at most the longest max_wait_ms that applies.

ItemDetail
ReadThe text of every message in the request: system prompt, user and assistant turns, tool results
MatchA rule matches when any message scores at or above its threshold
ReuseResults are reused when a conversation resends the same messages, so later turns wait only for new text
Not readImages, audio and files. A request that carries them counts as content the check cannot read
CoveredChat Completions, Responses, Messages and Gemini requests
Not coveredEmbeddings, images, audio, video and batches. An enforcing guardrail of yours refuses them on the models it covers with 400 content_filter
Where it runsA decision model that Experiential hosts. The text is not sent to another provider and is not stored

A request that runs server-side tools, such as web search, is checked before dispatch even under parallel.

LimitValue
Rules per guardrail16
max_wait_ms0 to 5,000 for parallel, 100 to 5,000 for before_dispatch. Default 250 and 2,000
thresholdAbove 0, up to 1. Default 0.5
Tags per evaluate call32

Content moderation on uncensored models

The platform's moderation of uncensored models runs on the same tags. Your list shows it with managed: true. You cannot change or remove it, and it shows only its name, tags and models. The settings on this page describe the guardrails you create.

The same platform tags work in your own guardrails, on any model.

{
  "name": "Moderation for the support bot",
  "rules": [
    { "tag": "fraudAndExtortion", "threshold": 0.4 }
  ],
  "models": ["my-local-model"],
  "on_error": "allow"
}

Errors

Status / codeAction
401Check the key
403Use a provisioning key. tag_read_only and guardrail_read_only mean a platform resource
404Check the id and your access to the API
409 tag_existsChoose another id
409 tag_limit_reachedDelete a custom tag, or ask for a higher limit
409 tag_in_useRemove the rules that name the tag first
422Fix the body. unknown_tag, unknown_model and unknown_identity name what does not exist
503 check_unavailableThe check could not run on an evaluate call. Retry
{
  "error": "Your organization has reached its custom tag limit",
  "code": "tag_limit_reached"
}