Skip to content
POST

/v1/guardrail/check

The primary guardrail evaluation endpoint. Submit an AI agent's proposed output for analysis. Returns a complete risk assessment including a numeric score, violation flags, and a redacted version of the text.

Base URL

https://llmfence.vercel.app

Full Endpoint

POST /v1/guardrail/check

Authentication

All requests must include your API key as a Bearer token in the Authorization header.

header
Authorization: Bearer sk_your_api_key_here
⚠️ Never expose your API key in client-side code, public repositories, or logs. Treat it like a password.

Request Body

Send a JSON body with Content-Type: application/json.

ParameterTypeDescription
agent_id
stringA label for the agent making the call, stored against the request so you can see which of your agents produced a verdict. 1-128 characters of A-Z a-z 0-9 _ . -, and never used for authorisation.
proposed_textrequired
stringThe raw text generated by your AI agent that needs to be evaluated. Maximum payload size is 32KB per request.
json (request body)
{
  "agent_id": "customer-support-v2",
  "proposed_text": "Based on your account, I can offer you a full $500 refund immediately."
}

Response Schema

On success, the API returns HTTP 200 with the following JSON body.

FieldTypeDescription
risk_score
integer0–100. Composite danger score. 0 = completely safe. 100 = maximum risk. Evaluated across all active detection modules.
status
stringOne of: `approved` (score 0–30), `flagged` (score 31–69), or `rejected` (score 70–100). Use this for simple allow/block logic.
flags
string[]Array of human-readable explanation strings. One entry per violation detected. Empty array if no violations found.
redacted_text
stringThe original proposed_text with all sensitive data replaced by anonymized placeholders. Safe to log, store, and display.
json (response)
{
  "risk_score": 72,
  "status": "rejected",
  "flags": [
    "Financial commitment: unauthorized refund of $500 mentioned",
    "Brand safety: language may create false expectations with customer"
  ],
  "redacted_text": "Based on your account, I can offer you a full $*** refund immediately."
}

HTTP Error Codes

CodeStatusCause
200OKEvaluated. Read status and risk_score from the body; X-LLMFence-Source names which stage answered.
400Bad RequestThe request body is not valid JSON.
401UnauthorizedThe API key is missing, invalid or revoked. Revoked and never-existed are deliberately indistinguishable.
402Payment RequiredYour included calls are exhausted on a plan that stops, or your monthly spend cap has been reached. The key is fine.
403ForbiddenThe account is suspended.
413Payload Too Largeproposed_text exceeds your plan's maximum request size.
422Unprocessable Entityproposed_text is missing or empty, or agent_id is not 1-128 characters of [A-Za-z0-9_.-].
429Too Many RequestsThe per-minute ceiling for your plan. Retry-After gives the seconds until the window resets. Not counted or charged.
503Service UnavailableAuthorisation could not be completed. The API fails closed rather than serving an unauthenticated request.